On 09/12/17 05:13, Michael Palimaka wrote:
> On 09/12/2017 05:04 AM, Daniel Frey wrote:
>> According to a comment in the bug, you can try to figure out which
>> session it is (ck-list-sessions) and look for the X11 display property
>> set. This will not work (or could be difficult) if you have several
>> users using KDE at the same time and can't tell the sessions apart.
>>
>> Once you figure that out, remember the session name and:
>>
>> # su -c 'dbus-send --system --print-reply \
>> --dest="org.freedesktop.ConsoleKit" \
>> /org/freedesktop/ConsoleKit/ \
>> org.freedesktop.ConsoleKit.Session.Unlock'
>>
>
> If there a nice way to wrap this up in a script I'd be interesting in
> shipping this for non-logind systems.
>
> Another option is sys-auth/elogind, which provides the logind interface
> and tools (like loginctl) for non-systemd systems. This is what I've
> been testing with OpenRC for some time.
>
> I read that ConsoleKit is also supporting the logind dbus interface now.
> This would in theory make it easy to create a tool to unlock the
> session, but I haven't had a chance to test it yet.
>
Well, I forgot to disable my screen locker during an update and got bit
by this again. It's a pain typing it manually (especially when you run a
monitor in portrait mode.)
I had some time and put together a general-purpose bash script. A note
of warning, I'm not an expert at bash by any means, but I was able to
test this several ways as I haven't restarted my computer yet.
I'll attach it if someone else wants to try it out. It's simply called
ck-unlock-session.
Dan
#!/bin/sh
# This script is to make unlocking using OpenRC/Consolekit easier when the KDE
Screenlocker breaks.
#
# Version: 0.1
# Date written: February 2, 2018
#
# Copyright (C) 2018 Daniel Frey
#
# This script is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This script is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#
# Some notes:
# -The switch processing/argument handling is very basic.
# -This script assumes session names start with "Session" when listing
#sessions. This is settable via a variable.
#
# Possible actions:
# -h : Show help screen
# -l : List current consolekit sessions
# -u : Unlock specified session (one parameter required - the session name)
# -a : Attempt to unlock all sessions
# Return code documentation
#
# 0: Script executed normally
# 1: Root access is not present for script
# 2: No arguments passed
# 3: Multiple actions requested, can only do one at a time
# 4: Argument passed was not recognized
# 5: Multiple arguments passed for unlock single session, only one needed
# 6: The argument required for unlocksession() is missing (internal error)
# Return code constants
readonly ERR_NORMAL_OPERATION=0
readonly ERR_NO_ROOT=1
readonly ERR_NO_ARGS=2
readonly ERR_TOO_MANY_ACTIONS=3
readonly ERR_INVALID_ARGUMENTS=4
readonly ERR_TOO_MANY_ARGS=5
readonly ERR_INTERNAL_ARG_MISSING=6
# Action parameter constants
readonly ACTION_NONE=0
readonly ACTION_HELP=1
readonly ACTION_LIST=2
readonly ACTION_UNLOCKALL=3
readonly ACTION_UNLOCK=4
# This is what's used to look for a session via consolekit.
# By default, assume it is prefixed with "Session".
SESSION_SEARCH_PREFIX=Session
# Check to make sure script has root access, if not... abort now!
if [ $EUID -ne 0 ]; then
echo "This script must be run as root."
exit $ERR_NO_ROOT
fi
function showhelp () {
echo "`basename $0`: a script that helps unlock consolekit sessions
Usage: `basename $0` [action] [parameters]
Actions:
-l : list current sessions available for unlocking
-u : unlock session specified as a parameter
-a : attempt to unlock all current sessions
-h : this screen
Parameters:
The -u parameter requires a session name to unlock, use -l to list
sessions.
Example:
To unlock a single session, use:
`basename $0` -u Session1
No arguments will show this screen."
}
function listsessions() {
# Get a list of all sessions, and remove the full colon from the
session name
ALLSESSIONS=`ck-list-sessions | grep -i ^$SESSION_SEARCH_PREFIX | rev |
cut -c 2- | rev`
echo
echo "Sessions present on this machine, space-delineated:"
echo
echo $ALLSESSIONS
echo
echo
echo "Session detail (to help locate a specific session:"
ck-list-sessions | grep -A 2 -i ^$SESSION_SEARCH_PREFIX
}
function unlocksession () {
# This function expects one parameter set (the session to unlock.
# Make sure the parameter exists before continuing.
if