Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gajim
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mesonium
gajim
Commits
02cca30d
Commit
02cca30d
authored
4 years ago
by
André
Committed by
Philipp Hörist
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Support idle time from org.freedesktop.ScreenSaver
parent
c36a2b30
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
flatpak/org.gajim.Gajim.yaml
+1
-0
1 addition, 0 deletions
flatpak/org.gajim.Gajim.yaml
gajim/common/idle.py
+61
-6
61 additions, 6 deletions
gajim/common/idle.py
with
62 additions
and
6 deletions
flatpak/org.gajim.Gajim.yaml
+
1
−
0
View file @
02cca30d
...
...
@@ -21,6 +21,7 @@ finish-args:
-
--talk-name=org.mpris.MediaPlayer2.*
-
--talk-name=org.freedesktop.portal.Fcitx
# Automatic status
-
--talk-name=org.freedesktop.ScreenSaver
-
--talk-name=org.gnome.Mutter.IdleMonitor
# Keyring
-
--talk-name=org.freedesktop.secrets
...
...
This diff is collapsed.
Click to expand it.
gajim/common/idle.py
+
61
−
6
View file @
02cca30d
...
...
@@ -33,6 +33,57 @@
log
=
logging
.
getLogger
(
'
gajim.c.idle
'
)
class
DBusFreedesktopIdleMonitor
:
def
__init__
(
self
):
self
.
last_idle_time
=
0
self
.
_extended_away
=
False
log
.
debug
(
'
Connecting to D-Bus
'
)
self
.
dbus_proxy
=
Gio
.
DBusProxy
.
new_for_bus_sync
(
Gio
.
BusType
.
SESSION
,
Gio
.
DBusProxyFlags
.
NONE
,
None
,
'
org.freedesktop.ScreenSaver
'
,
'
/org/freedesktop/ScreenSaver
'
,
'
org.freedesktop.ScreenSaver
'
,
None
)
log
.
debug
(
'
D-Bus connected
'
)
# Only the following call will trigger exceptions if the D-Bus
# interface/method/... does not exist. Using the failing method
# for class init to allow other idle monitors to be used on failure.
self
.
_get_idle_sec_fail
()
log
.
debug
(
'
D-Bus call test successful
'
)
def
_get_idle_sec_fail
(
self
):
(
idle_time
,)
=
self
.
dbus_proxy
.
call_sync
(
'
GetSessionIdleTime
'
,
None
,
Gio
.
DBusCallFlags
.
NO_AUTO_START
,
-
1
,
None
)
return
idle_time
//
1000
def
get_idle_sec
(
self
):
try
:
self
.
last_idle_time
=
self
.
_get_idle_sec_fail
()
except
GLib
.
Error
as
error
:
log
.
warning
(
'
org.freedesktop.ScreenSaver.GetSessionIdleTime() failed: %s
'
,
error
)
return
self
.
last_idle_time
def
set_extended_away
(
self
,
state
):
self
.
_extended_away
=
state
def
is_extended_away
(
self
):
return
self
.
_extended_away
class
DBusGnomeIdleMonitor
:
def
__init__
(
self
):
...
...
@@ -257,15 +308,19 @@ def _get_idle_monitor():
return
WindowsIdleMonitor
()
try
:
return
DBus
Gnome
IdleMonitor
()
return
DBus
Freedesktop
IdleMonitor
()
except
GLib
.
Error
as
error
:
log
.
info
(
'
Idle time via D-Bus not available: %s
'
,
error
)
try
:
return
XssIdleMonitor
()
except
OSError
as
error
:
log
.
info
(
'
Idle time via XScreenSaverInfo
'
'
not available: %s
'
,
error
)
try
:
return
DBusGnomeIdleMonitor
()
except
GLib
.
Error
as
error
:
log
.
info
(
'
Idle time via D-Bus (GNOME) not available: %s
'
,
error
)
try
:
return
XssIdleMonitor
()
except
OSError
as
error
:
log
.
info
(
'
Idle time via XScreenSaverInfo not available: %s
'
,
error
)
def
get_idle_sec
(
self
):
return
self
.
_idle_monitor
.
get_idle_sec
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment