-
Notifications
You must be signed in to change notification settings - Fork 0
/
radio-dashboard.sh
executable file
·93 lines (85 loc) · 2.65 KB
/
radio-dashboard.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
#!/bin/bash
# INFO: you can customize radio player as you wish i wrote my name with ascii here
# Function to display the menu
display_menu() {
clear
echo "
┌─┐┌─┐┬┌─┌─┐┬ ┬┌┐ ┬ ┬┬─┐┬ ┬┌─┐
│ ┬│ │├┴┐├─┤└┬┘├┴┐│ │├┬┘│ ││
└─┘└─┘┴ ┴┴ ┴ ┴ └─┘└─┘┴└─└─┘└─┘
"
echo "================="
echo "
┬─┐┌─┐┌┬┐┬┌─┐ ┌─┐┬ ┌─┐┬ ┬┌─┐┬─┐
├┬┘├─┤ ││││ │ ├─┘│ ├─┤└┬┘├┤ ├┬┘
┴└─┴ ┴─┴┘┴└─┘ ┴ ┴─┘┴ ┴ ┴ └─┘┴└─
"
echo "=== Dashboard ==="
echo "1. Add a new station"
echo "2. Remove a station"
echo "3. View all stations"
echo "4. Listen Radio"
echo "5. Exit"
echo "================="
}
# Function to add a new station
add_station() {
echo "=== Add a new station ==="
echo "Enter the station name:"
read station_name
echo "Enter the station URL:"
read station_url
echo "$station_name,$station_url" >> ./src/radyodelisi.csv
echo "Station added successfully!"
read -n 1 -s -r -p "Press any key to continue..."
}
# FIX: remove stati
remove_station() {
selected_line=$(cat ./src/radyodelisi.csv | fzf --reverse)
filtered_output=$(grep -vF "$selected_line" ./src/radyodelisi.csv)
echo "$filtered_output" > ./src/radyodelisi.csv
echo "Station removed successfully!"
read -n 1 -s -r -p "Press any key to continue..."
}
# TODO: add listener here
listen_radio(){
selected_station=$(awk -F ',' '{ print $1 }' ./src/radyodelisi.csv | fzf --prompt="Select a radio station: ")
if [ -n "$selected_station" ]; then
station=$(awk -F ',' -v station="$selected_station" '$1 == station { print $2 }' ./src/radyodelisi.csv)
mpv "$station"
fi
}
# Function to view all stations
view_stations() {
echo "=== All Stations ==="
cat ./src/radyodelisi.csv
read -n 1 -s -r -p "Press any key to continue..."
}
# Main loop
while true; do
display_menu
read -p "Enter your choice: " choice
case $choice in
1)
add_station
;;
2)
remove_station
;;
3)
view_stations
;;
# FIX: add listener as option
4)
listen_radio
;;
5)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid choice. Please enter a valid option."
read -n 1 -s -r -p "Press any key to continue..."
;;
esac
done