Biont/sway-launcher-desktop

override command to add swaymsg exec

Opened this issue · 4 comments

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

@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?

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

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?

this way it works :)