Skip to content

Commit

Permalink
home/services/system/theme: init
Browse files Browse the repository at this point in the history
Automatically switch between dark/light themes based on time of day.

Potential TODO:
- add more apps to switch
- automatically adjust the time of changes based on location
  - integrate with geoclue?
  • Loading branch information
fufexan committed Sep 5, 2024
1 parent cd34753 commit a68b6dd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions home/profiles/io/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
../../services/system/power-monitor.nix
../../services/system/syncthing.nix
../../services/system/tailray.nix
../../services/system/theme.nix
../../services/system/udiskie.nix

# wayland-specific
Expand Down
42 changes: 42 additions & 0 deletions home/services/system/theme.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
lib,
pkgs,
...
}: {
systemd.user.timers = {
theme-toggle-dark = {
Unit.Description = "Toggle dark theme";
Timer.OnCalendar = [
"*-*-* 18:00:00"
];
Install.WantedBy = ["graphical-session.target"];
};

theme-toggle-light = {
Unit.Description = "Toggle light theme";
Timer.OnCalendar = [
"*-*-* 06:00:00"
];
Install.WantedBy = ["graphical-session.target"];
};
};

systemd.user.services = {
theme-toggle-dark = {
Unit.Description = "Toggle dark theme";
Service = {
Type = "simple";
ExecStart = "${lib.getExe pkgs.dconf} write /org/gnome/desktop/interface/color-scheme \"'prefer-dark'\"";
TimeoutStopSec = 5;
};
};
theme-toggle-light = {
Unit.Description = "Toggle light theme";
Service = {
Type = "simple";
ExecStart = "${lib.getExe pkgs.dconf} write /org/gnome/desktop/interface/color-scheme \"'prefer-light'\"";
TimeoutStopSec = 5;
};
};
};
}

0 comments on commit a68b6dd

Please sign in to comment.