modify feh-wallpaper-changer to kill previous instance

This commit is contained in:
Sam 2024-06-16 12:53:07 +01:00
parent 08f1789b50
commit 97ff165b02
2 changed files with 10 additions and 1 deletions

View File

@ -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
'';
};
}

View File

@ -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"