Biont / sway-launcher-desktop

TUI Application launcher with Desktop Entry support. Made for SwayWM, but runs anywhere
GNU General Public License v3.0
613 stars 29 forks source link

override command to add swaymsg exec #33

Closed ghost closed 3 years ago

ghost commented 3 years ago

Hello, thank you for this project which helps me every day to have a fast and minimal environment. I use Sway and I would like my windows to appear on the same workspace where I ran sway-launcher-desktop. swaymsg exec ... can help for that.

Since this commit https://github.com/Biont/sway-launcher-desktop/commit/df557aa663fdf8bce38021cf1f72acc74ee73923 sway-launcher-desktop no longer uses swaymsg exec ... but it's a need I have. How can I modify the command sent to /bin/sh to make it run `swaymsg exec ...' before my command and thus find the spawn of my windows on the right workspace ? Thanks

Biont commented 3 years ago

@GreyXor Hey sorry for not replying earlier. I made a little tweak that allows redirecting the raw command to another program: If the script detects that its output goes to a terminal, it will launch the script like usual. If it detects it's being piped, it merely prints the command. So now you can do swaymsg exec "$(./sway-launcher-desktop.sh)" to achieve what you want.

Can you test it and see if this works for you?

ghost commented 3 years ago

No problem ofc, thank you for #28

like this it's not seems to work (sway-launcher-desktop is globally accessible in my arch)

for_window [app_id="^launcher$"] floating enable, resize set 30 ppt 60 ppt, border pixel 10

bindsym $mod+d exec alacritty --class=launcher -e swaymsg exec "$(sway-launcher-desktop)"

but i think it's more a problem about alacritty, the terminal it isn't spawned

Biont commented 3 years ago

Right, I believe this is because this kind of command substitution is not possible inside a sway keybinding because it's not running through a shell.

Could you try placing something like this somewhere available in your $PATH:

/home/GreyXor/bin/swaymsg-launcher-desktop

#!/usr/bin/env bash
swaymsg exec "$(sway-launcher-desktop)"

and then use bindsym $mod+d exec alacritty --class=launcher -e swaymsg-launcher-desktop to trigger it?

ghost commented 3 years ago

this way it works :)