#!/bin/sh
# This helper script unlocks the Plasma5 screenlocker of the session given by argument,
# should the locker ever crash.
#
# Requirements:	ConsoleKit[2] & qdbus
#

# list running sesions
list_sessions ()
{
    /usr/local/bin/ck-list-sessions | grep -oE '^Session[^:]*'
}

# unlock_session <session_name>
unlock_session ()
{
    /usr/local/bin/qdbus-qt6 --system org.freedesktop.ConsoleKit "/org/freedesktop/ConsoleKit/$1" org.freedesktop.ConsoleKit.Session.Unlock
}

if [ $# -ne 1 ] ; then
  list_sessions
else
  unlock_session $1
fi

