-
-
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" |
Hello- I'm on EndeavourOS (fork of Arch). I have winetricks 20250102-1 from multilib and wine 10.13-1 from extra. When I try to run the script as is, I get warnings:
warning: You appear to be using Wine's new wow64 mode. Note that this is EXPERIMENTAL and not yet fully supported. If reporting an issue, be sure to mention this.
warning: You are using a 64-bit WINEPREFIX. Note that many verbs only install 32-bit versions of packages. If you encounter problems, please retest in a clean 32-bit WINEPREFIX before reporting a bug.
When I then try to run ./.local/share/wineprefixes/MusicBee/drive_c/Program\ Files\ \(x86\)/MusicBee/launch.sh, as is in the .desktop entry, I get:
0138:err:environ:init_peb starting L"Z:\\home\\laura\\.local\\share\\wineprefixes\\MusicBee\\drive_c\\Program Files (x86)\\MusicBee\\MusicBee.exe" in experimental wow64 mode
0138:fixme:mscoree:parse_supported_runtime sku=L".NETFramework,Version=v4.8" not implemented
0138:fixme:mscoree:parse_supported_runtime sku=L".NETFramework,Version=v4.8" not implemented
0138:err:mscoree:CLRRuntimeInfo_GetRuntimeHost Wine Mono is not installed
Based on this blog post, I considered adding export WINEARCH="win32" alongside the other exports in the script, but then I get the following error when running it:
warning: wine cmd.exe /c echo '%AppData%' returned empty string, error message "wine: WINEARCH is set to 'win32' but this is not supported in wow64 mode."
Any help would be greatly appreciated. I can't figure out if wow64 mode is newer than the script, or if I maybe have some unusual wine config. This is my first time using wine.
@laurapigeon sorry for taking a bit to reply, was busy moving countries!
I know about the wow64 warnings, they're fine and should just be ignored; arch switched to supporting only it a couple months ago and I updated the script then to get it to work again. I completely forgot to update the blog post though, which is why it mentions win32 still (updated now)
I've tested it specifically on endeavour os now too and it seems to work for me there. Given it mentions it, can you try installing the wine-mono package and see if you're still getting the same result?
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
@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
just wanted to say yay >w< fluffies did a help. fang you fur writing this script bytheway!
couldn't edit anything with notepad either, even with the default wineprefix actually
i just moved some files in the same drive as my linux install and they can be edited that way. it's apparently just the drive on /mnt where wine can only read files when i should have full permissions