replace swww with wpaperd

This commit is contained in:
Adithya 2024-06-01 01:45:08 +05:30
parent ac78efc76b
commit 1aaf49e651
Signed by: adtya
GPG key ID: B8857BFBA2C47B9C
9 changed files with 37 additions and 120 deletions

View file

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

View file

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

View file

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

View file

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

View file

@ -7,7 +7,7 @@
./hyprlock.nix
./hypridle.nix
./kanshi.nix
./swww.nix
./wpaperd.nix
./wallpaper.nix
];
}

View file

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

View file

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

29
home/wm/addon/wpaperd.nix Normal file
View file

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

View file

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