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
|
@ -27,6 +27,8 @@
|
|||
{
|
||||
nixosModules.extra-modules = import ./modules;
|
||||
nixosModules.default = self.nixosModules.extra-modules;
|
||||
homeManagerModules.extra-modules = import ./hm-modules;
|
||||
homeManagerModules.default = self.homeManagerModules.extra-modules;
|
||||
}
|
||||
// flake-utils.lib.eachDefaultSystem (system: rec {
|
||||
pkgs = import nixpkgs {
|
||||
|
|
6
hm-modules/default.nix
Normal file
6
hm-modules/default.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./i3.nix
|
||||
./wallpapers.nix
|
||||
];
|
||||
}
|
31
hm-modules/i3.nix
Normal file
31
hm-modules/i3.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
lib,
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: {
|
||||
options.xsession.windowManager.i3.enableSystemdTarget = lib.mkEnableOption "i3 autostarting the systemd graphical user targets";
|
||||
config = let
|
||||
cfg = config.xsession.windowManager.i3.enableSystemdTarget;
|
||||
in
|
||||
lib.mkIf cfg {
|
||||
systemd.user = {
|
||||
targets.i3-session = {
|
||||
Unit = {
|
||||
Description = "i3 session";
|
||||
Documentation = ["man:systemd.special(7)"];
|
||||
BindsTo = ["graphical-session.target"];
|
||||
Wants = ["graphical-session-pre.target"];
|
||||
After = ["graphical-session-pre.target"];
|
||||
};
|
||||
};
|
||||
};
|
||||
xsession.windowManager.i3.config.startup = lib.mkAfter [
|
||||
{
|
||||
command = "${pkgs.systemd}/bin/systemctl --user start i3-session.target";
|
||||
always = false;
|
||||
notification = false;
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
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