Files
nixos/Droidnix/assets/traveldroid/Wallpapers/scripts/wallpaper.sh
T
2026-04-05 21:00:20 +02:00

49 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
set -euo pipefail
WALLPAPER_DIR="$HOME/Wallpapers"
# -----------------------------
# Set wallpaper on all monitors
# -----------------------------
set_wallpaper_all_monitors() {
pic="$1"
monitors=$(hyprctl monitors -j | jq -r '.[].name') # list all monitor names
for m in $monitors; do
awww img -o "$m" -t fade --transition-duration 1 "$pic"
done
}
# -----------------------------
# Handle workspace events
# -----------------------------
handle() {
case $1 in
workspace*)
workspace="${1: -1}" # last character
pic=""
case $workspace in
1) pic="$WALLPAPER_DIR/01.jpg" ;;
2) pic="$WALLPAPER_DIR/02.jpg" ;;
3) pic="$WALLPAPER_DIR/03.jpg" ;;
4) pic="$WALLPAPER_DIR/04.jpg" ;;
5) pic="$WALLPAPER_DIR/05.jpg" ;;
6) pic="$WALLPAPER_DIR/06.jpg" ;;
7) pic="$WALLPAPER_DIR/07.jpg" ;;
8) pic="$WALLPAPER_DIR/08.jpg" ;;
9) pic="$WALLPAPER_DIR/09.jpg" ;;
10) pic="$WALLPAPER_DIR/10.jpg" ;;
esac
[ -n "$pic" ] && set_wallpaper_all_monitors "$pic"
;;
esac
}
# -----------------------------
# Listen to Hyprland socket events
# -----------------------------
socat -U - UNIX-CONNECT:"$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock" | while read -r line; do
handle "$line"
done