-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbashparty.sh
executable file
·82 lines (74 loc) · 2.87 KB
/
bashparty.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
# Stops the process system/com.apple.audio.coreaudiod upon EXIT (ctrl+c termination)
stop_music () {
kill 0
}
trap stop_music EXIT
warning() {
echo "you didn't pass proper arguments"
}
# Prepare songs from ./songs in an indexed array
SONGS=()
for file in ./songs/*; do
SONGS+=("$(basename "$file")")
done
NUM_SONGS=${#SONGS[*]}
# Select a song by it's index, randomize or colorize
export INDEX=0
export COLOR=false
export TEXT=""
while [ $# -gt 0 ]; do
case $1 in
--index) shift
INDEX=$1
;;
--random) ((lastSong = NUM_SONGS - 1))
INDEX=`shuf -i 0-${lastSong} -n 1`
;;
--color) COLOR=true
;;
--text) shift
TEXT=$1
;;
* ) warning
exit
esac
shift
done
play_music() {
SONG_NAME="${SONGS[INDEX]}"
afplay "./songs/$SONG_NAME" &>/dev/null &
}
setColor() {
if [ "$COLOR" = true ]
then
randomColor=`shuf -i 0-7 -n 1`
tput setaf $randomColor
fi
}
strobe_light() {
while true; do
clear
setColor
text
text
text
text
sleep 0.05
clear
sleep 0.05
done
}
text() {
echo '███████╗███████╗███╗ ██╗████████╗██████╗ ██╗ ██╗██╗ ██████╗
██╔════╝██╔════╝████╗ ██║╚══██╔══╝██╔══██╗╚██╗ ██╔╝██║██╔═══██╗
███████╗█████╗ ██╔██╗ ██║ ██║ ██████╔╝ ╚████╔╝ ██║██║ ██║
╚════██║██╔══╝ ██║╚██╗██║ ██║ ██╔══██╗ ╚██╔╝ ██║██║ ██║
███████║███████╗██║ ╚████║ ██║ ██║ ██║ ██║██╗██║╚██████╔╝
╚══════╝╚══════╝╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝╚═╝╚═╝ ╚═════╝'
echo ''
}
run() {
play_music
strobe_light
}
run