update packages + some tweaks
This commit is contained in:
parent
527378ad95
commit
edfb60dd12
26 changed files with 304 additions and 319 deletions
|
|
@ -1,88 +0,0 @@
|
|||
{ lib, config, inputs, system, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
cfg = config.modules.desktop.swww;
|
||||
|
||||
# TODO: this whole thing is a little silly, but i cant find a better way to ref it in the scripts
|
||||
# maybe we can reference the config in the scripts? in a let of course :)
|
||||
wallpapersFolder = "${pkgs.my.wallpapers}/share/backgrounds";
|
||||
lastWallpaper = "$XDG_DATA_HOME/swww-last-wallpaper";
|
||||
lastWallpaperSym = "$XDG_DATA_HOME/swww-last-wallpaper-sym";
|
||||
in {
|
||||
options.modules.desktop.swww = {
|
||||
enable = mkEnableOption "Enable swww, a Solution to your Wayland Wallpaper Woes";
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.swww;
|
||||
example = "pkgs.swww";
|
||||
};
|
||||
wallpapersFolder = mkOption {
|
||||
type = types.str;
|
||||
default = wallpapersFolder;
|
||||
example = "$XDG_PICTURES_DIR/wallpapers";
|
||||
};
|
||||
lastWallpaper = mkOption {
|
||||
type = types.str;
|
||||
default = lastWallpaper;
|
||||
example = "$XDG_DATA_HOME/swww-last-wallpaper";
|
||||
};
|
||||
lastWallpaperSym = mkOption {
|
||||
type = types.str;
|
||||
default = lastWallpaperSym;
|
||||
example = "$XDG_DATA_HOME/swww-last-wallpaper-sym";
|
||||
};
|
||||
setScript = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.writeShellScript "swww-set" ''
|
||||
set -euo pipefail
|
||||
|
||||
if [ ! -f "${lastWallpaper}" ]; then
|
||||
echo "$(ls ${wallpapersFolder} | shuf -n 1)" > "${lastWallpaper}"
|
||||
fi
|
||||
|
||||
ln -sf "${wallpapersFolder}/$(cat ${lastWallpaper})" "${lastWallpaperSym}" # in case the hash of the pkg changes
|
||||
${lib.getExe cfg.package} img "${wallpapersFolder}/$(cat ${lastWallpaper})" --transition-type none
|
||||
'';
|
||||
};
|
||||
swapScript = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.writeShellScript "swww-swap" ''
|
||||
set -euo pipefail
|
||||
|
||||
file=$(ls ${wallpapersFolder} | ${lib.getExe config.modules.desktop.rofi.package} -dmenu -sep '\n' -i -p "select a wallpaper")
|
||||
wallpaper="${wallpapersFolder}/$file"
|
||||
|
||||
[ ! -f "$wallpaper" ] && exit 1
|
||||
|
||||
${lib.getExe cfg.package} img "$wallpaper" --transition-type grow --transition-fps 60 --transition-pos 1.0,1.0 --transition-duration 1.5
|
||||
|
||||
ln -sf "$wallpaper" "${lastWallpaperSym}"
|
||||
echo "$file" > "${lastWallpaper}"
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
hm.home.packages = [ cfg.package ];
|
||||
hm.systemd.user.services.swww = {
|
||||
Unit = {
|
||||
Description = "swww, a Solution to your Wayland Wallpaper Woes";
|
||||
After = [ "graphical-session-pre.target" ];
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
Type = "simple";
|
||||
ExecStart = "${cfg.package}/bin/swww-daemon --no-cache";
|
||||
ExecStartPost = "${cfg.setScript}";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue