Tuw can take the first argument as a JSON path if the path includes a file extension. By renaming your JSON files to *.tuw
and setting Tuw as a default application for *.tuw
files, you can launch GUIs just by clicking on the files.
On Windows, setting Tuw as the default application is straightforward. However, for other operating systems, the process is a bit more complex. Below are examples of how to set it up on Ubuntu 20.04 and macOS 10.15.
(Make Overrides.xml
if it does not exist.)
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-tuw">
<comment>TUW custom file</comment>
<glob pattern="*.tuw"/>
</mime-type>
</mime-info>
Replace /full/path/to/Tuw
with your path to Tuw. And save it as tuw.desktop
.
[Desktop Entry]
Version=1.0
Type=Application
Name=Tuw
Comment=Tiny GUI wrapper for CLI tools
Exec=/full/path/to/Tuw %f
Terminal=false
MimeType=application/x-tuw;
Categories=Utility;Application;
You can apply the changes with the following commands.
update-mime-database ~/.local/share/mime
update-desktop-database ~/.local/share/applications/
xdg-mime default tuw.desktop application/x-tuw
Open the script editor and write the following AppleScript. And replace /full/path/to/Tuw
with your path to Tuw.
on open fileList
-- Modify this variable for your environment
set exePath to "/full/path/to/Tuw"
set filePath to item 1 of fileList
set posixFilePath to POSIX path of filePath
tell application "Terminal"
do script exePath & " " & posixFilePath & "; exit;"
end tell
end open