summaryrefslogtreecommitdiffstats
path: root/lass/2configs
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-04-04 18:19:51 +0200
committerlassulus <lassulus@lassul.us>2022-04-04 18:32:44 +0200
commit4ebbfbebf46dc5cd84ed5c51162c08fd2ecf0542 (patch)
tree681dfd7d1341e11c93e9e04b82244b80273f9924 /lass/2configs
parentb9e0a7ec71e0318a992ff2b275a6aaee3cef63bd (diff)
l: add themes.nix
Diffstat (limited to 'lass/2configs')
-rw-r--r--lass/2configs/baseX.nix1
-rw-r--r--lass/2configs/themes.nix46
2 files changed, 47 insertions, 0 deletions
diff --git a/lass/2configs/baseX.nix b/lass/2configs/baseX.nix
index 249410371..cbe592d52 100644
--- a/lass/2configs/baseX.nix
+++ b/lass/2configs/baseX.nix
@@ -13,6 +13,7 @@ in {
./pipewire.nix
./tmux.nix
./xmonad.nix
+ ./themes.nix
{
krebs.per-user.lass.packages = [
pkgs.sshuttle
diff --git a/lass/2configs/themes.nix b/lass/2configs/themes.nix
new file mode 100644
index 000000000..dd98b2ef2
--- /dev/null
+++ b/lass/2configs/themes.nix
@@ -0,0 +1,46 @@
+{ config, lib, pkgs, ... }: let
+
+ switch-theme = pkgs.writers.writeDashBin "switch-theme" ''
+ if test -e "/etc/themes/$1"; then
+ ${pkgs.rsync}/bin/rsync --chown=lass:users -a --delete "/etc/themes/$1/" /var/theme/config/
+ echo "$1" > /var/theme/current_theme
+ chown lass:users /var/theme/current_theme
+ ${pkgs.procps}/bin/pkill -HUP xsettingsd
+
+ else
+ echo "theme $1 not found"
+ fi
+ '';
+
+in {
+ systemd.services.xsettingsd = {
+ wantedBy = [ "multi-user.target" ];
+ environment.DISPLAY = ":0";
+ serviceConfig = {
+ ExecStart = "${pkgs.xsettingsd}/bin/xsettingsd -c /var/theme/config/xsettings.conf";
+ User = "lass";
+ };
+ };
+ systemd.tmpfiles.rules = [
+ "d /var/theme/ 755 lass users"
+ ];
+ environment.systemPackages = [
+ switch-theme
+ ];
+ environment.etc = {
+ "themes/light/xsettings.conf".text = ''
+ Net/ThemeName "Adwaita"
+ '';
+ "themes/dark/xsettings.conf".text = ''
+ Net/ThemeName "Adwaita-dark"
+ '';
+ };
+ system.activationScripts.theme.text = ''
+ if test -e /var/theme/current_theme; then
+ ${switch-theme}/bin/switch-theme "$(cat /var/theme/current_theme)" ||
+ ${switch-theme}/bin/switch-theme dark
+ else
+ ${switch-theme}/bin/switch-theme dark
+ fi
+ '';
+}