From 07a8338e7799e4427f683dd5fc89286178622440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Mon, 6 May 2024 10:19:17 +0200 Subject: [PATCH] Use conflicting systemd units for color mode --- autostart/autostart.target.j2 | 2 +- i3/i3status-rust/config.toml.j2 | 2 +- services/color-theme-dark.service | 9 +++++++++ services/color-theme-light.service | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 services/color-theme-dark.service diff --git a/autostart/autostart.target.j2 b/autostart/autostart.target.j2 index 298b9f6..17b47dc 100644 --- a/autostart/autostart.target.j2 +++ b/autostart/autostart.target.j2 @@ -30,4 +30,4 @@ Wants=touchpad.service Wants=xresources.service Wants=yubikey-touch-detector.service Wants=kdeconnect.service - +Wants=color-theme-dark.service diff --git a/i3/i3status-rust/config.toml.j2 b/i3/i3status-rust/config.toml.j2 index f93f579..69247ab 100644 --- a/i3/i3status-rust/config.toml.j2 +++ b/i3/i3status-rust/config.toml.j2 @@ -75,7 +75,7 @@ command_state = "[[ $($HOME/.i3/scripts/presentation-mode status) == on ]] && ec block = "toggle" format = "  $icon " command_on = "systemctl --user start color-theme-light" -command_off = "systemctl --user stop color-theme-light" +command_off = "systemctl --user start color-theme-dark" command_state = "[[ $(systemctl --user is-active color-theme-light) == active ]] && echo active" [[block]] diff --git a/services/color-theme-dark.service b/services/color-theme-dark.service new file mode 100644 index 0000000..b6855c4 --- /dev/null +++ b/services/color-theme-dark.service @@ -0,0 +1,9 @@ +[Unit] +After=windowmanager.target +Conflicts=color-theme-light.service + +[Service] +Type=oneshot +ExecStart=/usr/bin/env switch-color-mode dark +RemainAfterExit=true +PassEnvironment=DISPLAY diff --git a/services/color-theme-light.service b/services/color-theme-light.service index 362aab3..1581f4c 100644 --- a/services/color-theme-light.service +++ b/services/color-theme-light.service @@ -1,9 +1,9 @@ [Unit] After=windowmanager.target +Conflicts=color-theme-dark.service [Service] Type=oneshot ExecStart=/usr/bin/env switch-color-mode light -ExecStop=/usr/bin/env switch-color-mode dark RemainAfterExit=true PassEnvironment=DISPLAY