diff options
| author | Ryan Schanzenbacher <ryan@rschanz.org> | 2023-11-07 20:42:30 -0500 | 
|---|---|---|
| committer | Ryan Schanzenbacher <ryan@rschanz.org> | 2023-11-07 20:42:30 -0500 | 
| commit | 121b0c3b6a68ee7df4c31ef11780be0a07da0810 (patch) | |
| tree | 9b6b362cd9b971850e015c6b03ec2ef52f2824f2 | |
| parent | 3b3b1f7ff013d770865dbf5f284f6e7328e0d7b3 (diff) | |
wallpaper daemon
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | home-config/hypr/Wallpapers/static/above-clouds.jpg (renamed from home-config/hypr/Wallpapers/above-clouds.jpg) | bin | 535067 -> 535067 bytes | |||
| -rw-r--r-- | home-config/hypr/Wallpapers/static/mountains.jpg (renamed from home-config/hypr/Wallpapers/mountains.jpg) | bin | 1097089 -> 1097089 bytes | |||
| -rwxr-xr-x | home-config/hypr/autostart.sh | 4 | ||||
| -rwxr-xr-x | home-config/hypr/hyprland-monitor-attached | bin | 0 -> 4690512 bytes | |||
| -rw-r--r-- | home-config/hypr/kanshi.conf | 4 | ||||
| -rwxr-xr-x | home-config/hypr/wallpaper-daemon.sh | 89 | ||||
| -rwxr-xr-x | home-config/hypr/wallpaper.sh | 9 | 
8 files changed, 99 insertions, 8 deletions
| @@ -1,2 +1,3 @@ | |||
| 1 | current | 1 | current | 
| 2 | home-config/sway/monitors | 2 | home-config/sway/monitors | 
| 3 | *.gif | ||
| diff --git a/home-config/hypr/Wallpapers/above-clouds.jpg b/home-config/hypr/Wallpapers/static/above-clouds.jpg index a525ee8..a525ee8 100644 --- a/home-config/hypr/Wallpapers/above-clouds.jpg +++ b/home-config/hypr/Wallpapers/static/above-clouds.jpg | |||
| Binary files differ | |||
| diff --git a/home-config/hypr/Wallpapers/mountains.jpg b/home-config/hypr/Wallpapers/static/mountains.jpg index f51a09b..f51a09b 100644 --- a/home-config/hypr/Wallpapers/mountains.jpg +++ b/home-config/hypr/Wallpapers/static/mountains.jpg | |||
| Binary files differ | |||
| diff --git a/home-config/hypr/autostart.sh b/home-config/hypr/autostart.sh index b05b71d..e09ef2b 100755 --- a/home-config/hypr/autostart.sh +++ b/home-config/hypr/autostart.sh | |||
| @@ -10,10 +10,12 @@ mako & | |||
| 10 | 10 | ||
| 11 | swww init & | 11 | swww init & | 
| 12 | 12 | ||
| 13 | ~/.config/hypr/wallpaper-daemon.sh & | ||
| 14 | |||
| 13 | swayidle -w timeout 300 'swaylock --screenshots --clock --indicator --grace 3 --fade-in 1 --effect-blur 7x5 --effect-greyscale' timeout 600 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' before-sleep 'swaylock -f -c 000000' & | 15 | swayidle -w timeout 300 'swaylock --screenshots --clock --indicator --grace 3 --fade-in 1 --effect-blur 7x5 --effect-greyscale' timeout 600 'hyprctl dispatch dpms off' resume 'hyprctl dispatch dpms on' before-sleep 'swaylock -f -c 000000' & | 
| 14 | 16 | ||
| 15 | syncthing serve --no-browser & | 17 | syncthing serve --no-browser & | 
| 16 | 18 | ||
| 17 | wl-clip-persist -c regular & | 19 | wl-clip-persist -c regular & | 
| 18 | 20 | ||
| 19 | kanshi -c ~/.config/hypr/kanshi.conf | 21 | ~/.config/guix/home-config/hypr/hyprland-monitor-attached ~/.config/hypr/wallpaper.sh ~/.config/hypr/wallpaper.sh & | 
| diff --git a/home-config/hypr/hyprland-monitor-attached b/home-config/hypr/hyprland-monitor-attached new file mode 100755 index 0000000..9c22710 --- /dev/null +++ b/home-config/hypr/hyprland-monitor-attached | |||
| Binary files differ | |||
| diff --git a/home-config/hypr/kanshi.conf b/home-config/hypr/kanshi.conf deleted file mode 100644 index 6a2cbfe..0000000 --- a/home-config/hypr/kanshi.conf +++ /dev/null | |||
| @@ -1,4 +0,0 @@ | |||
| 1 | profile { | ||
| 2 | output * enable | ||
| 3 | exec ~/.config/hypr/wallpaper.sh | ||
| 4 | } | ||
| diff --git a/home-config/hypr/wallpaper-daemon.sh b/home-config/hypr/wallpaper-daemon.sh new file mode 100755 index 0000000..5f53d33 --- /dev/null +++ b/home-config/hypr/wallpaper-daemon.sh | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | #!/usr/bin/env bash | ||
| 2 | |||
| 3 | # Script initialization | ||
| 4 | rm /tmp/$USER-desktop-anim | ||
| 5 | # Check if animated wallpapers exist, set env var if so | ||
| 6 | # Sleep for swww init to finish | ||
| 7 | sleep 3 | ||
| 8 | script_init() { | ||
| 9 | if [ `find ~/.config/hypr/Wallpapers/animated/ -name '*.gif' | wc -l` -gt 0 ]; then | ||
| 10 | echo "true" > /tmp/$USER-desktop-anim | ||
| 11 | ANIM_READY=true | ||
| 12 | else | ||
| 13 | # Download or bail here? | ||
| 14 | echo "no animations found, static only!" | ||
| 15 | fi | ||
| 16 | } | ||
| 17 | # check if on ac or battery | ||
| 18 | check_if_ac() { | ||
| 19 | ON_AC=`cat /sys/class/power_supply/AC/online` | ||
| 20 | if [ $ON_AC -eq 1 ] && [ "$ANIM_READY" = true ]; then | ||
| 21 | echo "Anim" | ||
| 22 | init_anim | ||
| 23 | else | ||
| 24 | echo "Static" | ||
| 25 | init_static | ||
| 26 | fi | ||
| 27 | } | ||
| 28 | |||
| 29 | init_static() { | ||
| 30 | # On battery or missing wallpapers, just load a random image | ||
| 31 | IMG=`find ~/.config/hypr/Wallpapers/static/ -type f | sort -R | tail -n1` | ||
| 32 | echo $IMG >> /tmp/$USER-desktop-anim | ||
| 33 | swww img $IMG | ||
| 34 | # This is hacky but sometimes we get into a race condition where the | ||
| 35 | # animated background will load anyways, so this will ensure we stay static | ||
| 36 | # until we definitely control swww and its state is known | ||
| 37 | sleep 60 | ||
| 38 | swww img $IMG | ||
| 39 | } | ||
| 40 | |||
| 41 | init_anim() { | ||
| 42 | # Preload a static image until the animated one is ready | ||
| 43 | swww img --transition-step 255 `find ~/.config/hypr/Wallpapers/static/ -type f | sort -R | tail -n1` | ||
| 44 | sleep 2 | ||
| 45 | IMG=`find ~/.config/hypr/Wallpapers/animated/ -name '*.gif' | sort -R | tail -n1` | ||
| 46 | echo $IMG >> /tmp/$USER-desktop-anim | ||
| 47 | swww img $IMG | ||
| 48 | } | ||
| 49 | |||
| 50 | begin_randomizer() { | ||
| 51 | while :; do | ||
| 52 | echo "Invoke selector" | ||
| 53 | sleep 3600 | ||
| 54 | if [ `cat /sys/class/power_supply/AC/online` -eq 1 ] && [ `cat /tmp/$USER-desktop-anim | head -n1` == "true" ]; then | ||
| 55 | switch_check `find ~/.config/hypr/Wallpapers/animated/ -name '*.gif' | sort -R | tail -n1` | ||
| 56 | else | ||
| 57 | switch_check `find ~/.config/hypr/Wallpapers/static/ -type f | sort -R | tail -n1` | ||
| 58 | fi | ||
| 59 | done | ||
| 60 | } | ||
| 61 | |||
| 62 | switch_check() { | ||
| 63 | # Simply query what image is displayed and make sure we do not overwrite | ||
| 64 | # it. This is more for animated wallpapers since it causes corruption | ||
| 65 | CURRENT_FILE=`swww query | awk -F'/' '{print $NF}'` | ||
| 66 | SELECTION=`echo $1 | awk -F'/' '{print $NF}'` | ||
| 67 | |||
| 68 | if ! [ "$CURRENT_FILE" == "$SELECTION" ]; then | ||
| 69 | # Update the file | ||
| 70 | sed -i '2c'"$1" /tmp/$USER-desktop-anim | ||
| 71 | # Set the background! | ||
| 72 | swww img $1 | ||
| 73 | fi | ||
| 74 | } | ||
| 75 | |||
| 76 | script_init | ||
| 77 | check_if_ac | ||
| 78 | begin_randomizer & | ||
| 79 | |||
| 80 | dbus-monitor --system "interface='org.freedesktop.DBus.Properties',member='PropertiesChanged',sender=':1.2',path='/org/freedesktop/UPower/devices/line_power_AC'" 2>/dev/null | stdbuf -o0 awk -F' ' '/variant boolean/ {print $(NF)}' | | ||
| 81 | while read -r line; do | ||
| 82 | if [ "$line" == "true" ]; then | ||
| 83 | echo "switching to ac" | ||
| 84 | switch_check `find ~/.config/hypr/Wallpapers/animated/ -name '*.gif' | sort -R | tail -n1` | ||
| 85 | elif [ "$line" == "false" ]; then | ||
| 86 | echo "switching to bat" | ||
| 87 | switch_check `find ~/.config/hypr/Wallpapers/static/ -type f | sort -R | tail -n1` | ||
| 88 | fi | ||
| 89 | done | ||
| diff --git a/home-config/hypr/wallpaper.sh b/home-config/hypr/wallpaper.sh index 7d9ea21..ac2c627 100755 --- a/home-config/hypr/wallpaper.sh +++ b/home-config/hypr/wallpaper.sh | |||
| @@ -1,6 +1,9 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh | 
| 2 | 2 | ||
| 3 | # Eventually allow for multiple animated backgrounds to be rotated. | 3 | sleep 2 | 
| 4 | # Right now just reset the current image for when outputs are changed | ||
| 5 | 4 | ||
| 6 | swww img ~/.config/hypr/Wallpapers/above-clouds.jpg | 5 | # Get currently loaded image | 
| 6 | IMG=`cat /tmp/$USER-desktop-anim | tail -n1` | ||
| 7 | |||
| 8 | # Load it for the monitors | ||
| 9 | swww img $IMG | ||
