feat: added i3 systemdTarget
feat: added xorg wallpaper module
This commit is contained in:
parent
f4a871a401
commit
bc948ad1ab
4 changed files with 99 additions and 0 deletions
60
hm-modules/wallpapers.nix
Normal file
60
hm-modules/wallpapers.nix
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
options.xsession.wallpapers = {
|
||||
enable = lib.mkEnableOption "automatically refreshing randomly selected wallpapers";
|
||||
folder = lib.mkOption {
|
||||
description = "The folder from which the wallpapers are selected. Relative to home directory";
|
||||
type = lib.types.str;
|
||||
default = ".local/share/wallpapers";
|
||||
};
|
||||
refreshInterval = lib.mkOption {
|
||||
description = "How often new wallpapers are drawn. Used as a Systemd timer interval.";
|
||||
type = lib.types.str;
|
||||
default = "3 min";
|
||||
};
|
||||
};
|
||||
config = let
|
||||
cfg = config.xsession.wallpapers;
|
||||
exe =
|
||||
pkgs.writeShellScript "set-wallpaper"
|
||||
''
|
||||
${pkgs.feh}/bin/feh --no-fehbg --bg-fill --randomize \
|
||||
$( ${pkgs.findutils}/bin/find ${config.home.homeDirectory}/${cfg.folder} \( -iname "*.png" -or -iname "*.jpg" \) )
|
||||
'';
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
systemd.user = {
|
||||
timers = {
|
||||
set-wallpaper = {
|
||||
Unit = {
|
||||
Description = "Set a random wallpaper every 3 minutes";
|
||||
};
|
||||
Timer = {
|
||||
OnUnitActiveSec = cfg.refreshInterval;
|
||||
};
|
||||
Install.WantedBy = [
|
||||
"timers.target"
|
||||
];
|
||||
};
|
||||
};
|
||||
services = {
|
||||
set-wallpaper = {
|
||||
Unit = {
|
||||
Description = "Set a random wallpaper on all X displays";
|
||||
};
|
||||
Service = {
|
||||
Type = "oneshot";
|
||||
ExecStart =
|
||||
exe;
|
||||
};
|
||||
Install.WantedBy = ["graphical-session.target"];
|
||||
};
|
||||
};
|
||||
};
|
||||
home.persistence."/state".directories = [cfg.folder];
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue