Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
@Sneetsher Merged them into one answer. –  JB0x2D1 Apr 10 at 13:21

1 Answer 1

up vote 1 down vote accepted

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')
share|improve this answer
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. –  Sneetsher Apr 10 at 17:59

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.