2

I'm experiencing this problem where VLC continues to inhibit the power management daemon even after playback has ended (even though the option in the VLC preferences is labeled "Inhibit the power management daemon during playback"). I asked in the VLC Forum but got no reply. I've considered manually compiling the latest development release of VLC in order to fix this issue but I'm not sure I want to go there or if this would even resolve the issue. One answer suggests setting up a DBus query to get the play state of VLC and killing the process when it's done playing. How would one go about setting up such a DBus query? My system is running VLC 2.0.9 from ppa:videolan/stable-daily on Ubuntu 12.04 LTS and all of the installed packages are updated to the latest versions. Thanks.

1
  • @Sneetsher Merged them into one answer.
    – JB0x2D1
    Apr 10, 2014 at 13:21

1 Answer 1

1

My solution written in C is what I settled on. It is a daemon that uses the low level DBus API to call methods on VLC to get the playback status and ask VLC to quit if it is stopped. The bash and python scripts were not reliable when run as Ubuntu Startup Applications, which is what I wanted. IIRC, the bash and python versions had to be manually run from a terminal to work.

Bash solution using GDBus (was installed by default on my Ubuntu 12.04):

#VLC Watchdog Bash Script (vlcwd.sh)
while [ 1 -eq 1 ]
do
    if [ "$(pgrep vlc)" != "" ] #if VLC is running
        then #get the playback status and save to variable pbs
        pbs=$(bash -c 'gdbus call --session \
        --dest org.mpris.MediaPlayer2.vlc-$(pgrep vlc) \
        --object-path /org/mpris/MediaPlayer2 \
        --method org.freedesktop.DBus.Properties.Get \
        "org.mpris.MediaPlayer2.Player" \
        "PlaybackStatus"')
        if [ "$pbs" = "(<'Stopped'>,)" ] #if VLC is stopped
        then kill -9 $(pgrep vlc) #then kill it so it doesn't block my screen saver
        fi
    fi
    sleep 5
done

Python This is how I set up a DBus query to get the play state of VLC using Python and the python-dbus module:

import dbus

bus = dbus.SessionBus()
vlc_media_player_obj = bus.get_object("org.mpris.MediaPlayer2.vlc", "/org/mpris/MediaPlayer2")
props_iface = dbus.Interface(vlc_media_player_obj, 'org.freedesktop.DBus.Properties')
pb_stat = props_iface.Get('org.mpris.MediaPlayer2.Player', 'PlaybackStatus')
1
  • 1
    In Ubuntu 14.04, I used bash version and changed --dest org.mpris.MediaPlayer2.vlc.instance$(pgrep vlc) as it appears in qdbusviewer. It works as it is supposed. Thank you very much.
    – user.dz
    Apr 10, 2014 at 17:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .