Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
X11:Utilities
takeabreak
takeabreak-locker-dbus.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File takeabreak-locker-dbus.patch of Package takeabreak
--- a/code/takeabreak_run +++ b/code/takeabreak_run @@ -13,6 +13,7 @@ should have received a copy of the GNU G program. If not, see <http://www.gnu.org/licenses/>. """ +from gi.repository import Gio import subprocess import sys import time @@ -60,6 +61,19 @@ def idle_sleep(): break else: curr_idle1 = curr_idle2 + +def screensaver_command(method, value): + names = ["org.freedesktop.ScreenSaver", + "org.gnome.ScreenSaver", + "org.mate.ScreenSaver"] + paths = ["/org/freedesktop/ScreenSaver", + "/org/gnome/ScreenSaver", + "/org/mate/ScreenSaver"] + + bus = Gio.bus_get_sync(Gio.BusType.SESSION, None) + for i in range(len(names)): + proxy = Gio.DBusProxy.new_sync(bus, 0, None, names[i], paths[i], names[i], None) + proxy.call(method, value, 0, 0, None, None) def take_a_break(): get = subprocess.check_output(["xrandr"]).decode("utf-8").split() @@ -78,18 +92,13 @@ def take_a_break(): "xrandr", "--output", scr, "--brightness", "0" ]) elif mode == "lock": - subprocess.Popen([ - "gnome-screensaver-command", "-l" - ]) + screensaver_command("Lock", None) elif mode == "screensaver": - subprocess.Popen([ - "gnome-screensaver-command", "-al" - ]) + screensaver_command("SetActive", GLib.Variant("(b)", (True,))) + screensaver_command("Lock", None) time.sleep(sleeptime) for scr in screens: - subprocess.Popen([ - "gnome-screensaver-command", "-d" - ]) + screensaver_command("SetActive", GLib.Variant("(b)", (False,))) time.sleep(2) if mode == "rotate": subprocess.call([
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor