You are not logged in.

#1 2008-01-16 07:32:31

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,121

Nice keybindings for MPD

Hey!

I thought about sharing a nice keybinding for mpc/mpd. It displays a dmenu in which you can type in the name of a song. The script then adds the found song to mpd's current playlist and begins to play the song imediately.

#!/bin/bash
mpc listall | dmenu -b -nb "#000" -nf "#7af" -sb "#000" -sf "#bdf" | mpc add - ; mpc play `mpc | sed -n '2,2p' | tr -s " " | cut -d " " -f 2 | cut -d "/" -f 2`

Do you have some fancy keybindings for MPD? Show them here! wink

Cheers Sigi


Dammit, haven't been here in a while. Still rocking Arch. smile

Offline

#2 2008-01-16 13:31:07

peets
Member
From: Montreal
Registered: 2007-01-11
Posts: 936
Website

Re: Nice keybindings for MPD

Cool! I will add this to my soon-to-be dzen setup.

I use my keyboard's "multimedia keys" through xbindkeys to control mpd. Here's the relevant part:

"amixer set PCM 5%-"
    m:0x0 + c:174
"amixer set PCM 5%+"
    m:0x0 + c:176
# Play / Pause
"mpc toggle"
    m:0x0 + c:162
"mpc stop"
    m:0x0 + c:164
"mpc prev"
    m:0x0 + c:144
"mpc next"
    m:0x0 + c:153
"urxvt -e ncmpc"
    m:0x0 + c:129

Offline

#3 2008-01-17 03:01:00

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,121

Re: Nice keybindings for MPD

I've got a new one. This one lets you search for an album in a dmenu. The script then clears mpd's playlist, loads all the tracks of the selected album in mpd, starts to play the first song of the album and disables random play mode:

[sigi@arch scripte]$ cat mpcalbum.sh 
#!/bin/bash
ALBUMTITLE=`mpc listall | awk -F / '{print $2 " - " $3}' | grep -v mp3 | uniq | sort -f | dmenu -b -nb "#000" -nf "#7af" -sb "#000" -sf "#bdf" | sed -e 's#\ \-\ #\/#'`
mpc listall | grep "$ALBUMTITLE" > .mpdnewlist_tmp
mpc clear
j=`wc -l .mpdnewlist_tmp | awk '{print $1}'`
J=`echo $j+1 | bc`
for ((i=1; i<J; i++)) ; do 
    mpc add "`sed -n "${i}p" .mpdnewlist_tmp`" > /dev/null
done
mpc play 1
mpc random off
rm .mpdnewlist_tmp

This is an older one I forgot to post in the first post. Update mpds DB and load all your songs:

 
#!/bin/bash
cd ~/music/
mpc crop
mpc update > /dev/null
while [ `mpc | grep Updating | wc -l` == 1 ]; do
        sleep 1
done
mpc clear
mpc ls | mpc add > /dev/null
mpc toggle

Have fun!

Cheers Sigi


Dammit, haven't been here in a while. Still rocking Arch. smile

Offline

#4 2008-03-13 19:47:13

danielsoft
Member
From: Czech Republic
Registered: 2008-02-16
Posts: 102

Re: Nice keybindings for MPD

hello, I started playing with mpc today -first time using it- and created this one called "mpcp":

#!/usr/bin/perl
@playlist=`mpc playlist`;
$arg=$ARGV[0];
for $p (@playlist)
{
 if($p =~ /(\d+)\).*$arg.*/)
  {
   system("mpc play $1");
   exit(0);
  }
}

"mpcp foo" will jump in the playlist -not modifying it- to song named/tagged "foo"


may the Source be with you

Offline

#5 2008-03-13 19:52:27

finferflu
Forum Fellow
From: Manchester, UK
Registered: 2007-06-21
Posts: 1,899
Website

Re: Nice keybindings for MPD

Not really keybindings:
* mpcplay
* mpcmenu.

No Ratpoison, no party, obviously tongue


Have you Syued today?
Free music for free people! | Earthlings

"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- A. de Saint-Exupery

Offline

#6 2008-03-13 20:11:35

fwojciec
Member
Registered: 2007-05-20
Posts: 1,411

Re: Nice keybindings for MPD

On my laptop I use MPD (normally) and mocp (when I have the external hd connected - I don't want to deal with mpd database in that case), but I also wanted to have a unified way of controlling music by means of keybindings.  This is a little script I've written:

#!/bin/sh

[ -f /home/filip/.moc/pid ] && [ -f /home/filip/.mpd/mpd.pid ] && echo "Both moc and mpd are running" && exit

case $1 in
    ne)
    [ -f /home/filip/.moc/pid ] && mocp -f
    [ -f /home/filip/.mpd/mpd.pid ] && mpc next
    ;;
    pr)
    [ -f /home/filip/.moc/pid ] && mocp -r
    [ -f /home/filip/.mpd/mpd.pid ] && mpc prev
    ;;
    st)
    [ -f /home/filip/.moc/pid ] && mocp -s
    [ -f /home/filip/.mpd/mpd.pid ] && mpc stop
    ;;
    pl)
    if [ -f /home/filip/.moc/pid ]; then
    state=`mocp -i | head -1 | sed 's/State: //g'`
    case $state in
        PLAY)
        mocp -G;;
        PAUSE)
        mocp -G;;
        STOP)
        mocp -p;;
        *)
        ;;
    esac
    fi 
    [ -f /home/filip/.mpd/mpd.pid ] && mpc toggle
    ;;
    *)
    ;;
esac

And then I have this in my ~/.config/openbox/rc.xml (keybindings section)

    <keybind key="W-Right">
      <action name="Execute">
        <command>music_control.sh ne</command>
      </action>
    </keybind>
    <keybind key="W-Left">
      <action name="Execute">
        <command>music_control.sh pr</command>
      </action>
    </keybind>
    <keybind key="W-Down">
      <action name="Execute">
        <command>music_control.sh st</command>
      </action>
    </keybind>
    <keybind key="W-Up">
      <action name="Execute">
        <command>music_control.sh pl</command>
      </action>
    </keybind>

Offline

#7 2008-08-07 15:32:29

nilsHaus
Member
Registered: 2007-06-22
Posts: 69

Re: Nice keybindings for MPD

Sorry to bump but how would I set these keybindings. I'm looking for a nice solution to setting my multimedia buttons to control volume. I can get keycodes via xev, but I'm not sure what I'd use to control mpd/mpc. Using Openbox, sole WM.

Offline

#8 2008-08-07 15:51:50

Sigi
Member
From: Thurgau, Switzerland
Registered: 2005-09-22
Posts: 1,121

Re: Nice keybindings for MPD


Dammit, haven't been here in a while. Still rocking Arch. smile

Offline

#9 2008-08-25 18:24:07

fresch
Member
Registered: 2008-08-06
Posts: 17

Re: Nice keybindings for MPD

hi

you might want to have a look at this post:
http://bbs.archlinux.org/viewtopic.php? … 74#p411574

I'm using a patched version of dmenu to display a vertical playlist for mpd
dmenuvd1.th.png

fresch

Offline

Board footer

Powered by FluxBB