From b0bc54840dc0bf74db93e2ea3abe7fee1b2cac06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Sun, 5 May 2024 15:29:55 +0200 Subject: [PATCH] Add service for light theme --- bin/switch-color-mode | 38 ++++++++++++++++++++++++++++++ services/color-theme-light.service | 9 +++++++ user.yml | 15 ++++++++++++ 3 files changed, 62 insertions(+) create mode 100755 bin/switch-color-mode create mode 100644 services/color-theme-light.service diff --git a/bin/switch-color-mode b/bin/switch-color-mode new file mode 100755 index 0000000..30ccf9e --- /dev/null +++ b/bin/switch-color-mode @@ -0,0 +1,38 @@ +#!/usr/bin/env bash + +set -o nounset + +set -x + +apply() { + local mode="${1}" + + case "${mode}" in + dark) + theme=monokai + ;; + light) + theme=github_light + ;; + esac + + sed -i "s#themes/.*\.toml#themes/${theme}.toml#" "${XDG_CONFIG_HOME}/alacritty/config.toml" + + sed -i "s#theme = .*\$#theme = \"${theme}\"#" "${XDG_CONFIG_HOME}/helix/config.toml" + + pkill -SIGUSR1 helix + + printf '%s' "${mode}" > "${XDG_RUNTIME_DIR}"/color_mode +} + +case "${1:-}" in + dark) + apply dark + ;; + light) + apply light + ;; + *) + exit 1 + ;; +esac diff --git a/services/color-theme-light.service b/services/color-theme-light.service new file mode 100644 index 0000000..362aab3 --- /dev/null +++ b/services/color-theme-light.service @@ -0,0 +1,9 @@ +[Unit] +After=windowmanager.target + +[Service] +Type=oneshot +ExecStart=/usr/bin/env switch-color-mode light +ExecStop=/usr/bin/env switch-color-mode dark +RemainAfterExit=true +PassEnvironment=DISPLAY diff --git a/user.yml b/user.yml index f8e4142..6a7eb62 100644 --- a/user.yml +++ b/user.yml @@ -343,6 +343,21 @@ loop_control: label: "{{ item.profile_path }}" +- name: handle user units + tags: + - user:units + block: + - name: link user service files + file: + state: link + force: true + follow: false + path: "/home/{{ user.name }}/.config/systemd/user/{{ item | basename }}" + src: "{{ item }}" + owner: "{{ user.name }}" + group: "{{ user.name }}" + with_fileglob: /var/lib/dotfiles/services/* + - name: handle autostart units tags: - user:autostart