Closed ThatOneCalculator closed 2 years ago
im setting the wallpaper with exec-once and then swaybg. If there was a hook that could run after an action it would be trivial to run a wallpaper switcher.
idk how to do hooks other than sockets, can you like listen to a socket with a bash script?
Added a UNIX sockets-based event system. See the IPC wiki page for events.
To see them live, do something like for example:
socat - UNIX-CONNECT:/tmp/hypr/.socket2.sock
However you want to handle that, you can now.
Lmk how to execute a script with a param on each event, I want to know myself too, but I suck at bash :P
@vaxerski
Here is how to execute a command on each workspace event
#!/bin/zsh
function handle {
if [[${1:0:9} == "workspace" ]]; then
echo $line
fi
}
socat - UNIX-CONNECT:/tmp/hypr/.socket2.sock | while read line; do handle $line; done
I set my background with
swaybg --image $(find $HOME/Pictures/Wallpaper -type f | shuf -n 1) -m fill
but that doesn't seem to like running inside of the function because it doesn't exit and needs to stay running to keep the background
okay, thanks.
But that seems like a script issue, no? you can always killall swaybg
and run swaybg each time in the bg.
At any rate, I'd consider this issue closed. It is now possible.
@japrogramer please lmk when you make a working script :pray:
@ThatOneCalculator
#!/bin/zsh
swaybg --image $(find $HOME/Pictures/Wallpaper -type f | shuf -n 1) -m fill&
function handle {
if [[ ${1:0:9} == "workspace" ]]; then
echo $line
killall swaybg
swaybg --image $(find $HOME/Pictures/Wallpaper -type f | shuf -n 1) -m fill&
fi
}
socat - UNIX-CONNECT:/tmp/hypr/.socket2.sock | while read line; do handle $line; done
this works when I run it from the shell but im having trouble calling it from hyprland.conf in an exec-once. so if you figure that out let me know
When I run it from shell, I get
./wall.sh:12: closing brace expected
typo in all swaybg it's ${ and should be $(
thanks oomfie ur the bestest
fixed in the comment
Works fine from shell, but briefly shows the Hyprland logo when switching workspaces
Also works fine when adding exec=/home/me/wall.sh
to hyprland.conf
I don't get that hyprland logo issue, I have a black background for my hyprland instance. thanks, I see I had a typo on my call.
now using
exec-once=sh -c \$HOME/.config/hypr/wallpaper_switch.sh
ah. How can I set the bg to be black instead of the hyprland logo?
I don't know It happened after the latest build I made from main.
weird...
The hyprland logo is due to the delay. You kill swaybg, and then before the new swaybg can initialize and load the image there is a gap.
so maybe store the current swaybg task pid in a variable and kill it after the new swaybg starts
yep, wait a couple sec and then kill
on the side note: this method SUCKS for multimon users. I'll tweak the events a bit.
Despite some initially odd behavior, the results from this are really pretty.
Oh Nice! ill move the kill to after the new swaybg spawns
r/unixporn would be proud.
Fixed them events. Also added activemon and activewindow.
Oh Nice! ill move the kill to after the new swaybg spawns
You can just wait 1s or something before killing old swaybg. The new one will open on top, anyway.
This is the new script with the delay kill
#!/bin/zsh
swaybg --image $(find $HOME/Pictures/Wallpaper -type f | shuf -n 1) -m fill&
function handle {
if [[ ${1:0:9} == "workspace" ]]; then
echo $line
swpid=`ps axf | grep swaybg | grep -v grep | awk '{printf $1}'`
swaybg --image $(find $HOME/Pictures/Wallpaper -type f | shuf -n 1) -m fill&
sleep .3
kill $swpid
fi
}
socat - UNIX-CONNECT:/tmp/hypr/.socket2.sock | while read line; do handle $line; done
Note: that if you switch to the same workspace you are in, it also changes the wallpaper
Note: that if you switch to the same workspace you are in, it also changes the wallpaper
i fixed that already, recompile
On the side note: the fact that it's even possible to do something like this, this quickly and easily is what I love about loonux
thanks, will recompile.
Pushed a new version to the AUR so that those who aren't on devel
will be prompted to recompile from source :heart:
@ThatOneCalculator Here is a new version of the script which works with the new socket file location, and the script tries to avoid repeating the wallpaper between workspace changes.
#!/bin/zsh
background=$(find $HOME/Pictures/Wallpaper -type f | shuf -n 1)
swaybg --image $background -m fill&
function handle {
if [[ ${1:0:9} == "workspace" ]]; then
echo $line
newbackground=$(find $HOME/Pictures/Wallpaper -type f | shuf -n 1)
echo $newbackground
until [[ ("${background}" != "${newbackground}") && (-r $newbackground) ]]; do
newbackground=$(find $HOME/Pictures/Wallpaper -type f | shuf -n 1)
echo $newbackground
sleep .3
done
echo $newbackground
background=newbackground
swpid=`ps axf | grep swaybg | grep -v grep | awk '{printf $1}'`
swaybg --image $newbackground -m fill&
sleep .3
kill $swpid
fi
}
socat - UNIX-CONNECT:/tmp/hypr/${HYPRLAND_INSTANCE_SIGNATURE}/.socket2.sock | while read line; do handle $line; done
Describe in detail your idea.
The ability to designate different wallpapers to different workspaces would be great :)