You are not logged in.

#1 2011-01-17 20:27:00

Maki
Member
From: Skopje, Macedonia
Registered: 2007-10-16
Posts: 353
Website

MPD's little helpers

I use MPD + ncmpcpp and its really awesome. I use mpdscribble for scrobbling to last.fm and mpd-sima for adding common songs in the playlists, and other tools like mpd-add-similar look nice (adding more than one song at a time.). What i miss now is a simple last.fm love track script or something, and a script that will copy the songs from a mpd playlist to a mp3 player. Anyone mind sharing such scripts or helping me make one ? smile, plus if you have any idea or a nice mpd tool write it here smile


If it ain't broke, broke it then fix it.

Offline

#2 2011-01-17 22:28:40

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: MPD's little helpers

Maki wrote:

I use MPD + ncmpcpp and its really awesome. I use mpdscribble for scrobbling to last.fm and mpd-sima for adding common songs in the playlists, and other tools like mpd-add-similar look nice (adding more than one song at a time.). What i miss now is a simple last.fm love track script or something, and a script that will copy the songs from a mpd playlist to a mp3 player. Anyone mind sharing such scripts or helping me make one ? smile, plus if you have any idea or a nice mpd tool write it here smile

loving a track:
http://aur.archlinux.org/packages.php?ID=41508

how I use it:

> cat love                     
#!/bin/bash
~/bin/lastfm-mpd-cli.py love --lastfmusername=USER --lastfmpassword=MD5SUM_OF_PASSWORD && echo "You loved `mpc current`" | dzen2 -y 1062 -p 4 -fn envy-code-r-10 -fg '#00BBFF' -bg '#080808'

just put ~/bin/love to some hotkey - voila

Last edited by Rasi (2011-01-17 22:36:45)


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#3 2011-01-17 22:33:05

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,914
Website

Re: MPD's little helpers

very handy tool to execute scripts/binary/whatever on certain mpd actions:

http://aur.archlinux.org/packages.php?ID=32890

how to use it:

cat .mpdcron/hooks/player
# Example player hook.
hooks/dump-status.bash
hooks/dump-song.bash
hooks/playing.sh
> cat playing.sh 
echo "$MPD_SONG_TAG_ARTIST - $MPD_SONG_TAG_TITLE  [#$MPD_SONG_TAG_TRACK $MPD_SONG_TAG_ALBUM]" | dzen2 -y 1062 -p 4 -fn 'envy code r-10' -fg '#00BBFF' -bg '#080808'

start mpdcron as user and now on every stop/play/pause it will show current track. i have simlar scripts for showing if i changed options like random mode etc...


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#4 2011-01-17 23:54:23

owain
Member
Registered: 2009-08-24
Posts: 251

Re: MPD's little helpers

I wanted notifications of track changes, but only when I had ncmpcpp open, so added an execute_on_song_change entry in ~/.ncmpcpp/config calling this:

#!/bin/sh

ARTIST=`mpc -f "%artist%" current | sed -e s/"&"/"&"/`
ALBUM=`mpc -f "%album%" current | sed -e s/"&"/"&"/`
TITLE=`mpc -f "%title%" current`


if [ "$ARTIST" != "" ] && [ "$ALBUM" != "" ]
    then
        LINETWO="
<b>"$ARTIST"

"$ALBUM"</b>"


elif [ "$ARTIST" != "" ] && [ "$ALBUM" == ""  ]
    then
        LINETWO="<b>"$ARTIST"</b>"


elif [ "$ARTIST" == "" ] && [ "$ALBUM" != ""  ]
    then
        LINETWO="<b>"$ALBUM"</b>"

else
        LINETWO=""
fi


notify-send "$TITLE" "$LINETWO" -u low -t 3000 -h int:x:875 -h int:y:25 -i /usr/share/icons/elementary/emblems/48/emblem-sound.svg -h string:synchronous:mpd

It's ugly coding, I know, but it gets things how I want them in terms of layout, creating three lines (title/artist/album) when necessary within the two 'lines' as notify-send sees them.  The sed commands deal with a problem with ampersands in the second entry of the notify-send signal, which may deserve a bug report there or elsewhere, if I pin down the issue.  Screenshot.

Edit: removing a superfluououos necessary...

Last edited by owain (2011-01-18 01:59:06)

Offline

#5 2011-01-18 01:57:04

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: MPD's little helpers

Another version of the "notify on track change" script:

#!/bin/bash
# vim:set filetype=sh: *

setsid /usr/bin/mpc idleloop player |\

while read ; do
        currtrack="$(/usr/bin/mpc -f '%file%' current)"

        if [[ "$currtrack" != "$prevtrack" ]] ; then
                /usr/bin/mpc -f '%title%' current |\
                /usr/bin/osd_cat -p bottom -f 10x20 -c white -s 1

                [[ $? -ne 0 ]] && exit 2

                prevtrack="$currtrack"
        fi
done &

Offline

#6 2011-01-18 02:34:09

Maki
Member
From: Skopje, Macedonia
Registered: 2007-10-16
Posts: 353
Website

Re: MPD's little helpers

Rasi wrote:
Maki wrote:

I use MPD + ncmpcpp and its really awesome. I use mpdscribble for scrobbling to last.fm and mpd-sima for adding common songs in the playlists, and other tools like mpd-add-similar look nice (adding more than one song at a time.). What i miss now is a simple last.fm love track script or something, and a script that will copy the songs from a mpd playlist to a mp3 player. Anyone mind sharing such scripts or helping me make one ? smile, plus if you have any idea or a nice mpd tool write it here smile

loving a track:
http://aur.archlinux.org/packages.php?ID=41508

how I use it:

> cat love                     
#!/bin/bash
~/bin/lastfm-mpd-cli.py love --lastfmusername=USER --lastfmpassword=MD5SUM_OF_PASSWORD && echo "You loved `mpc current`" | dzen2 -y 1062 -p 4 -fn envy-code-r-10 -fg '#00BBFF' -bg '#080808'

just put ~/bin/love to some hotkey - voila

thanks alot smile,  it works as a charm.


If it ain't broke, broke it then fix it.

Offline

#7 2011-01-18 04:59:05

Maki
Member
From: Skopje, Macedonia
Registered: 2007-10-16
Posts: 353
Website

Re: MPD's little helpers

A great guy over at #archlinux has created this script for copying stuff to mp3/folder smile

http://paste.pocoo.org/raw/322532/

All thanks goes to e36freak


If it ain't broke, broke it then fix it.

Offline

Board footer

Powered by FluxBB