Update for the new socket location of hyprpaper 0.7

This commit is contained in:
Keith Bowes 2024-07-10 16:00:01 -04:00
parent 3f0814fd56
commit 2643966144

View file

@ -37,21 +37,26 @@ get_random_wallpaper()
} }
load_wallpaper() { load_wallpaper() {
if (which hyprpaper && which socat && which wayland-info) >/dev/null 2>&1; then uses_wayland_info=0
if (which hyprpaper && which socat && (test "$uses_wayland_info" = "0" || which wayland-info)) >/dev/null 2>&1; then
hyprpaper & hyprpaper &
HYPRPAPER_SOCKET=/tmp/hypr/.hyprpaper.sock HYPRPAPER_SOCKET="${XDG_RUNTIME_DIR:-"/run/user/$(id -u)"}"/hypr/.hyprpaper.sock
# Change the wallpaper every hour # Change the wallpaper every hour
while test -S $HYPRPAPER_SOCKET; do while test -S "$HYPRPAPER_SOCKET"; do
#current_output=$(wayland-info -i wl_output | \ if test "$uses_wayland_info" != "0";
# grep 'name:' | tail -n 1 | cut -d : -f 2 | tr -d ' ') then
current_output=$(wayland-info -i wl_output | \
grep 'name:' | tail -n 1 | cut -d : -f 2 | tr -d ' ')
fi
random_wallpaper="$(get_random_wallpaper)" random_wallpaper="$(get_random_wallpaper)"
for cmd in "preload $random_wallpaper" \ for cmd in "preload $random_wallpaper" \
"wallpaper $current_output,$random_wallpaper" \ "wallpaper $current_output,$random_wallpaper" \
'unload all'; 'unload all';
do do
printf "$cmd" | socat UNIX-CONNECT:$HYPRPAPER_SOCKET - printf "$cmd" | socat UNIX-CONNECT:"$HYPRPAPER_SOCKET" -
done done
[ $? -eq 0 ] && sleep 60m [ $? -ne 0 ] && rm -f $HYPRPAPER_SOCKET
sleep 60m
done done
elif which swaybg >/dev/null 2>&1; then elif which swaybg >/dev/null 2>&1; then
get_random_wallpaper | xargs swaybg -c '#303030' -m fill -i & get_random_wallpaper | xargs swaybg -c '#303030' -m fill -i &