diff --git a/extra-packages/default.nix b/extra-packages/default.nix index c554bd2..03ea5f2 100644 --- a/extra-packages/default.nix +++ b/extra-packages/default.nix @@ -2,7 +2,6 @@ pkgs: { dracula-gtk = pkgs.callPackage ./dracula-gtk { }; misc-scripts = pkgs.callPackage ./scripts/misc { }; getpaper = pkgs.callPackage ./scripts/getpaper { }; - setpaper = pkgs.callPackage ./scripts/setpaper { }; youtube = pkgs.callPackage ./scripts/youtube { }; rofi-bluetooth = pkgs.callPackage ./rofi-bluetooth { }; smc-manjari = pkgs.callPackage ./smc-manjari { }; diff --git a/extra-packages/scripts/getpaper/getpaper.sh b/extra-packages/scripts/getpaper/getpaper.sh index 4809c6d..8574b65 100755 --- a/extra-packages/scripts/getpaper/getpaper.sh +++ b/extra-packages/scripts/getpaper/getpaper.sh @@ -14,12 +14,12 @@ CURL_BASE_CMD="curl --silent ${API_KEY_HEADER}" CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}" CONFIG_FILE="${CONFIG_DIR}/wallpaper_config.json" if [ ! -e "${CONFIG_FILE}" ]; then - echo '{"tags":null,"categories":"100","purity":"100", "sorting":"random", "size":null, "ratios":null, "colors":null, "ai_filter":1, "range": "1M", "dir":"~/Pictures/Wallpapers"}' | jq > "${CONFIG_FILE}" + echo '{"tags":null,"categories":"100","purity":"100", "sorting":"random", "size":null, "ratios":null, "colors":null, "ai_filter":1, "range": "1M"}' | jq > "${CONFIG_FILE}" fi CONFIG="$(cat "${CONFIG_FILE}")" -DIR="$(echo "${CONFIG}" | jq -r '.dir // empty')" +DIR="$1" if [ -z "${DIR}" ]; then DIR="${XDG_PICTURES_DIR:-${HOME}/Pictures}/Wallpapers" echo "Warning: wallpaper directory not set. using fallback directory ${DIR}" >&2 diff --git a/extra-packages/scripts/setpaper/default.nix b/extra-packages/scripts/setpaper/default.nix deleted file mode 100644 index 732fd6c..0000000 --- a/extra-packages/scripts/setpaper/default.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ lib -, stdenvNoCC -, makeWrapper -, envsubst -, jq -, swww -, -}: -stdenvNoCC.mkDerivation { - pname = "setpaper"; - version = "0.1"; - src = ./.; - - nativeBuildInputs = [ makeWrapper ]; - - installPhase = '' - runHook preInstall - - mkdir -p $out/bin - cp setpaper.sh $out/bin/setpaper - chmod +x $out/bin/setpaper - - runHook postInstall - ''; - - postInstall = '' - wrapProgram $out/bin/setpaper --prefix PATH : ${lib.makeBinPath [envsubst jq swww]} - ''; -} diff --git a/extra-packages/scripts/setpaper/setpaper.sh b/extra-packages/scripts/setpaper/setpaper.sh deleted file mode 100755 index c73da79..0000000 --- a/extra-packages/scripts/setpaper/setpaper.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh - -set -eu - -CONFIG_DIR="${XDG_CONFIG_HOME:-${HOME}/.config}" -CONFIG_FILE="${CONFIG_DIR}/wallpaper_config.json" -if [ ! -e "${CONFIG_FILE}" ]; then - echo "Wallpaper config file: ${CONFIG_FILE} missing." >&2 - exit 1 -fi - -CONFIG="$(cat "${CONFIG_FILE}")" - -DIR="$(echo "${CONFIG}" | jq -r '.dir // empty')" -if [ -z "${DIR}" ]; then - DIR="${XDG_PICTURES_DIR:-${HOME}/Pictures}/Wallpapers" - echo "Warning: wallpaper directory not set. using fallback directory ${DIR}" >&2 -fi -DIR="$(echo "${DIR}" | envsubst)" -mkdir -p "${DIR}" - -random_paper() { - if [ -d "$DIR" ] ; then - find -L "${DIR}"/ -type f -regextype egrep -regex ".*\.(jpe?g|png)$" | shuf -n1 --random-source=/dev/urandom - else - echo "${DIR} is not a directory" >&2 - exit 1 - fi -} - -swww img \ - --transition-type random \ - --transition-step 2 \ - --transition-duration 2 \ - --transition-bezier "0.1,0.1,1.0,1.0" \ - "$(random_paper)" - diff --git a/home/wm/addon/default.nix b/home/wm/addon/default.nix index 424ed5d..8a71085 100644 --- a/home/wm/addon/default.nix +++ b/home/wm/addon/default.nix @@ -7,7 +7,7 @@ ./hyprlock.nix ./hypridle.nix ./kanshi.nix - ./swww.nix + ./wpaperd.nix ./wallpaper.nix ]; } diff --git a/home/wm/addon/swww.nix b/home/wm/addon/swww.nix deleted file mode 100644 index 2a42750..0000000 --- a/home/wm/addon/swww.nix +++ /dev/null @@ -1,18 +0,0 @@ -{ pkgs, ... }: { - systemd.user.services.swww-daemon = { - Unit = { - Description = "Solution for Wayland Wallpaper Woes"; - Documentation = "https://github.com/LGFae/swww"; - PartOf = [ "graphical-session.target" ]; - After = [ "graphical-session-pre.target" ]; - }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - Service = { - ExecStart = "${pkgs.swww}/bin/swww-daemon --no-cache"; - Restart = "on-failure"; - KillMode = "mixed"; - }; - }; -} diff --git a/home/wm/addon/wallpaper.nix b/home/wm/addon/wallpaper.nix index 9e34186..4a0b1d1 100644 --- a/home/wm/addon/wallpaper.nix +++ b/home/wm/addon/wallpaper.nix @@ -1,6 +1,5 @@ -{ extra-packages, ... }: +{ config, extra-packages, ... }: let - change-wallpaper = "${extra-packages.setpaper}/bin/setpaper"; wallpaper-downloader = "${extra-packages.getpaper}/bin/getpaper"; in { @@ -15,23 +14,8 @@ in }; Service = { Type = "oneshot"; - ExecStart = "${wallpaper-downloader}"; - }; - - }; - setpaper = { - Unit = { - Description = "Change Wallpaper"; - PartOf = [ "graphical-session.target" ]; - After = [ "graphical-session-pre.target" ]; - Wants = "swww-daemon.service"; - }; - Install = { - WantedBy = [ "graphical-session.target" ]; - }; - Service = { - Type = "oneshot"; - ExecStart = "${change-wallpaper}"; + Restart = "on-failure"; + ExecStart = ''${wallpaper-downloader} "${config.xdg.userDirs.pictures}/Wallpapers"''; }; }; }; @@ -48,18 +32,6 @@ in Persistent = true; }; }; - setpaper = { - Unit = { - Description = "Change Wallpaper"; - }; - Install = { - WantedBy = [ "default.target" ]; - }; - Timer = { - OnStartupSec = "10min"; - OnUnitActiveSec = "10min"; - }; - }; }; }; } diff --git a/home/wm/addon/wpaperd.nix b/home/wm/addon/wpaperd.nix new file mode 100644 index 0000000..f0c0af7 --- /dev/null +++ b/home/wm/addon/wpaperd.nix @@ -0,0 +1,29 @@ +{ config, pkgs, ... }: { + programs.wpaperd = { + enable = true; + settings = { + default = { + duration = "10m"; + mode = "stretch"; + sorting = "random"; + path = "${config.xdg.userDirs.pictures}/Wallpapers"; + }; + }; + }; + systemd.user.services.wpaperd = { + Unit = { + Description = "Modern wallpaper daemon for Wayland"; + Documentation = "https://github.com/danyspin97/wpaperd"; + PartOf = [ "graphical-session.target" ]; + After = [ "graphical-session-pre.target" ]; + }; + Install = { + WantedBy = [ "graphical-session.target" ]; + }; + Service = { + ExecStart = "${pkgs.wpaperd}/bin/wpaperd"; + Restart = "on-failure"; + KillMode = "mixed"; + }; + }; +} diff --git a/home/wm/hyprland/default.nix b/home/wm/hyprland/default.nix index f9a9701..ad9a1ab 100644 --- a/home/wm/hyprland/default.nix +++ b/home/wm/hyprland/default.nix @@ -15,6 +15,7 @@ let rofi = "${config.programs.rofi.package}/bin/rofi"; swaync-client = "${pkgs.swaynotificationcenter}/bin/swaync-client"; tmux = "${config.programs.tmux.package}/bin/tmux"; + wpaperctl = "${config.programs.wpaperd.package}/bin/wpaperctl"; wpctl = "${pkgs.wireplumber}/bin/wpctl"; yazi = "${pkgs.yazi}/bin/yazi"; @@ -177,7 +178,7 @@ in "SUPER_SHIFT,b, exec, ${extra-packages.rofi-bluetooth}/bin/rofi-bluetooth" "SUPER,escape, exec, ${loginctl} lock-session" - "SUPER_SHIFT,W, exec, systemctl --user start setpaper.service" + "SUPER_SHIFT,W, exec, ${wpaperctl} next" "SUPER,1, workspace, 1" "SUPER,2, workspace, 2"