feat: allow multiple commands
Hey there!
First of all, congrats on the project! Very, very cool bringing this functionality to Linux. To me, these details are what make me thrilled about my setup and make me enjoy using my laptop daily.
I am using your project on KDE Plasma Wayland, so I'm using a custom command to set the desktop wallpaper:
[setter]
command = ['plasma-apply-wallpaperimage', '%f']
overlap = 0
quiet = true
This simple command handles the desktop wallpaper perfectly, no complaints there. However, the lock screen is another story... To set the lock screen wallpaper, I need to run this:
kwriteconfig5 --file kscreenlockerrc --group Greeter --group Wallpaper --group org.kde.image --group General --key Image 'path/to/image'
And this is where my problem arises, I would like to run 2 distinct commands in order to update both my desktop wallpaper and my lock screen wallpaper. I tried doing this by adding "&&" to the command array like you would on shell, but it just recognizes everything as an argument of the first command.
Of course, I can create a script that runs both commands and then make timewall call that script, but its just a hassle that could be avoided.
Props again for the project, wanna learn Rust too. 🙌🏼
Hi, thanks for a lot of kind words!
I have to admit that just using a script in such cases is what I would recommend and what I had in mind when creating timewall. In fact, I use a script for this too.
Unfortunately, I don't think I will implement support for multiple commands. I don't think think it's worth complicating the code and putting additional effort into an issue which can be trivially worked around. I realize that this might seem like a very simple feature, but I will just give you a hint of some things that need to be taken into account:
- Configuration backwards compatibility.
- Should the commands be run sequentially or concurrently? There's no way to satisfy everyone with a single option so it would probably have to be configurable.
- timewall supports long running commands which don't exit after setting the wallpaper. With multiple commands this requires keeping track of multiple concurrent background processes.
To sum up - it's much more complicated than it seems at first and it would require significant effort.
If you really want to keep everything in the config file though, there's another workaround which doesn't require a script. You can call your shell of choice and run as many commands as you like via the shell. E.g.:
[setter]
command = ['bash', '-c', 'plasma-apply-wallpaperimage "%f" && kwriteconfig5 --file kscreenlockerrc --group Greeter --group Wallpaper --group org.kde.image --group General --key Image "%f"']
Let me know if you find this advice useful. Maybe I should add a hint that this is possible to the README 😄.
Hi again, thanks for the clarification!
What I ended up doing was exactly that, writing a bash script that handled everything and, taking into account that it only took me a few minutes to do so, you're probably right about it being too much effort for a problem that can be easily solved 😅
The only thing I would suggest is that it would be cool to have a section in your README exploring this possibility and also the workaround that you mentioned of calling bash in the command, as you suggested. There could also be sub-sections on what commands to run for a couple different common setups, in my case for example it took me some effort and research to find the correct commands to use for KDE and I would be open to write a section on KDE :) It's totally okay if you don't think it is worth it though.
Let me know what you think!
Documentation is always a good idea 😄.
I added an example of using bash -c as a command and added Wallpaper setting commands section. For now it contains commands just for Gnome and Plasma. I might extend this in the future.
Thanks for the suggestions!