Skip to content

Instantly share code, notes, and snippets.

@autumn-mck
Last active November 6, 2025 21:39
Show Gist options
  • Select an option

  • Save autumn-mck/6d7fcbbc08f5d18be09f2cc219084675 to your computer and use it in GitHub Desktop.

Select an option

Save autumn-mck/6d7fcbbc08f5d18be09f2cc219084675 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# SPDX-License-Identifier: Beerware
# Script to automate downloading and installing the latest version of MusicBee
# If anything goes wrong/breaks, let me know so I can fix it!
set -eu
export WINEPREFIX="${XDG_DATA_HOME:-$HOME/.local/share}/wineprefixes/MusicBee"
installation_location="$WINEPREFIX/drive_c/Program Files (x86)/MusicBee/"
# the official download mirror links from MajorGeeks
mb_url_1="https://www.majorgeeks.com/mg/getmirror/musicbee,1.html"
mb_url_2="https://www.majorgeeks.com/index.php?ct=files&action=download&="
# for AAC (.m4a) support
# https://getmusicbee.com/forum/index.php?topic=23454.0
bass_aac_download_url="https://www.un4seen.com/files/z/2/bass_aac24.zip"
# for MPRIS support (optional, only enabled if --mpris is given)
mprisbee_bridge_url="https://github.com/Kyletsit/mprisbee-bridge/releases/download/0.3/mprisbee-bridge.zip"
mprisbee_plugin_url="https://github.com/Kyletsit/mb_MPRISBee/releases/download/0.2/mb_MPRISBee.zip"
export WINEDLLOVERRIDES="mscoree,mshtml=" # we don't need wine-mono installed, no need to give a warning over it. https://bugs.winehq.org/show_bug.cgi?id=47316#c4
export WINEDEBUG="-all" # don't print any debugging messages for wine
app_dir="${XDG_DATA_HOME:-$HOME/.local/share}/applications"
icon_dir="${XDG_DATA_HOME:-$HOME/.local/share}/icons/hicolor/256x256/apps"
# check requirements
require() {
command -v "$1" >/dev/null 2>&1 || {
printf "\n\nError: %s is not installed.\n" "$1" >&2
printf "\nPlease install it from your distro's repositories and try again." >&2
printf "\nNote: The package may be named differently than the command.\n" >&2
exit 1
}
}
for cmd in wine winetricks curl unzip xdg-icon-resource desktop-file-install; do
require "$cmd"
done
# parse arguments
mpris=false
for arg in "$@"; do
case "$arg" in
--mpris)
mpris=true
;;
esac
done
cleanup() {
rm -f "$mb_temp_file" "$cookie_temp_file" 2>/dev/null || true
rm -f "$installation_location"/bass_aac.zip "$installation_location"/Plugins/mb_MPRISBee.zip 2>/dev/null || true
}
trap cleanup EXIT HUP INT TERM
mb_temp_file=$(mktemp --tmpdir MusicBee-XXXXXX.exe)
cookie_temp_file=$(mktemp --tmpdir MG_MB_cookie_XXXXXX.txt)
printf "\nSetting up wine prefix (this will take a while)"
printf "Warnings about using a 64-bit prefix and using wow64 mode are expected and can be safely ignored.\n"
# unset display to prevent it displaying the "The wine configuration in ... is being updated, please wait" message
DISPLAY="" WAYLAND_DISPLAY="" winetricks --unattended dotnet48 xmllite gdiplus cjkfonts wmp11
winetricks --unattended windowmanagerdecorated=n
printf "\nDownloading and extracting MusicBee installer\n"
curl -fsSc "$cookie_temp_file" "$mb_url_1" >/dev/null # initial request to get the cookie, as if we were downloading through a browser
curl -fsSL -b "$cookie_temp_file" "$mb_url_2" | funzip > "$mb_temp_file" # download the zip file containing the installer, pipe it through funzip to unzip it, and write it to the temp file
printf "\nInstalling MusicBee\n"
# I've not dug into what the installer is packaged by, but it supports /S for a silent install
wine "$mb_temp_file" "/S"
cd "$installation_location"
printf "\nDownloading bass_aac to allow playing of AAC/M4A files\n"
curl -fsSL -o "./bass_aac.zip" "$bass_aac_download_url"
unzip -o bass_aac.zip bass_aac.dll
# install mprisbee-bridge
if [ "$mpris" = true ]; then
printf "\nInstalling mprisbee-bridge plugin\n"
curl -fsSL "$mprisbee_bridge_url" | funzip > "./mprisbee-bridge"
chmod +x ./mprisbee-bridge
(
cd "./Plugins"
curl -fsSL -o "./mb_MPRISBee.zip" "$mprisbee_plugin_url"
unzip -o mb_MPRISBee.zip
)
fi
# find the MusicBee icon and install it as an XDG icon (wine doesn't name icons consistently)
icon_path=$(find "$icon_dir" -type f -iname '*musicbee*.png' -print -quit)
xdg-icon-resource install "$icon_path" musicbee --context apps --size 256 --novendor
# launch script to reformat the given file path when trying to play a specific file from the file manager or wherever
cat > "./launch.sh" << EOL
#!/usr/bin/env sh
export WINEPREFIX="$WINEPREFIX"
installation_location="$installation_location"
file=\$(echo \$1 | tr '/' '\\\\') # Replace / with \\
if [ "$mpris" = true ]; then
"\$installation_location"/mprisbee-bridge &
bridge_pid=\$!
fi
wine "\$installation_location/MusicBee.exe" "/Play" "Z:\$file"
if [ "$mpris" = true ]; then
kill "\$bridge_pid" 2>/dev/null || true
wait "\$bridge_pid" 2>/dev/null
fi
EOL
chmod +x ./launch.sh
printf "\nInstalling XDG Desktop entry\n"
# a better XDG Desktop entry than the one generated by wine
# lists some supported mime types, and correctly categorises musicbee
cat > "./MusicBee.desktop" << EOL
[Desktop Entry]
Type=Application
Version=1.5
Name=MusicBee
Comment=The Ultimate Music Manager and Player
Icon=musicbee
Exec="$installation_location/launch.sh" "%f"
MimeType=audio/mp4;audio/mpeg;audio/aac;audio/flac;audio/ogg;
Categories=AudioVideo;Audio;Player;Music;
StartupNotify=true
StartupWMClass=musicbee.exe
SingleMainWindow=true
EOL
desktop-file-install --dir="$app_dir" --rebuild-mime-info-cache "./MusicBee.desktop"
# remove the XDG Desktop entry generated by wine (ours is better)
rm -rf "$app_dir/wine/Programs/MusicBee/"
printf "\nInstallation complete!\n"
printf "\nNote: If using HiDPI a display (i.e. you have scaling set to > 100%%), you have to set the DPI."
printf "\nThis can be done through the winecfg gui (run 'WINEPREFIX=\"%s\" winecfg'), under the 'Graphics' tab, or by running one of the below:\n" "$WINEPREFIX"
printf "\n150%% scaling: WINEPREFIX=\"%s\" wine reg add \"HKCU\\Control Panel\\Desktop\" /v LogPixels /t REG_DWORD /d 0x00000090 /f\n" "$WINEPREFIX"
printf "\n200%% scaling: WINEPREFIX=\"%s\" wine reg add \"HKCU\\Control Panel\\Desktop\" /v LogPixels /t REG_DWORD /d 0x000000C0 /f\n" "$WINEPREFIX"
@Fluffies-System
Copy link

Fluffies-System commented Oct 25, 2025

uhm! hey a couple of suggestions/fixes and a couple questions.

we fink you should add winetricks --unattended windowmanagerdecorated=n so that MusicBee will launch with its own window decorations. This is important because, by default, the menubar is part of the titlebar, which the desktop environment replaces wif its own. You can't access the settings wifout the menubar.

Also, we had to add an export to line 44 because otherwise the program was launching wif the default wineprefix and not the one set by the install script.

uhm ! we'd also like to change DPI but haven't figured out what command to use? we managed to do it by invoking the winecfg GUI, but. would like to have it all done in the script.
got it working wif wine reg add "HKCU\Control Panel\Desktop" /v LogPixels /t REG_DWORD /d 0x00000090 /f

also also uhm ! the icon isn't working? we had to change the icon name to 693A_MusicBee.0

@autumn-mck
Copy link
Author

@Fluffies-System thank yous for this! i really appreciate it

my girlfriend had encountered the same issue with the menubar but we weren't able to find out why, and it's never been an issue for me - added it now, also added the export

for the icon, it seems like wine doesn't consistently name icons - i've updated the script to automatically find the right icon now

for the DPI stuff, i'd had the same issue - i don't think it can be done automatically, as i can't find any easy way to get the dpi across X11/wayland and kde/gnome/etc, so instead i've just added a note after finishing for how to set the DPI

@Fluffies-System
Copy link

just wanted to say yay >w< fluffies did a help. fang you fur writing this script bytheway!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment