wallpaper-changer systemd service
This commit is contained in:
parent
67c39715ce
commit
03495183b2
|
@ -1,15 +1,53 @@
|
||||||
{ pkgs, ... }:
|
{
|
||||||
let
|
pkgs,
|
||||||
scripts = {
|
...
|
||||||
swww-wallpaper-changer = pkgs.writeShellApplication {
|
}:
|
||||||
name = "swww-wallpaper-changer";
|
{
|
||||||
text = builtins.readFile ./swww-wallpaper-changer.sh;
|
systemd.user.services.wallpaper-changer = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Script to change wallpaper using swww";
|
||||||
|
After = [ "graphical-session.target" ]; # or "wayland.target", depending on your system setup
|
||||||
|
#After = [ "hyprland-session.target" ];
|
||||||
|
};
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "default.target" ];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
Restart = "on-failure"; # This will make the service restart on failure
|
||||||
|
ExecStart= "${pkgs.writeShellScript "swww-daemon" ''
|
||||||
|
${pkgs.swww}/bin/swww-daemon
|
||||||
|
''}";
|
||||||
|
ExecStartPost = "${pkgs.writeShellScript "swww-wallpaper-changer" ''
|
||||||
|
#!/run/current-system/sw/bin/bash
|
||||||
|
export WAYLAND_DISPLAY="wayland-1"
|
||||||
|
set +o errexit
|
||||||
|
set +o nounset
|
||||||
|
set +o pipefail
|
||||||
|
script_name=''${BASH_SOURCE[0]}
|
||||||
|
for pid in $(pidof -x "$script_name"); do
|
||||||
|
if [ "$pid" != $$ ]; then
|
||||||
|
kill -15 "$pid"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
#[ "$XDG_SESSION_TYPE" != "wayland" ] && echo "Not a Wayland session, exiting." && exit 1
|
||||||
|
wallpaper_dir="$HOME/.local/share/bg/"
|
||||||
|
|
||||||
|
swww_daemon_pid=$(pidof -x 'swww-daemon')
|
||||||
|
swww_pid=$(pidof -x 'swww')
|
||||||
|
|
||||||
|
#[ -z "$swww_daemon_pid" ] || kill -15 "$swww_daemon_pid"
|
||||||
|
[ -z "$swww_pid" ] || kill -15 "$swww_pid"
|
||||||
|
#${pkgs.swww}/bin/swww-daemon &
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
find "$wallpaper_dir" -type f -follow \( -iname \*.jpg -o -iname \*.png -o -iname \*.gif -o -iname \*.bmp \) | shuf | while read -r file; do
|
||||||
|
${pkgs.swww}/bin/swww img "$file" --transition-step 10 --transition-fps 60
|
||||||
|
[ $? != 0 ] && echo "swww failed. Exiting" && exit 1
|
||||||
|
sleep 3
|
||||||
|
done
|
||||||
|
done
|
||||||
|
''}";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
|
||||||
{
|
|
||||||
home.packages = builtins.attrValues {
|
|
||||||
inherit (scripts)
|
|
||||||
swww-wallpaper-changer;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
# sddm
|
# sddm
|
||||||
# sshfs-fuse
|
# sshfs-fuse
|
||||||
# wdisplays
|
# wdisplays
|
||||||
wallpaper_changer
|
#wallpaper_changer
|
||||||
# #(callPackage ../../nixos_modules/themes/sddm-sugar-candy.nix{}).sddm-sugar-candy-theme
|
# #(callPackage ../../nixos_modules/themes/sddm-sugar-candy.nix{}).sddm-sugar-candy-theme
|
||||||
# libsForQt5.qt5.qtgraphicaleffects #required for sugar candy
|
# libsForQt5.qt5.qtgraphicaleffects #required for sugar candy
|
||||||
# #(import ../../nixos_modules/scripts/wallpaper_changer.nix { inherit pkgs; })
|
# #(import ../../nixos_modules/scripts/wallpaper_changer.nix { inherit pkgs; })
|
||||||
|
|
Loading…
Reference in New Issue