feat: add systemd units to automatically set system colorscheme

This commit is contained in:
Youwen Wu 2025-02-02 20:27:44 -08:00
parent 24aa4ea3f6
commit 4930320599
Signed by: youwen5
GPG key ID: 865658ED1FE61EC3

View file

@ -11,12 +11,91 @@
../users/youwen/nixos.nix ../users/youwen/nixos.nix
]; ];
# systemd.services.suntheme = {
# wantedBy = [ "default.target" ];
# after = [
# "network.target"
# "atd.service"
# ];
# wants = [ "atd.service" ];
# description = "Run suntheme to set daemons";
# serviceConfig = {
# Type = "oneshot";
# RemainAfterExit = "yes";
# ExecStart = ''${inputs.suntheme.packages.${pkgs.system}.default}/bin/suntheme'';
# };
# };
#
# environment.systemPackages = [
# (pkgs.writeShellScriptBin "light.sh" ''
# /nix/var/nix/profiles/system/specialisation/dawn/bin/switch-to-configuration test
# '')
# (pkgs.writeShellScriptBin "dark.sh" ''
# /nix/var/nix/profiles/nix/system/bin/switch-to-configuration test
# '')
# ];
systemd.services = {
colorscheme-dawn = {
description = "Set system colorscheme to dawn";
unitConfig = {
ConditionPathExists = [
"/etc/polarity"
"/nix/var/nix/profiles/system/specialisation/dawn/bin/switch-to-configuration"
];
};
serviceConfig = {
Type = "oneshot";
User = "root";
PermissionsStartOnly = true;
ExecStart = "/nix/var/nix/profiles/system/specialisation/dawn/bin/switch-to-configuration test";
};
};
colorscheme-dusk = {
description = "Set system colorscheme to dusk";
unitConfig = {
ConditionPathExists = [
"/etc/polarity"
"/nix/var/nix/profiles/system/bin/switch-to-configuration"
];
};
serviceConfig = {
Type = "oneshot";
User = "root";
PermissionsStartOnly = true;
ExecStart = "/nix/var/nix/profiles/system/bin/switch-to-configuration test";
};
};
};
systemd.timers = {
colorscheme-dawn = {
wantedBy = [ "timers.target" ];
description = "Schedule system colorscheme change to dawn at 7 AM";
timerConfig = {
OnCalendar = "*-*-* 07:00:00";
Persistent = true;
Unit = "colorscheme-dawn.service";
};
};
colorscheme-dusk = {
wantedBy = [ "timers.target" ];
description = "Schedule system colorscheme change to dusk at 7 PM";
timerConfig = {
OnCalendar = "*-*-* 19:00:00";
Persistent = true;
Unit = "colorscheme-dusk.service";
};
};
};
nix.extraOptions = '' nix.extraOptions = ''
!include ${config.age.secrets.nix_config_github_pat.path} !include ${config.age.secrets.nix_config_github_pat.path}
''; '';
nix.settings.trusted-users = [ "youwen" ]; nix.settings.trusted-users = [ "youwen" ];
services.atd.enable = true;
liminalOS.theming = { liminalOS.theming = {
# wallpaper = "${inputs.wallpapers}/aesthetic/afterglow_city_skyline_at_night.png"; # wallpaper = "${inputs.wallpapers}/aesthetic/afterglow_city_skyline_at_night.png";
# wallpaper = "${ # wallpaper = "${
@ -40,9 +119,12 @@
polarity = lib.mkDefault "dark"; polarity = lib.mkDefault "dark";
}; };
environment.etc.polarity.text = "dusk";
specialisation = { specialisation = {
dawn.configuration = { dawn.configuration = {
environment.etc."specialisation".text = "dawn"; environment.etc."specialisation".text = "dawn";
environment.etc.polarity.text = "dawn";
liminalOS.theming = { liminalOS.theming = {
wallpaper = pkgs.fetchurl { wallpaper = pkgs.fetchurl {
url = "https://w.wallhaven.cc/full/kx/wallhaven-kxoqx6.jpg"; url = "https://w.wallhaven.cc/full/kx/wallhaven-kxoqx6.jpg";
@ -53,8 +135,5 @@
polarity = "light"; polarity = "light";
}; };
}; };
dusk.configuration = {
environment.etc."specialisation".text = "dusk";
};
}; };
} }