1

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.

Kyle
  • 153

2 Answers2

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
  • 6,113
  • 1
  • 24
  • 34
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

Kyle
  • 153