Skip to content

Instantly share code, notes, and snippets.

@autumn-mck
Last active July 21, 2025 17:31
Show Gist options
  • Select an option

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

Select an option

Save autumn-mck/ef1fba379cb2429083cf76369d0b032a to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
# SPDX-License-Identifier: Beerware
set -e
bass_aac_download_url="https://www.un4seen.com/files/z/2/bass_aac24.zip"
settings_download_url="https://gist.githubusercontent.com/autumn-mck/509a41d5b72be782866e75bf118b4f98/raw/0c405bafc8ba53f309a078ecc7c8b659587e0b14/MusicBee3Settings.ini"
library_settings_download_url="https://gist.githubusercontent.com/autumn-mck/4212531f1534eab095fada942af049d9/raw/5d8a48d71279602ef97bcd400b396c8fe82ac251/MusicBeeLibrarySettings.ini"
discordbee_settings_url="https://gist.githubusercontent.com/autumn-mck/47aa3b50e55162e01e894063114a63a9/raw/d7698f91566e856f7e3075a633290810239c1323/DiscordBee.settings"
export WINEPREFIX="$HOME/.local/share/wineprefixes/MusicBee/"
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
installation_location="$WINEPREFIX/drive_c/Program Files (x86)/MusicBee/"
printf "Downloading and extracting MusicBee installer\n"
mb_temp_file=$(mktemp --tmpdir MusicBee-XXXXXX.exe)
curl -c ./MG_MB_cookie.txt 'https://www.majorgeeks.com/mg/getmirror/musicbee,1.html'
curl -L -b ./MG_MB_cookie.txt 'https://www.majorgeeks.com/index.php?ct=files&action=download&=' | 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
rm ./MG_MB_cookie.txt
printf "\nSetting up wine prefix\n"
winetricks --unattended dotnet48 xmllite gdiplus cjkfonts
printf "\nInstalling MusicBee\n"
# I haven't dug into what the installer is packaged by, but it supports /S for a silent install
wine "$mb_temp_file" "/S"
rm "$mb_temp_file"
cd "$installation_location"
# Allow playing of AAC/M4A files
# https://getmusicbee.com/forum/index.php?topic=23454.0
printf "\nDownloading bass_aac.dll\n"
curl -L -o bass_aac.zip $bass_aac_download_url
unzip -o bass_aac.zip bass_aac.dll
rm "./bass_aac.zip"
# Themes
(
cd ./Skins
printf "\nDownloading skins\n"
curl -L -O https://github.com/catppuccin/musicbee/releases/download/v2.3.1/catppuccin_macchiato_mauve_bar_unaccented.xmlc
curl -L -O https://github.com/catppuccin/musicbee/releases/download/v2.3.1/catppuccin_macchiato_mauve_bar_accented.xmlc
)
# Plugins
(
cd ./Plugins
printf "\nDownloading plugins\n"
curl -o DiscordBee.zip -L https://github.com/sll552/DiscordBee/releases/download/v3.1.0/DiscordBee-Release-v3.1.0.zip
unzip -o ./DiscordBee.zip
rm ./DiscordBee.zip
)
# Wine-Discord IPC bridge
printf "\nDownloading Wine-Discord IPC bridge\n"
curl -L -O https://github.com/0e4ef622/wine-discord-ipc-bridge/releases/download/v0.0.3/winediscordipcbridge.exe
# 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
WINEPREFIX="$WINEPREFIX"
installation_location="$installation_location"
file=\$(echo \$1 | tr '/' '\\\\') # Replace / with \\
wine "\$installation_location/winediscordipcbridge.exe" & wine "\$installation_location/MusicBee.exe" "/Play" "Z:\$file"
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=737E_MusicBee.0
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="$HOME/.local/share/applications/" --rebuild-mime-info-cache "./MusicBee.desktop"
# Script to allow media keys to control MusicBee
cat > "./togglePlayPause.sh" << EOL
#!/usr/bin/env sh
WINEPREFIX="$WINEPREFIX" wine "$installation_location/MusicBee.exe" "/PlayPause"
EOL
chmod +x "./togglePlayPause.sh"
# If needed in future
## Make sure MusicBee is actually open before trying to play/pause
#if [ "$(xdotool search --classname musicbee.exe)" != "" ]; then
# if [ "$(xdotool getwindowclassname "$(xdotool getactivewindow)")" != "musicbee.exe" ]; then
# ...
# fi
#fi
printf "\nDownloading settings\n"
cd "$WINEPREFIX/drive_c/users/$(whoami)/AppData/Roaming/MusicBee/"
curl -L -O $settings_download_url
mkdir -p ./DiscordBee
cd ./DiscordBee
curl -L -O $discordbee_settings_url
printf "\nDownloading library settings\n"
cd "$WINEPREFIX/drive_c/users/autumn/Music/MusicBee/"
curl -L -O $library_settings_download_url
printf "\nCreating empty MusicBeeLibrary\n"
# Create an empty MusicBeeLibrary to prevent it giving an error
# (This is what a library with 0 songs in it looks like for some reason)
rm -f ./MusicBeeLibrary.mbl
truncate -s 8000K MusicBeeLibrary.mbl
printf '\x01' | dd of=MusicBeeLibrary.mbl bs=1 seek=0 count=1 conv=notrunc
printf '\x01' | dd of=MusicBeeLibrary.mbl bs=1 seek=4 count=1 conv=notrunc
# Remove the XDG Desktop entry generated by wine (ours is better)
rm -r "$HOME/.local/share/applications/wine/Programs/MusicBee/"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment