1. #1
    Avatar von patlux
    Registriert seit
    26.10.2011
    Beiträge
    1.195
    Thanked 1.596 Times in 725 Posts
    Blog Entries
    2

    Standard [Source] MPD/Spotify Music Shortcuts

    Heyho,

    da ich neben meinem Musik-Player (sonata/mpd) auch manchmal Spotify nutze und zum Abspielen, Pausieren, Weiter- und Zurückschalten meine zusätzlichen Tasten auf meiner Tastatur nutze, hab ich ein Skript erstellt, welches je nachdem ob Sonata/MPD oder Spotify läuft die Tasteneingaben an das Programm schickt. Heißt, wenn Spotify nicht manuell gestartet wurde, werden alle Tasteneingaben an Sonata/MPD - also dem Standard-Player - geschickt. Sobald allerdings Spotify gestartet wurde, werden alle Eingaben an Spotify geschickt.

    Skript:
    #!/bin/sh
    case $1 in
    "open")
    if [ "$(pidof spotify)" ]
    then
    spotify
    else
    sonata
    fi
    exit 0;
    ;;
    "toggle")
    key="XF86AudioPlay"
    ;;
    "next")
    key="XF86AudioNext"
    ;;
    "prev")
    key="XF86AudioPrev"
    ;;
    "stop");;
    *)
    echo "Usage: $0 open|toggle|next|prev|stop"
    exit 1
    ;;
    esac
    if [ "$(pidof spotify)" ]
    then
    xdotool key --window $(xdotool search --name "Spotify (Premium )?- Linux Preview"|head -n1) $key
    else
    mpc $1
    fi
    exit 0


    Beachtet, dass ihr xdotool installiert haben müsst.
    Und natürlich müsst ihr euren Player (bei mir sonata) mit euren ersetzen.

    Ihr müsst dann noch eure Tasten, je nachdem welchen Window-Manager ihr nutzt, an die o.g. Skript-Datei schicken mit den Parametern "open", "toggle"(=play/pause), "next", "prev", "stop".

    Unter Openbox sieht die Konfiguration der Shortcuts dann so aus:

    rc.xml:
    <keybind key="XF86AudioStop">
    <action name="Execute">
    <command>~/bin/music.sh stop</command>
    </action>
    </keybind>
    <keybind key="XF86AudioPlay">
    <action name="Execute">
    <command>~/bin/music.sh toggle</command>
    </action>
    </keybind>
    <keybind key="XF86AudioPrev">
    <action name="Execute">
    <command>~/bin/music.sh prev</command>
    </action>
    </keybind>
    <keybind key="XF86AudioNext">
    <action name="Execute">
    <command>~/bin/music.sh next</command>
    </action>
    </keybind>
    <keybind key="XF86Tools">
    <action name="Execute">
    <command>~/bin/music.sh open</command>
    </action>
    </keybind>


    Da wirds an die von mir erstellte ~/bin/music.sh-Skriptdatei geschickt.


    Have Fun.
    Geändert von patlux (27.06.2013 um 11:55 Uhr)

  2. The Following 2 Users Say Thank You to patlux For This Useful Post:

    Festplatte (05.08.2013), TomatenKetchup (25.06.2013)

Ähnliche Themen

  1. Spotify nun auch in Deutschland
    Von Comu im Forum IT & Technik News
    Antworten: 1
    Letzter Beitrag: 13.03.2012, 14:52
Diese Seite nutzt Cookies, um das Nutzererlebnis zu verbessern. Klicken Sie hier, um das Cookie-Tracking zu deaktivieren.