Home > computers > linux > DBus | About

Cool things to try with dbus

Play next/previous media in vlc

qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next

You can add this a global keyboard shortcut if your DE supports it, or to xbindkeys. I have bound that to the Super+PgDown and the play previous to Super+PgUp.

see http://i.imgur.com/8ES1DR9.png

Play/pause current media in vlc

qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause

I have bound this to Super+Home. Oh, super is the "windows" key by the way.

Add a media file to the current playlist in vlc

Whenever I feel like loading a song into my playlist to listen to it I do :

addmusic pattern

Here are the complete bash functions that allow me to do this

export MUSICFOLDER=~/MUSIQUE/CONTENT/
function addmusic {
    track="$1"
    while read -r file
    do
        #the last argument is a boolean that if set to true will play the song immediately
	qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.TrackList.AddTrack file://"$file" $(dirname "$file") false

    done <<< "$(findmusic $track)"
}

function findmusic {
    find $MUSICFOLDER -iname "*$1*.mp3"
}

Examples

addmusic tellme

will add this file /home/ychaouche/MUSIQUE/CONTENT/CD6/tellmeitsreal_kciandjojo.mp3 to my current playlist.

addmusic sustenta

will add this file /home/ychaouche/MUSIQUE/CONTENT/CD6/sustenta_edmotta.mp3 to my current playlist

and

addmusic owlcity

will add all those files to the current playlist

/home/ychaouche/MUSIQUE/CONTENT/CD6/halcyon_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/helloseattleremix_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/dentalcare_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/fireflies8bit_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/tothesky_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/meteorshower_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/helloseatle_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/alligatorsky_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/dearvienna_owlcity.mp3
/home/ychaouche/MUSIQUE/CONTENT/CD6/onthewing_owlcity.mp3

contact : @ychaouche yacinechaouche at yahoocom


QR Code
QR Code Play next/previous media in vlc (generated for current page)