From 97ff165b022d540ea5ad4d25f146372e2df57e41 Mon Sep 17 00:00:00 2001 From: Sam Date: Sun, 16 Jun 2024 12:53:07 +0100 Subject: [PATCH] modify feh-wallpaper-changer to kill previous instance --- home/common/optional/desktop/cinnamon/autostart.nix | 2 +- .../desktop/common/x11/scripts/feh-wallpaper-changer.nix | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/home/common/optional/desktop/cinnamon/autostart.nix b/home/common/optional/desktop/cinnamon/autostart.nix index f55270d..bb1b6b9 100644 --- a/home/common/optional/desktop/cinnamon/autostart.nix +++ b/home/common/optional/desktop/cinnamon/autostart.nix @@ -10,7 +10,7 @@ Hidden=false Name[en_GB]=feh-wallpaper-changer Comment[en_GB]=Periodically changes the wallpaper using feh - X-GNOME-Autostart-Delay=0 + X-GNOME-Autostart-Delay=5 ''; }; } diff --git a/home/common/optional/desktop/common/x11/scripts/feh-wallpaper-changer.nix b/home/common/optional/desktop/common/x11/scripts/feh-wallpaper-changer.nix index cfa8550..c4da625 100644 --- a/home/common/optional/desktop/common/x11/scripts/feh-wallpaper-changer.nix +++ b/home/common/optional/desktop/common/x11/scripts/feh-wallpaper-changer.nix @@ -2,6 +2,15 @@ { home.packages = with pkgs; [ (writeShellScriptBin "feh-wallpaper-changer" '' + + # Kill previous instance if exists + script_name=''${BASH_SOURCE[0]} + for pid in $(pidof -x $script_name); do + if [ $pid != $$ ]; then + kill -9 $pid + fi + done + wallpaper_dir="$HOME/.local/share/bg/" if [ ! -d "$wallpaper_dir" ]; then echo "No wallpapers in $wallpaper_dir, cloning from remote"