guest@dotshare [~/groups/info/dzen2] $ ls mpd-notif/ | cat

mpd notif (scrot)

hokagemadura Jul 31, 2013 (info/dzen2)

albumart.py(raw, dl)

SCROT

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import os
import shutil
import commands
import urllib

# Path where the images are saved
imgpath = "/home/hokage/.config/ario/covers/"

# Path where 'artist-only' images can be found
artistimgpath = "/home/hokage/.config/ario/covers/"

# Image displayed when no image found
noimg = "/home/hokage/.config/airo/nocover.jpg"

# Cover displayed by conky
cover = "/tmp/cover.jpg"

def copycover(currentalbum, src, artistsrc, dest, defaultfile):
    searchstring = currentalbum.replace(" ", "+")
    if not os.path.exists(src):
        url = "http://www.albumart.org/index.php?srchkey=" + searchstring + "&itempage=1&newsearch=1&searchindex=Music"
        cover = urllib.urlopen(url).read()
        image = ""
        for line in cover.split("\n"):
            if "http://www.albumart.org/images/zoom-icon.jpg" in line:
                image = line.partition('src="')[2].partition('"')[0]
                break
        if image:
            urllib.urlretrieve(image, src)
    if os.path.exists(src):
        shutil.copy(src, dest)
    elif os.path.exists(artistsrc):
        shutil.copy(artistsrc, dest)
    elif os.path.exists(defaultfile):
        shutil.copy(defaultfile, dest)
    else:
        print ""

# Name of current album
album = commands.getoutput("mpc --format %artist%-%album% | head -n 1")
artist = commands.getoutput("mpc --format %artist% | head -n 1")

# If tags are empty, use noimg.
# Hieronder stond steeds conkycover ipv cover, heb ik gewijzigd.
if album == "":
    if os.path.exists(cover):
        os.remove(cover)
    if os.path.exists(noimg):
        shutil.copy(noimg, cover)
    else:
        print ""
else:
    filename = imgpath + album + ".jpg"
    artistfilename = artistimgpath + artist + ".jpg"
    if os.path.exists("/tmp/nowplaying") and os.path.exists("/tmp/cover.jpg"):
        nowplaying = open("/tmp/nowplaying").read()
        if nowplaying == album:
            pass
        else:
            copycover(album, filename, artistfilename, cover, noimg)
            open("/tmp/nowplaying", "w").write(album)
    else:
        copycover(album, filename, artistfilename, cover, noimg)
        open("/tmp/nowplaying", "w").write(album)

CLICK TO VIEW

x

.conkyrc(raw, dl)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
alignment top_left
gap_x 783
gap_y 27
update_interval 0.1
no_buffers yes
double_buffers yes
#maximum_width 1024
imlib_cache_size 0
total_run_times 0
own_window_type desktop

TEXT
${if_mpd_playing}
${execi 1 python2 albumart.py}${image /tmp/cover.jpg -s 87x87}
$endif
 

x

dzenmpd.sh(raw, dl)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
#! /bin/sh

position(){
pos=$(mpc | awk 'NR==2' | awk '{print $4}' | sed 's/(//' | sed 's/%)//')
bar=$(echo $pos | gdbar -w 190 -h 1.5 -fg "#FF3D00" -bg "#821D00")
echo -n "$bar"
return
}

font="M+ 1c-7"
icon="/home/hokage/.icons/xbm8x8"

while :; do
echo "   $(mpc current -f %artist%)
   $(mpc current -f %title%) 
   $(mpc current -f %album%)

^p(65)^ca(1,mpc prev)^i($icon/prev.xbm)^ca()   ^ca(1,mpc toggle)^i($icon/play.xbm)^ca()   ^ca(1,mpc stop)^i($icon/stop.xbm)^ca()   ^ca(1,mpc next)^i($icon/next.xbm)^ca()
$(position)" 
done | dzen2 -p -y 25 -x 883 -l 5 -u -w 190 -ta l -fn "$font" -e 'onstart=uncollapse;key_Escape=ungrabkeys,exit'
 

x

launcher.sh(raw, dl)

1
2
3
4
#! /bin/sh

sh ~/scripts/dzenmpd.sh &
conky
 

x