-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathterminal_covers_old.sh
executable file
·97 lines (81 loc) · 2.25 KB
/
terminal_covers_old.sh
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/bash
# bc for calculation
# curl for unsplash images
# requires mpc to get song info
# Snagged mpc-based looping from http://www.hackerposse.com/~rozzin/mpdjay
########### Configuration
# TODO: Sane defaults and autodetect
MUSICDIR=~/music
TMPDIR=~/tmp
########### Render Options
# aview
# img2text https://github.com/hit9/img2txt
# w3mimage - TODO
# asciiart
# wmctrl
function get_album_art {
echo "### Finding cover for $ALBUM..."
coverart1="$SONGDIR"
#coverart1=$MUSICDIR/"$ALBUM"/"$ARTIST"
# trimming characters that jack it up...
coverart1=$(echo "$coverart1"| sed s/[:.]//g)
# getting lowercase and removing final slash
coverart="${coverart1,,}"
coverart="${coverart%/}"
if [ -f "$coverart/cover.jpg" ]; then
COVERART="$coverart/cover.jpg"
elif [ -f "$SONGDIR/folder.jpg" ]; then
COVERART="$coverart/folder.jpg"
else
curl -s https://unsplash.it/512/512/?random -o $TMPDIR/unsplash.jpg
convert $TMPDIR/unsplash.jpg -blur 0x3 $TMPDIR/unsplash_blur.jpg
COVERART="$TMPDIR/unsplash_blur.jpg"
fi
}
function show_album_art {
if [ ! -f "$COVERART" ]; then
echo "### Something's horribly wrong"
else
clear
#in case not automatically listed
cols=$(tput cols)
lines=$(tput lines)
if [ "$cols" -gt "$lines" ]; then
gvalue="$cols"
lvalue="$lines"
else
gvalue="$lines"
lvalue="$cols"
fi
bvalue=$(echo "scale=4; $gvalue-3" | bc)
if [ "$bvalue" -gt 78 ];then
bvalue=78
fi
########SELECT WHICH VIEWER YOU WISH TO USE HERE
img2txt.py --ansi --targetAspect=0.5 --maxLen="$bvalue" "$COVERART"
#asciiart -c -w "$bvalue" "$COVERART"
#killall aview;anytopnm "$COVERART" | aview -driver curses &
snark=$(echo $WINDOWID)
wmctrl -i -r "$snark" -T "$DataString"
fi
}
# Here's the main loop
(echo qman-startup; mpc idleloop player) \
| while read event
do
DataString=$(mpc --format "[[%artist% - ]%title%[ - %album%]"| head -1)
ARTIST=$(mpc --format %artist% | head -1)
ALBUM=$(mpc --format %album% | head -1)
SONGFILE=$(mpc --format %file% | head -1)
SONGFILE=$MUSICDIR/"$SONGFILE"
SONGDIR=$(dirname "$SONGFILE")
if [ -f "$SONGFILE" ]; then
echo "Getting info for $ARTIST and $ALBUM"
get_album_art
show_album_art
else
echo "We're getting wrong information for some reason."
fi
done
fi
clear