mirror of
https://gitlab.com/Zaney/zaneyos.git
synced 2025-02-20 18:40:47 +01:00
Updated wallsetter.nix:
single-instance, smoother animation, won't select same wallpaper twice, automatic timeout, to change wallpaper immediately just call the script again
This commit is contained in:
parent
fe9745e7fe
commit
c8bdd0dcff
@ -1,19 +1,24 @@
|
|||||||
{ pkgs, username, ... }:
|
{ pkgs, ... }:
|
||||||
|
|
||||||
pkgs.writeShellScriptBin "wallsetter" ''
|
pkgs.writeShellScriptBin "wallsetter" ''
|
||||||
WALLPAPER=$(find /home/${username}/Pictures/Wallpapers -name '*' | awk '!/.git/' | tail -n +2 | shuf -n 1)
|
|
||||||
|
TIMEOUT=720
|
||||||
|
|
||||||
|
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
|
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
|
${pkgs.swww}/bin/swww img "$WALLPAPER" --transition-type random --transition-step 1 --transition-fps 60
|
||||||
notify-send -t 9000 "The wallpaper folder is expected to have more than 1 image. Exiting Wallsetter."
|
sleep $TIMEOUT
|
||||||
exit
|
done
|
||||||
fi
|
|
||||||
|
|
||||||
${pkgs.swww}/bin/swww img "$WALLPAPER" --transition-type random
|
|
||||||
fi
|
|
||||||
''
|
''
|
||||||
|
Loading…
Reference in New Issue
Block a user