You are not logged in.

#1 2014-05-18 02:54:23

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

[SOLVED] indicator-session: Logout, Restart, Shutdown unresponsive

If you use systemd, install indicator-session-systemd to solve this problem.

TODO: Find a way to logout, restart, shutdown, etc with systemd that doesn't require a password. Suggestions welcome!

Bug report / feature request for loginctl kill-session to be allowed to users.

Last edited by quequotion (2014-06-15 23:47:07)

Offline

#2 2014-06-12 10:41:29

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: [SOLVED] indicator-session: Logout, Restart, Shutdown unresponsive

Some progress. Apparently, indicator-session is attempting to use gnome-session-quit for all three options.

I managed to get some terminal output:

killall indicator-session-service && /usr/lib/indicator-session/indicator-session-service

Then I clicked each of the unresponsive options in sequence:

** (gnome-session-quit:25654): WARNING **: Failed to call logout: Logout interface is only available during the Running phase

** (gnome-session-quit:25661): WARNING **: Failed to call Reboot: Reboot interface is only available during the Running phase

** (gnome-session-quit:25663): WARNING **: Failed to call Shutdown: Shutdown interface is only available during the Running phase

I've also tried running gnome-session-quit from the command line by itself and got the same results.

So, how do I get to the "Running phase" of whatever is supposed to be there?

Nevermind. Seriously had a enough of this, and so decided to go off on a tangent.

EDIT: Then I went and filed a bug report about it anyway.

Behold ye what anger hath wrought: indicator-session-systemd

Last edited by quequotion (2014-06-16 18:46:35)

Offline

#3 2014-06-12 12:48:06

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: [SOLVED] indicator-session: Logout, Restart, Shutdown unresponsive

One way or another, I am getting this done.

I will have logout, restart, and shutdown options in a convenient system tray icon. I will have them I tell you!

Step 1, this:
systemd-dbus-session-manager

#! /bin/bash

case "$1" in
	logout|quit|exit)
		MESSAGE="Enter password to log out:"
		# Logout /only/ the /current desktop session/.
		# Caveats:
		# -Nothing simply prints the session id; get it by association with this running scripts PID.
		# -An unknowable thing cannot be pattern matched; Session IDs appear to be two digit hex numbers.
		# -A password is required to kill a session or user; there's no getting around it, I tried.
		SESSIONID=$(gdbus call -y -d org.freedesktop.login1 -o /org/freedesktop/login1 -m org.freedesktop.login1.Manager.GetSessionByPID $$ | sed -nr '/.*session\/(.{,2}).*/s//\1/p')
		# gdbus will throw and IO Error if sending more than two arguments,
		# even if the method requires three or more like KillSession.
		gksu -m $MESSAGE loginctl kill-session $SESSIONID
		exit # curious if this exit actually happens...
	;;
	suspend|standby|sleep)
		MESSAGE="Suspending..."
		METHOD="Suspend"
		ARGS="true"
		ICON="shutdown"
		OK="Suspend"
	;;
	hibernate)
		MESSAGE="Hibernating..."
		METHOD="Hibernate"
		ARGS="true"
		ICON="shutdown"
		OK="Hibernate"
	;;
	reboot|reset)
		MESSAGE="Rebooting..."
		METHOD="Reboot"
		ARGS="true"
		ICON="shutdown"
		OK="Reboot"
	;;
	shutdown|poweroff)
		MESSAGE="Powering Off..."
		METHOD="PowerOff"
		ARGS="true"
		ICON="shutdown"
		OK="Poweroff"
	;;
	*)
		exit
	;;
esac

# Zenity's OK and Cancel buttons are backward (unless you read left to right)...
[[ $(zenity --question --title=indicator-session-systemd --window-icon="/usr/share/icons/gnome/16x16/actions/gnome-$ICON.png" --text="$MESSAGE?\n(5 sec)" --ok-label Cancel --icon-name="gnome-$ICON" --cancel-label $OK --timeout=5; echo $?) -gt 0 ]] && gdbus call -y -d org.freedesktop.login1 -o /org/freedesktop/login1 -m org.freedesktop.login1.Manager.$METHOD $ARGS

Step 3, Upload a new indicator-session-systemd package to AUR.
Done, although there's probably more fine tuning that could be done.
So long as systemd and dbus are available, this package should work with any indicator-supporting DE.

Last edited by quequotion (2014-06-13 10:42:53)

Offline

#4 2014-06-12 15:59:57

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: [SOLVED] indicator-session: Logout, Restart, Shutdown unresponsive

Another way, which depends on polkit:
systemctl-session-manager

#! /bin/bash

case "$1" in
	logout|quit|exit)
		MESSAGE="Enter password to log out:"
		# Logout /only/ the /current desktop session/.
		# Caveats:
		# -Nothing simply prints the session id; get it by association with this running scripts PID.
		# -An unknowable thing cannot be pattern matched; Session IDs appear to be two digit hex numbers.
		# -A password is required to kill a session or user; there's no getting around it, I tried.
		SESSIONID=$(gdbus call -y -d org.freedesktop.login1 -o /org/freedesktop/login1 -m org.freedesktop.login1.Manager.GetSessionByPID $$ | sed -nr '/.*session\/(.{,2}).*/s//\1/p')
		# gdbus will throw and IO Error if sending more than two arguments,
		# even if the method requires three or more like KillSession.
		gksu -m $MESSAGE loginctl kill-session $SESSIONID
		exit # curious if this exit actually happens...
	;;
	suspend|standby|sleep)
		MESSAGE="Suspending..."
		METHOD="suspend"
		ICON="shutdown"
		OK="Suspend"
	;;
	hibernate)
		MESSAGE="Hibernating..."
		METHOD="hibernate"
		ICON="shutdown"
		OK="Hibernate"
	;;
	reboot|reset)
		MESSAGE="Rebooting..."
		METHOD="reboot"
		ICON="shutdown"
		OK="Reboot"
	;;
	shutdown|poweroff)
		MESSAGE="Powering Off..."
		METHOD="poweroff"
		ICON="shutdown"
		OK="Poweroff"
	;;
	*)
		exit
	;;
esac

# Zenity's OK and Cancel buttons are backward (unless you read left to right)...
[[ $(zenity --question --title=indicator-session-systemd --window-icon="/usr/share/icons/gnome/16x16/actions/gnome-$ICON.png" --text="$MESSAGE?\n(5 sec)" --ok-label Cancel --icon-name="gnome-$ICON" --cancel-label $OK --timeout=5; echo $?) -gt 0 ]] && systemctl $METHOD

Last edited by quequotion (2014-06-13 11:08:46)

Offline

#5 2014-06-12 16:33:50

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: [SOLVED] indicator-session: Logout, Restart, Shutdown unresponsive

Furthermore, if you'd like to give "Lock" something to do, replacing gnome-screensaver's dbus with a dupe that calls xscreensaver works.

There's also a logind dbus method "Lock" but it doesn't actually lock the screen and requires a password (to call); as does this:

loginctl -lock-session $(gdbus call -y -d org.freedesktop.login1 -o /org/freedesktop/login1 -m org.freedesktop.login1.Manager.GetSessionByPID $$ | sed -nr '/.*session\/(.{,2}).*/s//\1/p')

Last edited by quequotion (2014-06-16 18:49:48)

Offline

#6 2014-06-13 03:33:59

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: [SOLVED] indicator-session: Logout, Restart, Shutdown unresponsive

Looks like the most of the dbus methods don't actually require a password, as they are explicitly allowed in /etc/dbus-1/systemd.d/org.freedesktop.login1.conf

Only the logout fuctions, KillSession and KillUser, are not explicitly allowed..... Why?

Let's see if I can do something about that. Nope, can't.

Even if explicitly allowed by config, the KillSession and KillUser methods require passwords.

Anyway KillSession doesn't work and KillUser is not the right thing to do (it ends everything, even tty logins).

The only viable option for systemd logout, which also requires a password, is:

loginctl kill-session $(gdbus call -y -d org.freedesktop.login1 -o /org/freedesktop/login1 -m org.freedesktop.login1.Manager.GetSessionByPID $$ | sed -nr '/.*session\/(.{,2}).*/s//\1/p')

Last edited by quequotion (2014-06-13 11:13:30)

Offline

#7 2014-06-13 08:20:19

quequotion
Member
From: Oita, Japan
Registered: 2013-07-29
Posts: 813
Website

Re: [SOLVED] indicator-session: Logout, Restart, Shutdown unresponsive

KillSession seems to be broken. It's supposed to take three arguments: string(sessionid) string(leader|all) int32(signal)

"sessionid" identifies a session. There's no easy way to get this information; one must grep or sed the output of something. They seem to be two-digit hex numbers, but there's no way to tell if longer identifiers are possible.
"leader" designates the session parent process; "all" designates all processes in the session
"signal" is a numbered kill signal, like 9 or 15

Whatever is given by gdbus, the result is an IO Error.

If I recall correctly, I had the same problem with dbus-send ages ago, that it wasn't capable of sending more than two arguments. This has never been fixed?

So I made a bug report for this too.

Last edited by quequotion (2014-06-17 13:52:57)

Offline

Board footer

Powered by FluxBB