philj56 / tofi

Tiny dynamic menu for Wayland
MIT License
878 stars 36 forks source link

tofi-drun: launch application on selected workspace #14

Closed 7ff04da4aa6ac37197e249299066ac30 closed 2 years ago

7ff04da4aa6ac37197e249299066ac30 commented 2 years ago

So I ditched j4-dmenu-desktop in favor of tofi's built in drun, which has been great and blazingly fast. The only thing I miss is the ability (or characteristic, rather?) is that I could set sway exec to launch the application selected by j4-dmenu-desktop, and it would launch on the workspace selected (for example, I could launch GIMP on workspace 4 and, even though it has a slow startup, I could change back to workspace 1 and the application would still open on workspace 4).

The command I had for launching applications this way was: set $menu 'j4-dmenu-desktop --no-generic --use-xdg-de --dmenu="tofi --hint-font false --config ~/.config/tofi/config.ini && sway exec {cmd}"'.

I am aware of the examples in the README of tofi, though neither set $drun tofi-drun | xargs swaymsg exec gio launch or set $drun tofi-drun --drun-launch=true works the same way as I had it set before. Maybe I am being oblivious of something, but is there any way to achieve the behaviour I've described before?

philj56 commented 2 years ago

Passers-by, please read this.

Ok, I think I've fixed this in df3495a160878fd28e3642b47087024429bd512f (see the commit message for more detailed info). I had hoped that xargs swaymsg exec gio launch would do the right thing, but it seems not.

For now, you can fix it by following the new advice in the README, and use

set $drun tofi-drun --drun-print-exec=true | xargs swaymsg exec --

Unfortunately, I can't fix this by default without breaking people's configs, so I've put warnings where I can and will make a release soon, then change the defaults in the release after that. Hopefully that prevents too many problems, but I'll also leave this issue open until then in case it helps a few more people see the necessary change.

Please could you let me know if this fixes it for you? If so, I'll make a release with the warnings.

7ff04da4aa6ac37197e249299066ac30 commented 2 years ago

This fixes the behaviour described, and I'm very happy to say that I do not depend on j4-dmenu-desktop anymore.

Please do warn users when you change the defaults. For now, tofi works perfectly for my use case, using the option --drun-print-exec=true.

philj56 commented 2 years ago

Great! I've made a release.

Please do warn users when you change the defaults

Yeah, I'm very tempted not to change them, but with how new this is I think it's better to get it out of the way now than keep broken behaviour forever. Still, there's warning in the terminal output of tofi when you run tofi-drun without --drun-print-exec=true, the output of tofi -h, the README, the man page, and the release notes, so hopefully it gets to most users.

7ff04da4aa6ac37197e249299066ac30 commented 2 years ago

Actually, by using it a bit, I've encountered an issue: I use my browser as a sort of wrapper for discord, using a profile for that. So the Exec line on the desktop file looks like this: Exec=/usr/lib/librewolf/librewolf %u -P Discord --class discordProfile.

However, when launching it with tofi, the default profile is launched. Further, when enclosing the command with quotes, I receive the following message: xargs: unmatched double quote; by default quotes are special to xargs unless you use the -0 option. When passing the -0 option, I receive no error message and the browser launches, but still on the default profile.

I don't have this issue when using KDE's launcher, Krunner. It opens the correct browser profile just fine, so I think this could be related to the new addition of --drun-print-exec=true. I could be wrong, of course.

philj56 commented 2 years ago

This is why I originally tried not to do any parsing of the Exec line myself 😅 But that should be fixed in b02063d48236a4d33022d77e75b727497f97f96a. It had a bug that meant any text after the last % field code would be missed, so your exec line resulted in just Exec=/usr/lib/librewolf/librewolf.

Thanks for the detailed report, it really helps nailing down issues like this quickly!

7ff04da4aa6ac37197e249299066ac30 commented 2 years ago

I believe everything's fixed now, so thanks, once again.

Thanks for the detailed report, it really helps nailing down issues like this quickly!

Well, it's in my own interest to be as precise as possible, as I'm not a very technical person and seeing as tofi is quickly becoming one of my favourite programs :)

philj56 commented 2 years ago

Alright, I've made --drun-print-exec always true in c0d3df8af0328280836ccfef85ae7e40eb3b6b87, so you should be able to remove it from your configs and have everything keep working. I'll make a release in a day or two with it in and close this issue then.

philj56 commented 2 years ago

v0.4.0's out now, so I'm closing this.