added lock.sh and unlock.sh

This commit is contained in:
Seaswimmer 2024-06-22 22:32:34 -04:00
parent 27304c4927
commit f9fdad44c4
Signed by: cswimr
GPG key ID: 3813315477F26F82
2 changed files with 22 additions and 0 deletions

11
lock.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
loginctl lock-session
exit_code=$?
time=$(date +"%r")
if [ $exit_code -eq 0 ]; then
kdeconnect-cli -d "$(kdeconnect-cli -l | grep -oP '(?<=: )\w{8}_\w{4}_\w{4}_\w{4}_\w{12}')" --ping-msg "Locked $HOSTNAME ($time)"
else
kdeconnect-cli -d "$(kdeconnect-cli -l | grep -oP '(?<=: )\w{8}_\w{4}_\w{4}_\w{4}_\w{12}')" --ping-msg "Failed to lock $HOSTNAME ($time) - Error code: $exit_code"
fi

11
unlock.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
loginctl unlock-session
exit_code=$?
time=$(date +"%r")
if [ $exit_code -eq 0 ]; then
kdeconnect-cli -d "$(kdeconnect-cli -l | grep -oP '(?<=: )\w{8}_\w{4}_\w{4}_\w{4}_\w{12}')" --ping-msg "Unlocked $HOSTNAME ($time)"
else
kdeconnect-cli -d "$(kdeconnect-cli -l | grep -oP '(?<=: )\w{8}_\w{4}_\w{4}_\w{4}_\w{12}')" --ping-msg "Failed to unlock $HOSTNAME ($time) - Error code: $exit_code"
fi