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