]> git.friedersdorff.com Git - max/saltfiles.git/commitdiff
Manage lock and conky scripts
authorMaximilian Friedersdorff <max@friedersdorff.com>
Tue, 4 Jun 2019 10:39:18 +0000 (11:39 +0100)
committerMaximilian Friedersdorff <max@friedersdorff.com>
Tue, 4 Jun 2019 10:39:18 +0000 (11:39 +0100)
states/local/bin.sls [new file with mode: 0644]
states/sway/files/conky-i3bar [new file with mode: 0755]
states/sway/files/lock [new file with mode: 0644]
states/sway/init.sls

diff --git a/states/local/bin.sls b/states/local/bin.sls
new file mode 100644 (file)
index 0000000..1cd44f1
--- /dev/null
@@ -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 (executable)
index 0000000..ad8d8fd
--- /dev/null
@@ -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 (file)
index 0000000..7549837
--- /dev/null
@@ -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
index f19533dbd133a6fcd8fb12f0682ad324570ddfdd..010484d2d4423b7b3b9d00b7058b788e52038532 100644 (file)
@@ -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