Skip to content

Commit 9560ea9

Browse files
autorandr: Set wallpaper on display change
1 parent 46c7498 commit 9560ea9

File tree

3 files changed

+41
-8
lines changed

3 files changed

+41
-8
lines changed

configuration/home/autorandr.nix

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ in {
1010
programs.autorandr = {
1111
enable = true;
1212
profiles = {
13-
# Default single-screen setup, with builtin laptop screen as
14-
# primary.
13+
# Default single-display setup, with builtin laptop display as primary.
1514
default = {
1615
fingerprint = { inherit (fingerprints) eDP-1; };
1716
config = {
@@ -23,8 +22,8 @@ in {
2322
};
2423
};
2524
};
26-
# Double-screen setup with HDMI screen as primary and builtin
27-
# laptop screen as secondary.
25+
# Double-display setup with HDMI display as primary and builtin laptop
26+
# display as secondary.
2827
doublescreen = {
2928
fingerprint = { inherit (fingerprints) HDMI-1 eDP-1; };
3029
config = {
@@ -46,6 +45,8 @@ in {
4645
postswitch = lib.optionalAttrs config.services.polybar.enable {
4746
"polybar-restart" =
4847
"${config.services.polybar.package}/bin/polybar-msg cmd restart";
48+
} // lib.optionalAttrs (config.wallpaper.command != null) {
49+
"wallpaper" = config.wallpaper.command;
4950
};
5051
};
5152
};

configuration/home/xsession.nix

+8-4
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,18 @@ let
1616
'';
1717
};
1818
in {
19+
imports = [ ../../modules/home/wallpaper.nix ];
20+
1921
home.packages = [ xmonad ];
2022

2123
xsession = {
2224
enable = true;
23-
initExtra = ''
24-
${pkgs.feh}/bin/feh --no-fehbg --bg-fill --geometry +0+0 ${wallpaper}
25-
'';
26-
2725
windowManager.command = "${xmonad}/bin/xmonad-${targetSystem}";
2826
};
27+
28+
wallpaper = {
29+
enableXSession = true;
30+
command =
31+
"${pkgs.feh}/bin/feh --no-fehbg --bg-fill --geometry +0+0 ${wallpaper}";
32+
};
2933
}

modules/home/wallpaper.nix

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{ config, lib, ... }:
2+
with lib;
3+
let cfg = config.wallpaper;
4+
in {
5+
options.wallpaper = {
6+
enableXSession = mkOption {
7+
type = types.bool;
8+
default = false;
9+
description = ''
10+
Whether to enable setting the wallpaper using X Session.
11+
'';
12+
};
13+
14+
command = mkOption {
15+
type = types.str;
16+
default = null;
17+
description = ''
18+
Command to set wallpaper.
19+
'';
20+
};
21+
};
22+
23+
config = mkIf cfg.enableXSession {
24+
xsession.initExtra = ''
25+
${cfg.command}
26+
'';
27+
};
28+
}

0 commit comments

Comments
 (0)