Re: Detect screen-lock in shell/c++
- From: Bastien Nocera <hadess hadess net>
- To: Mathieu Slabbinck <matty slabbinck gmail com>
- Cc: desktop-devel-list gnome org
- Subject: Re: Detect screen-lock in shell/c++
- Date: Mon, 03 Nov 2014 10:20:50 +0100
On Mon, 2014-11-03 at 10:03 +0100, Mathieu Slabbinck wrote:
2014-11-03 9:32 GMT+01:00 Bastien Nocera <hadess hadess net>:
On Mon, 2014-11-03 at 08:43 +0100, Mathieu Slabbinck wrote:
> I have a cross-platform application that runs on Ubuntu
14.04 (Unity &
> GNome) & Fedora (GNome). There I need to determine if the
screensaver
> is active or not and if the screen is locked or not.
>
> I found out that I can get the screensaver info with:
> gnome-screensaver-command -q
As far as I know, neither Unity nor gnome-shell use
gnome-screensaver
anymore. In fact, gnome-screensaver has been closed for new
bugs.
Didn't know that's deprecated. Works fine still.
It's not "deprecated", it's obsolete. It won't do anything with GNOME or
recent versions of Unity.
Any idea on the correct current handling to get tis information?
> But I cannot seem to figure out how I can detect a screen
lock. For
> example on Unity I can use:
>
> gdbus call -e -d com.canonical.Unity
-o /com/canonical/Unity/Session -m
com.canonical.Unity.Session.IsLocked
>
> but that's a Unity-specific item. So what's the best
approach to get
> screen lock in GNome?
What do you actually want to do? Why do you need to detect the
screen
saver? Or do you need to detect that the screen is locked?
Well the application I created should do action A when the user logs
out or locks the screen, and the application should do action B when
the screen saver comes up.
Simple as that.
You can use the GNOME and Unity specific interfaces, or you can use
logind's session API to get the status. On my system, for example, going
in and out of the screensaver, you can see the IdleHint changing:
$ gdbus monitor --system --dest org.freedesktop.login1 --object-path /org/freedesktop/login1/session/_31
Monitoring signals on object /org/freedesktop/login1/session/_31 owned by org.freedesktop.login1
The name org.freedesktop.login1 is owned by :1.1
/org/freedesktop/login1/session/_31: org.freedesktop.DBus.Properties.PropertiesChanged
('org.freedesktop.login1.Session', {'IdleHint': <true>, 'IdleSinceHint': <uint64 1415006348876052>,
'IdleSinceHintMonotonic': <uint64 516705962866>}, @as [])
/org/freedesktop/login1/session/_31: org.freedesktop.login1.Session.Unlock ()
/org/freedesktop/login1/session/_31: org.freedesktop.DBus.Properties.PropertiesChanged
('org.freedesktop.login1.Session', {'IdleHint': <false>, 'IdleSinceHint': <uint64 1415006353519410>,
'IdleSinceHintMonotonic': <uint64 516710606224>}, @as [])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]