From: Maximilian Friedersdorff Date: Tue, 4 Jun 2019 10:39:18 +0000 (+0100) Subject: Manage lock and conky scripts X-Git-Url: https://git.friedersdorff.com/?a=commitdiff_plain;h=31e13a4bca72c4cf40590ebd1331e635a6192e40;p=max%2Fsaltfiles.git Manage lock and conky scripts --- diff --git a/states/local/bin.sls b/states/local/bin.sls new file mode 100644 index 0000000..1cd44f1 --- /dev/null +++ b/states/local/bin.sls @@ -0,0 +1,8 @@ +{% set local_bin = grains['homedir'] + '/.local/bin' %} + +{{ local_bin }}: + file.directory: + - user: {{ grains['user'] }} + - group: {{ grains['user'] }} + - mode: 750 + - makedirs: True diff --git a/states/sway/files/conky-i3bar b/states/sway/files/conky-i3bar new file mode 100755 index 0000000..ad8d8fd --- /dev/null +++ b/states/sway/files/conky-i3bar @@ -0,0 +1,9 @@ +#!/bin/sh + +echo '{"version":1}' + +echo '[' + +echo '[],' + +exec conky -c ~/.conkyrc diff --git a/states/sway/files/lock b/states/sway/files/lock new file mode 100644 index 0000000..7549837 --- /dev/null +++ b/states/sway/files/lock @@ -0,0 +1,22 @@ +#!/bin/sh + +NAG_MSG="Smartcard is still plugged in, not locking! \ +Lock again to force locking." + +LOCK_CMD="swaylock " +LOCK_CMD+=" -i HDMI-A-2:~/Pictures/lockscreen_1080_1.png" +LOCK_CMD+=" -i HDMI-A-3:~/Pictures/lockscreen_1080_2.png" + +if [ $(pgrep -c lock.{{ grains['host'] }}) -gt 1 ]; then + pkill -f "$NAG_MSG" + $LOCK_CMD +else + gpg --card-status > /dev/null + if [ $? -ne 2 ]; then + gpg --card-status + echo $? + swaynag -m "$NAG_MSG" --type warning + else + $LOCK_CMD + fi +fi diff --git a/states/sway/init.sls b/states/sway/init.sls index f19533d..010484d 100644 --- a/states/sway/init.sls +++ b/states/sway/init.sls @@ -2,6 +2,7 @@ include: - sway.{{ grains['os']| lower }} - conky - font.pango-liberation-mono + - local.bin config dir: file.directory: @@ -19,3 +20,20 @@ sway config: - user: {{ grains['user']}} - group: {{ grains['user']}} - mode: 640 + +lock script: + file.managed: + - name: {{ grains['homedir'] }}/.local/bin/lock.{{ grains['host'] }} + - source: {{ grains['stateroot'] }}/sway/files/lock + - template: jinja + - user: {{ grains['user'] }} + - group: {{ grains['user'] }} + - mode: 750 + +conky launch script: + file.managed: + - name: {{ grains['homedir'] }}/.local/bin/conky-i3bar + - source: {{ grains['stateroot'] }}/sway/files/conky-i3bar + - user: {{ grains['user'] }} + - group: {{ grains['user'] }} + - mode: 750