mirror of
https://git.in.rschanz.org/ryan77627/guix-config.git
synced 2024-11-07 08:16:09 -05:00
wallpaper daemon
This commit is contained in:
parent
3b3b1f7ff0
commit
121b0c3b6a
8 changed files with 99 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,2 +1,3 @@
|
|||
current
|
||||
home-config/sway/monitors
|
||||
*.gif
|
||||
|
|
Before Width: | Height: | Size: 522 KiB After Width: | Height: | Size: 522 KiB |
Before Width: | Height: | Size: 1 MiB After Width: | Height: | Size: 1 MiB |
|
@ -10,10 +10,12 @@ mako &
|
|||
|
||||
swww init &
|
||||
|
||||
~/.config/hypr/wallpaper-daemon.sh &
|
||||
|
||||
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' &
|
||||
|
||||
syncthing serve --no-browser &
|
||||
|
||||
wl-clip-persist -c regular &
|
||||
|
||||
kanshi -c ~/.config/hypr/kanshi.conf
|
||||
~/.config/guix/home-config/hypr/hyprland-monitor-attached ~/.config/hypr/wallpaper.sh ~/.config/hypr/wallpaper.sh &
|
||||
|
|
BIN
home-config/hypr/hyprland-monitor-attached
Executable file
BIN
home-config/hypr/hyprland-monitor-attached
Executable file
Binary file not shown.
|
@ -1,4 +0,0 @@
|
|||
profile {
|
||||
output * enable
|
||||
exec ~/.config/hypr/wallpaper.sh
|
||||
}
|
89
home-config/hypr/wallpaper-daemon.sh
Executable file
89
home-config/hypr/wallpaper-daemon.sh
Executable file
|
@ -0,0 +1,89 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Script initialization
|
||||
rm /tmp/$USER-desktop-anim
|
||||
# Check if animated wallpapers exist, set env var if so
|
||||
# Sleep for swww init to finish
|
||||
sleep 3
|
||||
script_init() {
|
||||
if [ `find ~/.config/hypr/Wallpapers/animated/ -name '*.gif' | wc -l` -gt 0 ]; then
|
||||
echo "true" > /tmp/$USER-desktop-anim
|
||||
ANIM_READY=true
|
||||
else
|
||||
# Download or bail here?
|
||||
echo "no animations found, static only!"
|
||||
fi
|
||||
}
|
||||
# check if on ac or battery
|
||||
check_if_ac() {
|
||||
ON_AC=`cat /sys/class/power_supply/AC/online`
|
||||
if [ $ON_AC -eq 1 ] && [ "$ANIM_READY" = true ]; then
|
||||
echo "Anim"
|
||||
init_anim
|
||||
else
|
||||
echo "Static"
|
||||
init_static
|
||||
fi
|
||||
}
|
||||
|
||||
init_static() {
|
||||
# On battery or missing wallpapers, just load a random image
|
||||
IMG=`find ~/.config/hypr/Wallpapers/static/ -type f | sort -R | tail -n1`
|
||||
echo $IMG >> /tmp/$USER-desktop-anim
|
||||
swww img $IMG
|
||||
# This is hacky but sometimes we get into a race condition where the
|
||||
# animated background will load anyways, so this will ensure we stay static
|
||||
# until we definitely control swww and its state is known
|
||||
sleep 60
|
||||
swww img $IMG
|
||||
}
|
||||
|
||||
init_anim() {
|
||||
# Preload a static image until the animated one is ready
|
||||
swww img --transition-step 255 `find ~/.config/hypr/Wallpapers/static/ -type f | sort -R | tail -n1`
|
||||
sleep 2
|
||||
IMG=`find ~/.config/hypr/Wallpapers/animated/ -name '*.gif' | sort -R | tail -n1`
|
||||
echo $IMG >> /tmp/$USER-desktop-anim
|
||||
swww img $IMG
|
||||
}
|
||||
|
||||
begin_randomizer() {
|
||||
while :; do
|
||||
echo "Invoke selector"
|
||||
sleep 3600
|
||||
if [ `cat /sys/class/power_supply/AC/online` -eq 1 ] && [ `cat /tmp/$USER-desktop-anim | head -n1` == "true" ]; then
|
||||
switch_check `find ~/.config/hypr/Wallpapers/animated/ -name '*.gif' | sort -R | tail -n1`
|
||||
else
|
||||
switch_check `find ~/.config/hypr/Wallpapers/static/ -type f | sort -R | tail -n1`
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
switch_check() {
|
||||
# Simply query what image is displayed and make sure we do not overwrite
|
||||
# it. This is more for animated wallpapers since it causes corruption
|
||||
CURRENT_FILE=`swww query | awk -F'/' '{print $NF}'`
|
||||
SELECTION=`echo $1 | awk -F'/' '{print $NF}'`
|
||||
|
||||
if ! [ "$CURRENT_FILE" == "$SELECTION" ]; then
|
||||
# Update the file
|
||||
sed -i '2c'"$1" /tmp/$USER-desktop-anim
|
||||
# Set the background!
|
||||
swww img $1
|
||||
fi
|
||||
}
|
||||
|
||||
script_init
|
||||
check_if_ac
|
||||
begin_randomizer &
|
||||
|
||||
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)}' |
|
||||
while read -r line; do
|
||||
if [ "$line" == "true" ]; then
|
||||
echo "switching to ac"
|
||||
switch_check `find ~/.config/hypr/Wallpapers/animated/ -name '*.gif' | sort -R | tail -n1`
|
||||
elif [ "$line" == "false" ]; then
|
||||
echo "switching to bat"
|
||||
switch_check `find ~/.config/hypr/Wallpapers/static/ -type f | sort -R | tail -n1`
|
||||
fi
|
||||
done
|
|
@ -1,6 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Eventually allow for multiple animated backgrounds to be rotated.
|
||||
# Right now just reset the current image for when outputs are changed
|
||||
sleep 2
|
||||
|
||||
swww img ~/.config/hypr/Wallpapers/above-clouds.jpg
|
||||
# Get currently loaded image
|
||||
IMG=`cat /tmp/$USER-desktop-anim | tail -n1`
|
||||
|
||||
# Load it for the monitors
|
||||
swww img $IMG
|
||||
|
|
Loading…
Reference in a new issue