I recently switched to DWM and I've been customizing it. I have xautolock setup to autolock my computer after 5 minutes. It gets annoying when I'm watching a movie using Totem. Is there a way to tell if Totem is currently playing a movie so I can edit my screen lock script to check for that? I don't just want it to assume that because Totem is running, it's not okay to lock the screen. It needs to be playing.
Asked
Active
Viewed 369 times
2 Answers
0
Couldn't you check for audio out on the sound card? Have it look at any output (headphones/speaker). I doubt if you'll ever be watching a movie silently...
Everett
- 5,912
- 1
- 22
- 33
-
-
Then what you are attempting to do may be impossible. If you queue off of video, whenever the screen saver comes up, the computer won't lock. If you don't want to do this based off of totem running, you really don't have much else to work with... – Everett Jul 23 '12 at 06:41
0
I found a post on Stackoverflow explainging how to enable a D-bus plugin for totem.
The Python script I came up with is ugly, but it does the job for making sure movies playing don't lock the screen:
import dbus
def totem_is_playing():
try:
T_SERVICE_NAME = "org.mpris.Totem"
T_OBJECT_PATH = "/Player"
T_INTERFACE = "org.freedesktop.MediaPlayer"
session_bus= dbus.SessionBus()
totem = session_bus.get_object(T_SERVICE_NAME, T_OBJECT_PATH)
totem_mediaplayer = dbus.Interface(totem, dbus_interface=T_INTERFACE)
status = totem_mediaplayer.GetStatus()
if status[0] == 0:
return True
return False
except dbus.exceptions.DBusException:
return False
The plugin API can be explain via code review here: https://yayoutube.googlecode.com/svn-history/r50/trunk/totem/mpris/mpris.py