-
Notifications
You must be signed in to change notification settings - Fork 2
/
cover
executable file
·76 lines (62 loc) · 1.85 KB
/
cover
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
#!/bin/fish
#
# cover - A small script to easily resize and view album art
# onodera, https://github.com/onodera-punpun
## CONFIGURATION
# Set music dir location
set musicdir $HOME/media/music
# Set cover size
set size 128x128
# Set highlight color
set highlight yellow
## EXECUTE
if test (count $argv) -eq 1
switch $argv
case -h --help
echo -e 'Usage: cover [options]\n'
echo 'options:'
echo ' -a, --all resize all covers'
echo ' -c, --current resize current playing album cover'
echo ' -h, --help print help and exit'
exit 0
case -a --all
set covers (find $musicdir -type f -name 'cover.*' | sort)
set all (count $covers)
set current 0
# TODO: Fix blank line after read
read -n 1 -p 'echo "Do you want to resize $all covers to $size? [y/N] "' answer
switch $answer
case Y y
for cover in $covers
set current (math $current + 1)
set path (string split '/' $cover)
echo "Resizing cover $current/$all, "(set_color $highlight)"$path[-2]"(set_color normal)"."
convert $cover -filter Lanczos -thumbnail $size! (string replace -r 'cover.(jpg|png|gif)' 'cover_popup.png' $cover)
if test $status -ge 1
exit 1
end
end
case '*'
exit 0
end
case -c --current
set path (mpc -f '%file%' | cut -d \n -f 1 | rev | cut -d / -f 2- | rev)
convert $musicdir/$path/cover.* -filter Lanczos -thumbnail $size! $musicdir/$path/cover_popup.png >/dev/null
if test $status -eq 0
echo 'Cover resized successfully.'
else
echo 'This album doesn\'t have a cover.'
exit 1
end
case '*'
echo 'Invalid option, use -h for help.'
exit 1
end
else
set path (mpc -f \%file\% | cut -d \n -f 1 | rev | cut -d / -f 2- | rev)
pqiv $musicdir/$path/cover.*
if test $status -ge 1
echo 'This album doesn\'t have a cover.'
exit 1
end
end