Last active
August 29, 2015 14:05
-
-
Save meyerbaptiste/25e0aa751ff8260998b5 to your computer and use it in GitHub Desktop.
Gnome 3 inhibitor for VLC (Python)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# -*- coding: utf-8 -*- | |
import os | |
import sys | |
import dbus | |
class inhibitor: | |
def __init__(self): | |
bus = dbus.SessionBus() | |
self.cookie = None | |
self.proxy = bus.get_object('org.gnome.SessionManager', '/org/gnome/SessionManager') | |
def start(self): | |
if self.cookie == None: | |
self.cookie = self.proxy.Inhibit('vlc', dbus.UInt32(0), 'VLC has disabled the screensaver', dbus.UInt32(8)) | |
def stop(self): | |
if self.cookie != None: | |
self.proxy.Uninhibit(self.cookie) | |
self.cookie = None | |
inhibitor = inhibitor() | |
inhibitor.start() | |
arguments = ' '.join(sys.argv[1:]) | |
if len(arguments) == 0: | |
command = '/usr/bin/vlc' | |
else: | |
command = '/usr/bin/vlc "%s"' % (arguments) | |
os.system(command) | |
inhibitor.stop() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment