]> git.friedersdorff.com Git - max/saltfiles.git/blob - states/sway/files/lock
Add background image to lock screen
[max/saltfiles.git] / states / sway / files / lock
1 #!/bin/sh
2
3 NAG_MSG="Smartcard is still plugged in, not locking! \
4 Remove now to lock."
5 NOLOCK_MSG="Smartcard was not removed, did not lock!"
6
7 LOCK_CMD="swaylock "
8 {% if grains['host'] == 'magnesium' %}
9 LOCK_CMD+=" -i HDMI-A-2:~/Pictures/lockscreen_1080_1.png"
10 LOCK_CMD+=" -i HDMI-A-3:~/Pictures/lockscreen_1080_2.png"
11 {% elif grains['host'] == 'barium' %}
12 LOCK_CMD+=" -i eDP-1:~/Pictures/lockscreen_1080_1.png"
13 LOCK_CMD+=" -i HDMI-A-1:~/Pictures/lockscreen_1080_1.png"
14 {% endif %}
15
16
17 if [ $(pgrep -c lock.magnesium) -gt 1 ]; then
18         exit
19 else
20         gpg --card-status > /dev/null
21         if [ $? -ne 2 ]; then
22                 swaynag -m "$NAG_MSG" --type warning&
23
24                 counter=0
25                 while [ $? -ne 2 ]; do
26                         if [ $counter -gt 20 ]; then
27                                 pkill -f "$NAG_MSG"
28                                 swaynag -m "$NOLOCK_MSG" --type error&
29                                 exit
30                         fi
31
32                         sleep 1
33                         counter=$(bc <<<"${counter}+1")
34                         gpg --card-status > /dev/null
35                 done
36                 pkill -f "$NAG_MSG"
37         fi
38         $LOCK_CMD
39 fi