Commit 509137bba542
Changed files (2)
home
common
desktop
sway
services
home/common/desktop/sway/swayidle.nix
@@ -23,10 +23,12 @@ let
fi
'';
niriPowerOnScript = pkgs.writeShellScript "niri-power-on-monitors" ''
- edp=$(${pkgs.niri}/bin/niri msg outputs | ${pkgs.gnugrep}/bin/grep -oP 'eDP-\d+')
- if [ -n "$edp" ]; then
- ${pkgs.niri}/bin/niri msg output "$edp" on
- fi
+ # Re-enable all outputs first, then let kanshi apply the correct profile
+ # (e.g. disabling eDP when docked)
+ for output in $(${pkgs.niri}/bin/niri msg outputs | ${pkgs.gnugrep}/bin/grep '^Output' | ${pkgs.gnugrep}/bin/grep -oP '\(\K[^)]+(?=\))'); do
+ ${pkgs.niri}/bin/niri msg output "$output" on
+ done
+ ${pkgs.systemd}/bin/systemctl --user restart kanshi
'';
powerOnCmd =
if desktop == "niri" then
home/common/services/color-scheme-timer.nix
@@ -66,7 +66,6 @@ in
};
Timer = {
OnCalendar = cfg.lightTime;
- Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
@@ -79,11 +78,38 @@ in
};
Timer = {
OnCalendar = cfg.darkTime;
- Persistent = true;
};
Install = {
WantedBy = [ "timers.target" ];
};
};
+
+ # Boot-time check: set correct scheme based on current time
+ systemd.user.services.color-scheme-init = {
+ Unit = {
+ Description = "Set color scheme based on current time";
+ After = [ "graphical-session.target" ];
+ };
+ Service = {
+ Type = "oneshot";
+ ExecStart =
+ let
+ initScript = pkgs.writeShellScript "color-scheme-init" ''
+ hour=$(date +%H)
+ light_hour=$(echo ${cfg.lightTime} | cut -d: -f1)
+ dark_hour=$(echo ${cfg.darkTime} | cut -d: -f1)
+ if [ "$hour" -ge "$light_hour" ] && [ "$hour" -lt "$dark_hour" ]; then
+ ${pkgs.toggle-color-scheme}/bin/toggle-color-scheme light
+ else
+ ${pkgs.toggle-color-scheme}/bin/toggle-color-scheme dark
+ fi
+ '';
+ in
+ "${initScript}";
+ };
+ Install = {
+ WantedBy = [ "graphical-session.target" ];
+ };
+ };
};
}