Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support reloading image via SIGUSR? #64

Open
ieugen opened this issue Feb 6, 2024 · 1 comment
Open

Support reloading image via SIGUSR? #64

ieugen opened this issue Feb 6, 2024 · 1 comment

Comments

@ieugen
Copy link

ieugen commented Feb 6, 2024

Hello,

Would it make sense to support reloading the image / reset swaybg via sending a SIGUSR signal?

Currently I use a process like this:

Inspired by https://sylvaindurand.org/dynamic-wallpapers-with-sway/

#!/bin/sh
PID=`pidof swaybg`
swaybg -i $HOME/.config/sway/background-image -m fill &
sleep 1
kill -9 $PID

I have another script that randomly replaces, every hour, the symbolic link that I have at $HOME/.config/sway/background-image .

The issue with the above solution is that it sometimes fails and I get a grey screen.
Don't know why.

@ieugen
Copy link
Author

ieugen commented Feb 6, 2024

I think I found a solution using systemd to manage the process instead.

save this as ~/.config/systemd/user/swaybg.service

[Unit]
Description=Display swaywm background image

[Service]
ExecStart=swaybg -i /home/ieugen/.config/sway/background-image -m fill

[Install]
WantedBy=default.target
# Then install the service
systemct --user enable swaybg.service
# And then to reload, sympli restart the service
systemct --user restart swaybg.service

Feel free to use the text above, add it to docs if you think it's valuable.
Or I could send a PR.

For completion, this is what I use to randomly choose an image from my collection:
~/.local/bin/random-background-image.sh

#!/bin/sh

export NEW_IMG="$(find $HOME/Poze/Imagini.fundal -type f | shuf -n1)"
echo "Using new backgruond image $NEW_IMG"
ln -sf "$NEW_IMG" /home/ieugen/.config/sway/background-image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant