swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.68k stars 1.11k forks source link

sway{bar,bg}_command support for passing args #5724

Open mmonaco opened 4 years ago

mmonaco commented 4 years ago

As of now (HEAD) swaybar_command and swaybg_command take everything as the executable, spaces and all, regardless of quotes. It would be useful to be able to pass a richer command line (as we can for exec), without wrapper scripts. Some bars take e.g., flags to control logging levels. My case is probably a bit over the top but I like for the command to be systemd-cat -t swaybg /usr/bin/swaybg to help me debug / learn.

Apologies if this is WAI

emersion commented 4 years ago

I don't see a good way of doing this.

mmonaco commented 4 years ago

TL;DR;? It must already be possible to parse a command line, honoring whitespace, no? A la exec?

emersion commented 4 years ago

We pass sway{bar,bg}_command to exec(3), which doesn't accept arguments, just a filename. I'm not willing to re-implement word splitting.

mmonaco commented 4 years ago

On mobile now, but isn't it execve or similar? We pass the bar id to bars for example. Can you please be clear if you don't like the idea at all or patches welcome?

emersion commented 4 years ago

Ah, I was thinking you'd want to support swaybar_command "cmd arg1 arg2 arg3", not swaybar_command cmd arg1 arg2 arg3. Now assuming you were planning to do the latter.

I'm still on the fence because this allows to easily break CLI args (by specifying flags Sway already specifies). Also, I don't want complexity to be added to the spawning code just because of this new feature.

alexdewar commented 1 month ago

A possible workaround is to write a script which passes whatever arguments you want to your swaybar along with the ones passed by sway ($@) and then set this as your swaybar_command.