From 3bdbf5198302a1797316d3372afcbe073e531617 Mon Sep 17 00:00:00 2001 From: Amy Retzerau Date: Thu, 9 Jan 2025 00:38:14 +0100 Subject: [PATCH] dynamic wallpapers :3 --- .../user/timers.target.wants/wallpaper.timer | 1 + .config/systemd/user/wallpaper.service | 6 +++++ .config/systemd/user/wallpaper.timer | 8 ++++++ wallpaper/script.sh | 26 +++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 120000 .config/systemd/user/timers.target.wants/wallpaper.timer create mode 100644 .config/systemd/user/wallpaper.service create mode 100644 .config/systemd/user/wallpaper.timer create mode 100755 wallpaper/script.sh diff --git a/.config/systemd/user/timers.target.wants/wallpaper.timer b/.config/systemd/user/timers.target.wants/wallpaper.timer new file mode 120000 index 0000000..6a7f387 --- /dev/null +++ b/.config/systemd/user/timers.target.wants/wallpaper.timer @@ -0,0 +1 @@ +/home/amy/.config/systemd/user/wallpaper.timer \ No newline at end of file diff --git a/.config/systemd/user/wallpaper.service b/.config/systemd/user/wallpaper.service new file mode 100644 index 0000000..891cb02 --- /dev/null +++ b/.config/systemd/user/wallpaper.service @@ -0,0 +1,6 @@ +[Unit] +Description=Time based wallpaper switcher + +[Service] +Type=simple +ExecStart=%h/wallpaper/script.sh diff --git a/.config/systemd/user/wallpaper.timer b/.config/systemd/user/wallpaper.timer new file mode 100644 index 0000000..1db6d86 --- /dev/null +++ b/.config/systemd/user/wallpaper.timer @@ -0,0 +1,8 @@ +[Unit] +Description=Run foo weekly and on boot + +[Timer] +OnCalendar=minutely +Persistent=false +[Install] +WantedBy=timers.target diff --git a/wallpaper/script.sh b/wallpaper/script.sh new file mode 100755 index 0000000..e968e73 --- /dev/null +++ b/wallpaper/script.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +PATHNAME=~/wallpaper/ +cd $PATHNAME +printf -v date "%(%H)T" + +LAST=-1 +FOUND=-1 +for filename in $(ls *.png | sort -g) +do + if ((${filename%%.*} >= date && ${FOUND%%.*} == -1));then + echo ${FOUND%%.*} + FOUND=$LAST + if ((${FOUND%%.*}==-1));then + FOUND=-2 + fi + fi + LAST=$filename +done + +if ((${FOUND%%.*} < 0));then + FOUND=$LAST +fi + +hyprctl hyprpaper wallpaper ",$PATHNAME$FOUND" +echo ${FOUND%%.*}