-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall-musescore4.sh
More file actions
executable file
·154 lines (120 loc) · 4.21 KB
/
Copy pathinstall-musescore4.sh
File metadata and controls
executable file
·154 lines (120 loc) · 4.21 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/bash
# --- User Provided URLs ---
MSS_URL="https://github.com/musescore/MuseScore/releases/download/v4.6.0/MuseScore-Studio-4.6.0.252730944-x86_64.AppImage"
MSM_URL="https://muse-cdn.com/Muse_Sounds_Manager_x64.deb"
# --- Derived Variables ---
MSS_FILENAME="${MSS_URL##*/}"
MSM_FILENAME="${MSM_URL##*/}"
# Extract version from MSS_URL
MSS_VERSION=$(echo "$MSS_FILENAME" | grep -oP 'MuseScore-Studio-\K\d+\.\d+\.\d+')
# --- External Functions ---
source lib/notify_lib.sh
source lib/check_libfuse.sh
# --- Functions ---
show_help() {
cat <<EOF
Usage: $0 [OPTIONS]
Install Options:
-m Install MuseScore Studio
-s Install Muse Sounds Manager
-a Install all components (both)
Uninstall Options:
-M Uninstall MuseScore Studio
-S Uninstall Muse Sounds Manager
-A Uninstall all components (both)
-h Show this help message
EOF
exit 0
}
confirm_action() {
local message="$1"
read -rp "⚠️ ${message} Continue? [y/N] " confirm
[[ "${confirm,,}" == "y" ]] || return 1
return 0
}
install_ms_studio() {
check_libfuse || return 1
local installed_file
installed_file=$(ls -1 ~/.local/bin/MuseScore-Studio-*.AppImage 2>/dev/null | head -n1)
if [[ -n "$installed_file" ]]; then
local installed_version
installed_version=$(basename "$installed_file" | grep -oP 'MuseScore-Studio-\K\d+\.\d+\.\d+')
if [[ "$installed_version" == "$MSS_VERSION" ]]; then
notify "MuseScore Studio ${MSS_VERSION} is already installed. Skipping." "success"
return 0
else
notify "Different version (${installed_version}) detected. Replacing with ${MSS_VERSION}." "warning"
uninstall_ms_studio
fi
fi
notify "Installing MuseScore Studio ${MSS_VERSION}" "heading"
if [[ -f "${MSS_FILENAME}" ]]; then
echo "Found existing: ${MSS_FILENAME}"
else
wget "${MSS_URL}" || notify "Download failed" "error"
fi
chmod +x "${MSS_FILENAME}"
"./${MSS_FILENAME}" install || notify "Installation failed" "error"
notify "MuseScore Studio ${MSS_VERSION} installed successfully" "success"
}
install_ms_sounds() {
notify "Installing Muse Sounds Manager"
if [[ -f "${MSM_FILENAME}" ]]; then
echo "Found existing: ${MSM_FILENAME}"
else
wget -O "${MSM_FILENAME}" "${MSM_URL}" || notify "Download failed" "error"
fi
sudo apt install "./${MSM_FILENAME}" -y
rm -f "${MSM_FILENAME}"
notify "Muse Sounds Manager installed succesfully" "success"
}
uninstall_ms_studio() {
confirm_action "This will uninstall MuseScore Studio." || return
notify "Uninstalling MuseScore Studio" "heading"
# Remove any AppImage and symlinks
rm -f ~/.local/bin/MuseScore-Studio-*.AppImage
rm -f ~/.local/bin/{mscore4portable,musescore4portable}
# Remove desktop file
local desktop_file="${HOME}/.local/share/applications/org.musescore.MuseScore4portable.desktop"
[ -f "${desktop_file}" ] && rm -f "${desktop_file}"
# Remove icon files
local icon_dir="${HOME}/.local/share/icons/hicolor"
if [ -d "${icon_dir}" ]; then
find "${icon_dir}" -type f -name "mscore4portable.png" -delete
find "${icon_dir}" -type f -path "*/mimetypes/*" -name "*musescore4portable*" -delete
fi
# Remove MIME files related to MuseScore
local mime_base="${HOME}/.local/share/mime"
for dir in application x-scheme-handler packages; do
if [ -d "${mime_base}/${dir}" ]; then
find "${mime_base}/${dir}" -type f -iname "*musescore*" -delete
fi
done
update-mime-database "${mime_base}" >/dev/null 2>&1
notify "MuseScore Studio completely removed" "success"
}
uninstall_ms_sounds() {
confirm_action "This will uninstall Muse Sounds Manager." || return
notify "Uninstalling Muse Sounds"
sudo apt purge -y muse-sounds-manager
notify "Muse Sounds removed" "success"
}
# --- Main Logic ---
main() {
# If no arguments provided
[[ $# -eq 0 ]] && show_help
while getopts ":msaMSAh" opt; do
case "${opt}" in
m) install_ms_studio ;;
s) install_ms_sounds ;;
a) install_ms_studio; install_ms_sounds ;;
M) uninstall_ms_studio ;;
S) uninstall_ms_sounds ;;
A) uninstall_ms_studio; uninstall_ms_sounds ;;
h) show_help ;;
*) echo "Invalid option: -${OPTARG}"; show_help; exit 1 ;;
esac
done
}
# --- Entry Point ---
main "$@"