-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbmm-launcher
executable file
·89 lines (81 loc) · 2.76 KB
/
bmm-launcher
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
#!/bin/bash
# This is a launcher (main menu) for all
# scripts that manage the media center files.
# Tarso Galvao 05/04/23 Debian 11
## load environment variables
if [ -f $HOME/bmm/.env ]; then
. $HOME/bmm/.env
else
echo 'BASH MEDIA MANAGER'
echo 'No enviromento found! Entering setup...' && sleep 2
clear && eval $HOME/bmm/bmm-setup_enviroment
exit 0
fi
## Main Menu (--no-gui)
nogui_menu() {
clear
echo -e "${HEAD}BASH MEDIA MANAGER - Launcher${NC}"
echo "--------------------------------"
echo "1. Convert Audio files to MP3"
echo "2. Convert Video files to MP4"
echo "3. Remove Empty Audio Folders"
echo "4. Media Backup Manager"
echo "5. Fix Media Permissions"
echo "6. Easily Share Media"
echo "7. Setup Environment Variables"
echo "8. Quit to shell"
echo "--------------------------------"
read -p "$Enter your choice (1-8): " choice
case $choice in
1) eval "bmm-converter_mp3 --no-gui" ;;
2) eval "bmm-converter_mp4" ;;
3) eval "bmm-dir_cleaner" ;;
4) eval "bmm-media_backup --no-gui" ;;
5) eval "bmm-media_permissions" ;;
6) eval "bmm-media_share" ;;
7) eval "bmm-setup_enviroment" ;;
8) clear && exit 0 ;;
*)
echo -e "${ERROR}Invalid choice.${WARN} Please enter a valid option (1-8).${NC}"
sleep 2
;;
esac
nogui_menu
}
## Main Menu (no args)
main_menu() {
menu_opt=$(dialog --colors --no-cancel --no-lines --title 'Script-Launcher Menu' \
--backtitle "\Z7Bash Media Manager" \
--stdout \
--menu ' Up and down arrows change selection.\n Use the Enter key to confirm.' \
0 0 0 \
'converter_mp3' 'Converts Audio files to MP3' \
'converter_mp4' 'Converts Video files to MP4' \
'dir_cleaner' 'Removes Empty Audio Folders' \
'media_backup' 'Media Backup Manager' \
'media_permissions' 'Fix Media Permissions' \
'media_share' 'Easily Share Media' \
'setup_enviroment' 'Setup Enviroment Variables' \
'quit' 'Quit to shell')
# Exit on Quit or Cancel || Execute chosen script.
if [ $menu_opt = 'quit' ] || [ $? -ne 1 ]; then
clear && exit 0
else
clear && eval bmm-$menu_opt
exit 0
fi
}
# START ARGS
if [ "$1" = '--no-gui' ] || [ "$1" = '-n' ]; then
nogui_menu
elif [ "$1" = '--help' ] || [ "$1" = '-h' ]; then
if ! command -v $BANNER >>/dev/null; then echo -e "${WARN}BASH MEDIA MANAGER${NC}"; else eval $BANNER; fi
echo -e "${HEAD}BMM Launcher${NC}"
echo -e "Use with no arguements to enter the GUI menu."
echo -e "Usage: bmm-launcher [-arg] [--arg]\n"
echo -e " -n [--no-gui] -> CLI interactive mode."
echo -e " -h [--help] -> This message screen."
exit 1
else
main_menu
fi