-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkava
More file actions
executable file
·142 lines (129 loc) · 4.54 KB
/
Copy pathkava
File metadata and controls
executable file
·142 lines (129 loc) · 4.54 KB
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/bin/bash
source $HOME/.config/kava/config
index_adv () {
if ((index < ( nelem - 1 ))); then
((index++))
else
index=0
fi
}
inarray() { local n=$1 h; shift; for h; do [[ $n = "$h" ]] && return; done; return 1; }
wallpaper () {
echo "Cover for \""$(mpc current -f "%$artist% - %album%")"\" found, setting wallpaper..."
cp cover.png /tmp/cover.png
mogrify -resize "$size" -bordercolor snow -background black +polaroid /tmp/cover.png
convert -size "$res" "$image_temp" -page ${coordinates[$index]} /tmp/cover.png -layers flatten "$wallpaper"
feh --bg-scale "$wallpaper"
cp "$wallpaper" "$image_temp"
}
main () {
local index=0
local nelem="${#coordinates[@]}"
feh --bg-scale "$image"
cp "$image" $HOME/.config/kava/wally_temp.jpg
image_temp="$HOME/.config/kava/wally_temp.jpg"
while true; do
if [[ $stopped == true ]]; then
export current="$current"
export stopped=false
else
current="$(mpc current --format "%$artist% - %album%")"
fi
if [[ "$artist" == "albumartist" ]]; then
found=0; for i in "${various[@]}"; do
if [[ $i = "$(mpc current --format %"$artist"%)" ]]; then
export current="Various Artists - $(mpc current --format %album%)"; export VA=true; break; fi; done
# inarray "$(mpc current --format %"$artist"%)" "${array[@]}"
fi
mpc idle player>/dev/null 2>&1
sleep 1
if [[ -z $(mpc current) ]]; then
export stopped=true
elif [[ $(mpc current --format "%$artist% - %album%") != "$current" ]]; then
dir="$(dirname "$(mpc current --format %file%)")"
cd "$mpdpath"/"$dir"
if [[ -a cover.png ]]; then
wallpaper
index_adv
elif [[ -a folder.jpg ]]; then
rm -f folder.jpg
echo "Cover for \""$(mpc current -f "%$artist% - %album%")"\" not found, trying to download..."
getCover
elif [[ -a cover.jpg ]]; then
convert cover.jpg cover.png
rm -f cover.jpg
wallpaper
index_adv
else
echo "Cover for \""$(mpc current -f "%$artist% - %album%")"\" not found, trying to download..."
getCover
fi
fi
done
}
getCover () {
if [[ $1 == "noset" ]]; then
if [[ $VA == true ]]; then
cover=$(get-cover "Various Artists" "$(mpc current -f %album%)")
else
cover=$(get-cover "$(mpc current -f %"$artist"%)" "$(mpc current -f %album%)")
fi
cd "$mpdpath"/"$dir"
if [[ $cover == "Fetch error." ]]; then
echo "...could not download cover for \""$(mpc current -f "%$artist% - %album%")"\", skipping..."
else
echo "...found cover, saving"
wget "$cover" -O cover>/dev/null 2>&1
fi
if [[ $(file --mime-type cover | awk '{ print $NF }') == "image/png" ]]; then
mv cover cover.png
elif [[ $(file --mime-type cover | awk '{ print $NF }') == "image/jpeg" ]]; then
mv cover cover.jpg
fi
else
if [[ $VA == true ]]; then
cover=$(get-cover "Various Artists" "$(mpc current -f %album%)")
else
cover=$(get-cover "$(mpc current -f %"$artist"%)" "$(mpc current -f %album%)")
fi
cd "$mpdpath"/"$dir"
if [[ $cover != "Fetch error." ]]; then
wget "$cover" -O cover>/dev/null 2>&1
fi
if [[ $(file --mime-type cover | awk '{ print $NF }') == "image/png" ]]; then
mv cover cover.png
wallpaper
index_adv
elif [[ $(file --mime-type cover | awk '{ print $NF }') == "image/jpeg" ]]; then
mv cover cover.jpg
convert cover.jpg cover.png
rm -f cover.jpg
wallpaper
index_adv
fi
fi
}
reset () {
if [[ -z $(mpc current) ]]; then
echo "No song playing, skipping"
else
dir="$(dirname "$(mpc current --format %file%)")"
cd "$mpdpath"/"$dir"
rm -f folder.jpg
mv cover.png cover.png.bak>/dev/null 2>&1
mv cover.jpg cover.jpg.bak>/dev/null 2>&1
getCover noset
if [[ -a cover.png || cover.jpg ]]; then
rm -f cover.png.bak
rm -f cover.jpg.bak
else
mv cover.png.bak cover.png
mv cover.jpg.bak cover.jpg
fi
fi
}
if [[ $1 == reset ]]; then
reset
else
main
fi