Unlock gnome/mate/i3 locks from the command line
I run multiple desktop environments, and they all come with their own screen locking tool. Sometimes I want to unlock a system remotely, that means from the command line. The script below can unlock mate, gnome and i3lock.
#!/bin/bash
echo "Unlock"
echo
echo " - [m]ate"
echo " - [g]nome"
echo " - [i]3lock"
uid=$(id -u "${USER}")
if pgrep -U "$uid" -af i3lock > /dev/null; then
choice="i"
elif pgrep -U "$uid" -af mate-screensaver > /dev/null; then
choice="m"
else
read -r -s -n1 choice
fi
echo -e "\nChoice: ${choice}"
if [ "$choice" == "m" ]; then
mate-screensaver-command --unlock
elif [ "$choice" == "g" ]; then
loginctl unlock-sessions
elif [ "$choice" == "i" ]; then
pkill -f i3lock
else
echo "Unknown choice ${choice}"
fi
0 comments
Reply