philj56 / tofi

Tiny dynamic menu for Wayland
MIT License
884 stars 37 forks source link

I can't open some apps with tofi-drun #60

Closed gmr458 closed 1 year ago

gmr458 commented 1 year ago

I am using Fedora 36 with Hyprland and when I use the command tofi-drun | xargs hyprctl dispatch exec I can open programs like Calendar, Alacritty, Sublime Text, Kitty, Calculator, Firefox, but other programs like Spotify, GNOME Files, VS Code, VLC Media Player don't open.

This is the output trying to open GNOME Files:

> tofi-drun | xargs hyprctl dispatch exec
[ real,   cpu,   maxRSS]
[0.000, 0.008,  5956 KB][DEBUG]: This is tofi.
[0.000, 0.008,  5956 KB][DEBUG]: First roundtrip start.
[0.000, 0.009,  5956 KB][DEBUG]:    Bound to shm 1.
[0.000, 0.009,  5956 KB][DEBUG]:    Bound to compositor 4.
[0.000, 0.009,  5956 KB][DEBUG]:    Bound to seat 15.
[0.000, 0.009,  5956 KB][DEBUG]:    Bound to zwlr_layer_shell_v1 18.
[0.000, 0.009,  5956 KB][DEBUG]:    Bound to output 42.
[0.000, 0.009,  5956 KB][DEBUG]: First roundtrip done.
[0.000, 0.009,  5956 KB][DEBUG]: Second roundtrip start.
[0.000, 0.009,  5956 KB][DEBUG]:    Got keyboard from seat.
[0.000, 0.009,  5956 KB][DEBUG]:    Got pointer from seat.
[0.000, 0.009,  5956 KB][DEBUG]:    Output configuration done.
[0.000, 0.009,  5956 KB][DEBUG]: Second roundtrip done.
[0.001, 0.009,  5956 KB][DEBUG]: Selected output eDP-1.
[0.001, 0.009,  5956 KB][DEBUG]: Generating desktop app list.
[0.001, 0.009,  5956 KB][DEBUG]:    Retrieving cache location.
[0.001, 0.009,  5956 KB][DEBUG]:    Retrieving application dirs.
[0.001, 0.009,  5956 KB][DEBUG]:    Cache up to date, loading.
[0.001, 0.009,  5956 KB][DEBUG]:    Moving already known apps to the front.
[0.001, 0.009,  5956 KB][DEBUG]: App list generated.
[0.001, 0.009,  5956 KB][DEBUG]: Creating main window surface.
[0.001, 0.009,  5956 KB][DEBUG]: Third roundtrip start.
[0.001, 0.009,  5956 KB][DEBUG]:    Configuring keyboard.
[0.006, 0.014,  8176 KB][DEBUG]:    Keyboard configured.
[0.006, 0.014,  8176 KB][DEBUG]:    Key repeat every 31 ms after 200 ms.
[0.006, 0.014,  8176 KB][DEBUG]:    Layer surface configure, 1280 x 720.
[0.006, 0.014,  8176 KB][DEBUG]: Third roundtrip done.
[0.006, 0.014,  8176 KB][DEBUG]: Initialising window surface.
[0.006, 0.014,  8176 KB][DEBUG]:    Created shm file with size 7200 KiB.
[0.006, 0.014,  8176 KB][DEBUG]: Window surface initialised.
[0.006, 0.014,  8176 KB][DEBUG]: Initialising renderer.
[0.012, 0.019, 12212 KB][DEBUG]:    Creating Pango context.
[0.012, 0.020, 12804 KB][DEBUG]:    Creating Pango font description.
[0.012, 0.020, 12804 KB][DEBUG]:    Initial text render.
[0.045, 0.059, 18500 KB][DEBUG]:    Drew 13 results.
[0.045, 0.059, 18500 KB][DEBUG]: Renderer initialised.
[0.052, 0.059, 18500 KB][DEBUG]: Layer surface configure, 1280 x 720.
[0.052, 0.059, 18500 KB][DEBUG]: Surface entered output.
[4.402, 0.066, 22076 KB][DEBUG]: Window closed, performing cleanup.
[4.410, 0.067, 22076 KB][DEBUG]: Finished, exiting.
usage: hyprctl [(opt)flags] [command] [(opt)args]

commands:
    monitors
    workspaces
    clients
    activewindow
    layers
    devices
    dispatch
    keyword
    version
    kill
    splash
    hyprpaper
    reload
    setcursor
    getoption
    cursorpos

flags:
    -j -> output in JSON
    --batch -> execute a batch of commands, separated by ';'
philj56 commented 1 year ago

I think this is an issue in Hyprland. As far as I can tell, the problem is that those .desktop files pass command line arguments in their Exec= line, e.g. --unity-launch for VSCode. In Sway, you can handle that by passing --, after which all arguments are assumed to be for the command to be run:

> tofi-drun | xargs swaymsg exec --
# Selecting VSCode results in "swaymsg exec -- code-oss --unity-launch"

With hyprctl, it just sees the --unity-launch and complains about an invalid argument. Until this is fixed, you should be able to work around it by passing --drun-launch=true to tofi, though this can have other undesirable effects such as launching programs on the wrong monity.

philj56 commented 1 year ago

Alright, this should be possible in Hyprland now:

> tofi-drun | xargs hyprctl dispatch exec --
gmr458 commented 1 year ago

Thanks for the help, tofi-drun --drun-launch=true | xargs hyprctl dispatch exec -- is now working for me from the terminal, but no from the Hyprland keybinding, it has to be a problem with Hyprland.

philj56 commented 1 year ago

You shouldn't use --drun-launch if you're feeding it to Hyprland, that makes tofi try to launch the command itself (and not print anything out)

gmr458 commented 1 year ago

Sorry, I forgot to update my Hyprland dotfiles, tofi-drun --drun-launch=true works perfect.