From 84b58f9453157bfd08625dff386ff73ccbcc4f1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hannes=20K=C3=B6rber?= Date: Mon, 5 Oct 2020 21:55:12 +0200 Subject: [PATCH] Allow per-user environment --- _machines/tb-hak.yml | 5 ++++- bin/dunstctl | 25 +++++++++++++++++++++++++ i3/scripts/i3exit | 4 ++-- i3/scripts/presentation-mode | 4 ++-- zsh/zprofile.j2 | 3 ++- 5 files changed, 35 insertions(+), 6 deletions(-) create mode 100755 bin/dunstctl diff --git a/_machines/tb-hak.yml b/_machines/tb-hak.yml index bb7a843..d4a4b2b 100644 --- a/_machines/tb-hak.yml +++ b/_machines/tb-hak.yml @@ -12,6 +12,8 @@ users: mail: hannes.koerber@tradebyte.com git_gpg_sign: false gpg_agent: false + environment: + MACHINE_HAS_NEXTCLOUD: "false" - name: hannes-private group: tpp vt: 2 @@ -20,6 +22,8 @@ users: gpg_agent: true gpg_keys: master_key: "0xB5C002530C6A2053" + environment: + MACHINE_HAS_NEXTCLOUD: "true" screen: 1: DP-1-1 @@ -45,6 +49,5 @@ workspace: environment: MACHINE_HAS_KEEPASSX: "true" - MACHINE_HAS_NEXTCLOUD: "false" MACHINE_HAS_RESTIC_BACKUP: "true" MACHINE_HAS_SPOTIFY: "true" diff --git a/bin/dunstctl b/bin/dunstctl new file mode 100755 index 0000000..ac58761 --- /dev/null +++ b/bin/dunstctl @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -o nounset + +_logfile="$LOGDIR/dunstctl.log" + +log() { + printf '[%s] %s\n' "$(date -uIseconds)" "$*" >> "$_logfile" +} + +case "$1" in + enable) + log "Enabling dunst" + systemctl --user --no-block kill --signal SIGUSR2 dunst_user + + ;; + disable) + log "Disabling dunst" + systemctl --user --no-block kill --signal SIGUSR1 dunst_user + ;; + *) + >&2 printf 'Unknown command\n' + exit 1 +esac + diff --git a/i3/scripts/i3exit b/i3/scripts/i3exit index ccce0b0..8ab21b9 100755 --- a/i3/scripts/i3exit +++ b/i3/scripts/i3exit @@ -47,11 +47,11 @@ reset_screen() { lock_and_screen_off() { lock & _pid=$! - systemctl --user --no-block kill --signal SIGUSR1 dunst_user + dunstctl disable screen_off xset dpms 0 0 5 wait $_pid - systemctl --user --no-block kill --signal SIGUSR2 dunst_user + dunstctl enable reset_screen } diff --git a/i3/scripts/presentation-mode b/i3/scripts/presentation-mode index 5aad032..f9ccd8a 100755 --- a/i3/scripts/presentation-mode +++ b/i3/scripts/presentation-mode @@ -9,14 +9,14 @@ is_on() { switch_on() { touch "${_status_file}" - systemctl --user --no-block kill --signal SIGUSR1 dunst_user + dunstctl disable & systemctl --user --no-block stop redshift_user systemctl --user --no-block stop spotify } switch_off() { rm -f "${_status_file}" - systemctl --user --no-block kill --signal SIGUSR2 dunst_user + dunstctl enable & "$_autostart" redshift_user spotify } diff --git a/zsh/zprofile.j2 b/zsh/zprofile.j2 index 3d6e92b..4159a93 100644 --- a/zsh/zprofile.j2 +++ b/zsh/zprofile.j2 @@ -47,7 +47,8 @@ export ACPI_LID_NAME=LID umask 0022 -{% for k, v in machine.environment.items() %} +{% set env = machine.environment | combine(user.environment) %} +{% for k, v in env.items() %} export {{ k }}="{{ v }}" {% endfor %}