-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlyrics
executable file
·41 lines (38 loc) · 1.01 KB
/
lyrics
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
#!/bin/bash
# Edgar Uriel Domínguez Espinoza
# This is a small script is useful with MoC and clyrics (https://github.com/trizen/clyrics)
# is needed for get lyrics from Internet. In fact clyrics could be enough for you
help() {
echo "Show lyrics on console"
echo "lyrics [OPCIONS]"
echo "Opcions:"
echo "-a <ARTIST>"
echo "-t <TITLE>"
echo "-d <DIR>"
exit 0
}
# Begin Script
ARTIST=`mocp -i | awk '/^Artist:/ { $1=""; print $0 }' | sed -e 's/^ *//g' -e 's/ *$//g'`
TITLE=`mocp -i | awk '/^SongTitle:/ { $1=""; print $0 }' | sed -e 's/^ *//g' -e 's/ *$//g'`
DIR="$HOME/.lyrics"
if [[ $1 == "-h" ]]; then
help
else
while getopts a:t:d: option
do
case "${option}" in
a) ARTIST=${OPTARG} ;;
t) TITLE=${OPTARG} ;;
d) DIR=${OPTARG} ;;
esac
done
FILE="$DIR/$ARTIST - $TITLE.txt"
if [[ -f "$FILE" ]]; then
exec $PAGER "$FILE"
else
exec clyrics "$ARTIST" "$TITLE" | "$PAGER"
fi
exit 0
fi
# End Script