diff --git a/users/price/conf/swww-wallpapers/default.nix b/users/price/conf/swww-wallpapers/default.nix new file mode 100644 index 00000000..fff94666 --- /dev/null +++ b/users/price/conf/swww-wallpapers/default.nix @@ -0,0 +1,84 @@ +{ pkgs, ... }: +let + wallpapers = ./wallpapers; +in +{ + home.packages = [ pkgs.swww ]; + systemd.user = { + services = { + swww-daemon = { + Service = + let + cleanup-socket-script = pkgs.writeShellScript "swww-daemon-cleanup-socket" '' + # Remove the existing swww.socket if it exists, avoids some issues with swww-daemon + # startup where swww-daemon claims the address is already in use + if [[ -w "$XDG_RUNTIME_DIR/swww.socket" ]]; then + rm -f $XDG_RUNTIME_DIR/swww.socket || exit 1 + fi + ''; + in + { + RestartSec = 3; + PassEnvironment = [ "XDG_RUNTIME_DIR" ]; + ExecStartPre = "${cleanup-socket-script}"; + ExecStopPost = "${cleanup-socket-script}"; + ExecStart = "${pkgs.swww}/bin/swww-daemon"; + }; + Install.WantedBy = [ "graphical-session.target" ]; + Unit = { + Description = "Wayland Wallpaper Service"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session.target" ]; + }; + }; + swww-watch-wallpapers = { + Service = { + RestartSec = 3; + Environment = [ + "SWWW_TRANSITION_FPS=120" + "SWWW_TRANSITION_STEP=30" + "SWWW_TRANSITION_DURATION=0.75" + ]; + ExecStart = "${ + pkgs.writeShellApplication { + name = "swww-watch-wallpapers"; + runtimeInputs = with pkgs; [ + swww + coreutils + ]; + text = '' + set -eEuo pipefail + + main() { + local prev_mons_connected=0 + local mons_connected=0 + local cached_swww_query + + while sleep 1; do + cached_swww_query="$(swww query)" + mons_connected="$(wc -l <<< "$cached_swww_query")" + if ((mons_connected != prev_mons_connected)); then + prev_mons_connected="$mons_connected" + swww img -t random ${wallpapers}/Nebula.jpg + if [[ "$cached_swww_query" =~ "eDP-1: "* ]]; then + swww img -t wipe --transition-angle 40 -o eDP-1 ${wallpapers}/Autumn-Leaves.jpg + fi + fi + done + } + + main + ''; + } + }/bin/swww-watch-wallpapers"; + }; + Install.WantedBy = [ "swww-daemon.service" ]; + Unit = { + Description = "Wayland Wallpaper Service"; + PartOf = [ "swww-daemon.service" ]; + After = [ "swww-daemon.service" ]; + }; + }; + }; + }; +} diff --git a/users/price/dots/.local/share/wallpapers/Autumn-Leaves.jpg b/users/price/conf/swww-wallpapers/wallpapers/Autumn-Leaves.jpg similarity index 100% rename from users/price/dots/.local/share/wallpapers/Autumn-Leaves.jpg rename to users/price/conf/swww-wallpapers/wallpapers/Autumn-Leaves.jpg diff --git a/users/price/dots/.local/share/wallpapers/Industrial-Shaded.png b/users/price/conf/swww-wallpapers/wallpapers/Industrial-Shaded.png similarity index 100% rename from users/price/dots/.local/share/wallpapers/Industrial-Shaded.png rename to users/price/conf/swww-wallpapers/wallpapers/Industrial-Shaded.png diff --git a/users/price/dots/.local/share/wallpapers/Mountain-Retreat.jpg b/users/price/conf/swww-wallpapers/wallpapers/Mountain-Retreat.jpg similarity index 100% rename from users/price/dots/.local/share/wallpapers/Mountain-Retreat.jpg rename to users/price/conf/swww-wallpapers/wallpapers/Mountain-Retreat.jpg diff --git a/users/price/dots/.local/share/wallpapers/Nebula.jpg b/users/price/conf/swww-wallpapers/wallpapers/Nebula.jpg similarity index 100% rename from users/price/dots/.local/share/wallpapers/Nebula.jpg rename to users/price/conf/swww-wallpapers/wallpapers/Nebula.jpg diff --git a/users/price/dots/.local/share/wallpapers/Space-Mountains.png b/users/price/conf/swww-wallpapers/wallpapers/Space-Mountains.png similarity index 100% rename from users/price/dots/.local/share/wallpapers/Space-Mountains.png rename to users/price/conf/swww-wallpapers/wallpapers/Space-Mountains.png diff --git a/users/price/dots/.local/share/wallpapers/TokyoNight.jpg b/users/price/conf/swww-wallpapers/wallpapers/TokyoNight.jpg similarity index 100% rename from users/price/dots/.local/share/wallpapers/TokyoNight.jpg rename to users/price/conf/swww-wallpapers/wallpapers/TokyoNight.jpg diff --git a/users/price/dots/.local/share/wallpapers/kanagawa-alt.jpg b/users/price/conf/swww-wallpapers/wallpapers/kanagawa-alt.jpg similarity index 100% rename from users/price/dots/.local/share/wallpapers/kanagawa-alt.jpg rename to users/price/conf/swww-wallpapers/wallpapers/kanagawa-alt.jpg diff --git a/users/price/dots/.local/share/wallpapers/kanagawa-min.png b/users/price/conf/swww-wallpapers/wallpapers/kanagawa-min.png similarity index 100% rename from users/price/dots/.local/share/wallpapers/kanagawa-min.png rename to users/price/conf/swww-wallpapers/wallpapers/kanagawa-min.png diff --git a/users/price/home.nix b/users/price/home.nix index 18a25743..f98e561b 100644 --- a/users/price/home.nix +++ b/users/price/home.nix @@ -152,12 +152,7 @@ in ] ++ [ rust-analyzer ]; - file = { - ".local/share/wallpapers" = { - source = ./dots/.local/share/wallpapers; - force = true; - }; - } // softLinkDots ".config"; + file = softLinkDots ".config"; sessionVariables = { _ZL_DATA = "${config.xdg.cacheHome}/zlua"; @@ -483,56 +478,6 @@ in }; }; services = { - swww-daemon = { - Service = - let - cleanup-socket-script = pkgs.writeShellScript "swww-daemon-cleanup-socket" '' - # Remove the existing swww.socket if it exists, avoids some issues with swww-daemon - # startup where swww-daemon claims the address is already in use - if [[ -w "$XDG_RUNTIME_DIR/swww.socket" ]]; then - rm -f $XDG_RUNTIME_DIR/swww.socket || exit 1 - fi - ''; - in - { - RestartSec = 3; - PassEnvironment = [ "XDG_RUNTIME_DIR" ]; - ExecStartPre = "${cleanup-socket-script}"; - ExecStopPost = "${cleanup-socket-script}"; - ExecStart = "${pkgs.swww}/bin/swww-daemon"; - }; - Install.WantedBy = [ "compositor.target" ]; - Unit = { - Description = "Wayland Wallpaper Service"; - PartOf = [ "compositor.target" ]; - After = [ "compositor.target" ]; - }; - }; - swww-wallpapers = { - Service = { - RestartSec = 3; - Type = "oneshot"; - Environment = [ - "SWWW_TRANSITION_FPS=120" - "SWWW_TRANSITION_STEP=30" - "SWWW_TRANSITION_DURATION=0.75" - ]; - ExecStart = - let - wallpaper-dir = "${dotsDir}/.local/share/wallpapers"; - in - [ - "${pkgs.swww}/bin/swww img -t random ${wallpaper-dir}/Nebula.jpg" - "${pkgs.swww}/bin/swww img -t wipe --transition-angle 40 -o eDP-1 ${wallpaper-dir}/Autumn-Leaves.jpg" - ]; - }; - Install.WantedBy = [ "swww-daemon.service" ]; - Unit = { - Description = "Wayland Wallpaper Service"; - PartOf = [ "swww-daemon.service" ]; - After = [ "swww-daemon.service" ]; - }; - }; keyd-application-mapper = { Unit = { Description = "Keyd - Linux Keyboard Remapper";