Skip to content

Instantly share code, notes, and snippets.

@meyerbaptiste
Last active August 29, 2015 14:05
Show Gist options
  • Save meyerbaptiste/25e0aa751ff8260998b5 to your computer and use it in GitHub Desktop.
Save meyerbaptiste/25e0aa751ff8260998b5 to your computer and use it in GitHub Desktop.
Gnome 3 inhibitor for VLC (Python)
#!/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