Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Launch with JSON #67

Merged
merged 3 commits into from
Jan 3, 2025
Merged

Launch with JSON #67

merged 3 commits into from
Jan 3, 2025

Conversation

matyalatte
Copy link
Owner

Related to #55.

Tuw now takes the first argument as a JSON path. If you rename JSON files to *.tuw and set Tuw as a default application for opening *.tuw, you can launch GUI just by clicking *.tuw files.

Changes

  • When the first argument contains ., tuw uses it as a JSON file for gui definition. And working directory will be the JSON file's directory.
  • Tuw now uses the default CWD to resolve paths in command-line arguments. (Old versions used executable's directory as CWD.)

@matyalatte matyalatte added the enhancement New feature or request label Dec 21, 2024
@matyalatte
Copy link
Owner Author

matyalatte commented Dec 21, 2024

How to set default applications.

How to set Tuw as a default application for opening *.tuw

Windows

  1. Right click a *.tuw file and select Open with....
  2. Check Always use this app to open .tuw file and select Tuw.exe.

Ubuntu

1. Add application/x-tuw to ~/.local/share/mime/packages/Overrides.xml

(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>

2. Make ~/.local/share/applications/tuw.desktop.

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;

3. Update database

$ update-mime-database ~/.local/share/mime
$ update-desktop-database ~/.local/share/applications/
$ xdg-mime default tuw.desktop application/x-tuw

macOS

1. Make AppleScript

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

[!Note]
You have to make a wrapper for Tuw with AppleScript, because macOS applications do not pass paths as arguments when opening files. It requires native API to get the opening file paths but Tuw does not support it yet.

2. Export the script as an application. (File > Export...)

export_applescript

3. Right click a .tuw file and set Tuw as a default application.

@matyalatte matyalatte merged commit d0d5e60 into dev Jan 3, 2025
9 checks passed
@matyalatte matyalatte deleted the launch_with_json branch January 6, 2025 07:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant