Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
I was going to say "use D-Bus", but it turns out that Totem doesn't expose much of anything via D-Bus... –  Ignacio Vazquez-Abrams Jul 23 '12 at 6:21

2 Answers 2

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...

share|improve this answer
    
Yeah, but I don't mind if the computer locks while I play music. –  Kyle Jul 23 '12 at 6:36
    
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 6:41
up vote 0 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.