From 0d41f7a41878fc86765a4bf6bf3575e640868bd7 Mon Sep 17 00:00:00 2001 From: Tyler Kelley Date: Mon, 17 Jun 2024 03:20:29 -0500 Subject: [PATCH] update wallsetter script using Zsolt's code from a merge request. Thank you! Your sick --- scripts/wallsetter.nix | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/scripts/wallsetter.nix b/scripts/wallsetter.nix index 55e5356..6f391a6 100644 --- a/scripts/wallsetter.nix +++ b/scripts/wallsetter.nix @@ -1,19 +1,24 @@ -{ pkgs, username, ... }: +{ pkgs, ... }: pkgs.writeShellScriptBin "wallsetter" '' - WALLPAPER=$(find /home/${username}/Pictures/Wallpapers -name '*' | awk '!/.git/' | tail -n +2 | shuf -n 1) - PREVIOUS=$WALLPAPER - if [ "$WALLPAPER" == "$PREVIOUS" ]; then - WALLPAPER=$(find /home/${username}/Pictures/Wallpapers -name '*' | awk '!/.git/' | tail -n +2 | shuf -n 1) - fi - if [ -d /home/${username}/Pictures/Wallpapers ]; then - num_files=$(ls -1 /home/${username}/Pictures/Wallpapers | wc -l) - if [ $num_files -lt 1 ]; then - notify-send -t 9000 "The wallpaper folder is expected to have more than 1 image. Exiting Wallsetter." - exit - fi + TIMEOUT=720 - ${pkgs.swww}/bin/swww img "$WALLPAPER" --transition-type random - fi + for pid in $(pidof -o %PPID -x wallsetter); do + kill $pid + done + + if ! [ -d ~/Pictures/Wallpapers ]; then notify-send -t 5000 "~/Pictures/Wallpapers does not exist" && exit 1; fi + if [ $(ls -1 ~/Pictures/Wallpapers | wc -l) -lt 1 ]; then notify-send -t 9000 "The wallpaper folder is expected to have more than 1 image. Exiting Wallsetter." && exit 1; fi + + while true; do + while [ "$WALLPAPER" == "$PREVIOUS" ]; do + WALLPAPER=$(find ~/Pictures/Wallpapers -name '*' | awk '!/.git/' | tail -n +2 | shuf -n 1) + done + + PREVIOUS=$WALLPAPER + + ${pkgs.swww}/bin/swww img "$WALLPAPER" --transition-type random --transition-step 1 --transition-fps 60 + sleep $TIMEOUT + done ''