From 3c2800b7d4a03dda4557275d1680d6acb25888b3 Mon Sep 17 00:00:00 2001 From: Stefan Ellmauthaler Date: Mon, 14 Aug 2023 15:29:26 +0200 Subject: [PATCH] Add background image service (based on feh calls) --- users/ellmau/autorandr.nix | 1 + users/ellmau/background-x.nix | 34 ++++++++++++++++++++++++++++++++++ users/ellmau/default.nix | 1 + 3 files changed, 36 insertions(+) create mode 100644 users/ellmau/background-x.nix diff --git a/users/ellmau/autorandr.nix b/users/ellmau/autorandr.nix index efe7957..1ce3c29 100644 --- a/users/ellmau/autorandr.nix +++ b/users/ellmau/autorandr.nix @@ -126,6 +126,7 @@ with lib; { }; hooks.postswitch = { "polybar" = "systemctl --user restart polybar.service"; + change-bg = "/home/ellmau/.fehbg"; }; }; }; diff --git a/users/ellmau/background-x.nix b/users/ellmau/background-x.nix new file mode 100644 index 0000000..a0cf970 --- /dev/null +++ b/users/ellmau/background-x.nix @@ -0,0 +1,34 @@ +{ + config, + pkgs, + lib, + nixosConfig, + ... +}: +with lib; { + config = let + cfg = nixosConfig.elss.graphical.xserver; + fehArgs = "--bg-fill --no-fehbg"; + in + mkIf cfg.enable { + systemd.user = { + services = { + desktop-background = { + Unit = { + Description = "Set desktop background"; + Documentation = ["man:feh(1)"]; + After = ["graphical-session-pre.target"]; + ParOf = ["graphical-session.target"]; + }; + + Service = { + type = "oneshot"; + ExecStart = "${pkgs.feh}/bin/feh ${fehArgs} ${config.xdg.configHome}/background.png"; + }; + + Install = {WantedBy = ["graphical-session.target"];}; + }; + }; + }; + }; +} diff --git a/users/ellmau/default.nix b/users/ellmau/default.nix index 59a327b..8f3349b 100644 --- a/users/ellmau/default.nix +++ b/users/ellmau/default.nix @@ -24,6 +24,7 @@ ./waybar.nix ./graphical.nix + ./background-x.nix ]; services = { gnome-keyring = {