-
-
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" |
@Zephirus2 heya o/
it still works for me yep, although i've not tested it widely (only really on arch linux and nixos), so i'm not surprised it doesn't always work
what distro are you using?
what else is logged before or after that error?
i'm not familiar with the internals of wine itself so that error on it's own doesn't mean much to me unfortunately
hey thank you for the guide it's super useful! :)
do you know how i could give musicbee the permission to write files though?
i am no developer so i don't know if it is related to your installation at all but every time i try to edit tags/love a track/send to volume analysis etc. it simply gives me the error Access denied. Ensure that your windows account has permissions to write to the directory and file. when i should have full rights in the music folder?



sorry it seems like. an easy enough fix and maybe i'm missing something super obvious but i can't figure it out and searching the web doesn't return much so i was wondering if you ran into this issue as well
@924e50c0 that's definitely an odd issue, with those permissions, anything should be able to read from/write to those files
can you try running something like WINEPREFIX=~/.local/share/wineprefixes/MusicBee/ wine ~/.local/share/wineprefixes/MusicBee/drive_c/windows/notepad.exe, and test with notepad to see if you're able to edit anything?
i've not seen that at all myself - the only thing i can see from those screenshots that's different to my setup is that i'm loading the music from the same drive, instead of something on /mnt (i don't see why that would cause any issues, but i'll test it myself in a bit)
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
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!
Hi! Does this still work for you? I'm getting this error..
Modules: Module Address Debug info Name (39 modules) PE 400000- 97e000 Deferred musicbee PE 44d0000- 49c8000 Deferred mscorlib PE 55f0000- 568a000 Deferred system.drawing PE 56e0000- 5786000 Deferred microsoft.visualbasic PE 5850000- 599c000 Deferred system.core PE 5b60000- 6024000 Deferred system.windows.forms PE 6030000- 6386000 Deferred system PE 79d20000-79dca000 Deferred diasymreader PE-Wine 79de0000-79ded000 Deferred dwmapi PE-Wine 79e00000-7a74b000 Deferred shell32 PE-Wine 7a760000-7a7ec000 Deferred gdiplus PE 7a800000-7a810000 Deferred nlssorting PE 7a820000-7a880000 Deferred clrjit PE-Wine 7a890000-7a8c7000 Deferred uxtheme PE-Wine 7a8e0000-7a8eb000 Deferred winex11 PE-Wine 7a900000-7a90c000 Deferred version PE 7a920000-7af8f000 --none-- clr PE-Wine 7afc0000-7afd8000 Deferred shcore PE-Wine 7aff0000-7b03c000 Deferred shlwapi PE 7b050000-7b0b6000 --none-- mscoreei PE-Wine 7b240000-7b25e000 Deferred imm32 PE-Wine 7b270000-7b335000 Deferred oleaut32 PE-Wine 7b350000-7b368000 Deferred coml2 PE-Wine 7b380000-7b38c000 Deferred cryptbase PE-Wine 7b3a0000-7b429000 Deferred rpcrt4 PE-Wine 7b440000-7b490000 Deferred combase PE-Wine 7b4a0000-7b55e000 Deferred ole32 PE 7b570000-7b5ba000 --none-- mscoree PE-Wine 7b5d0000-7b608000 Deferred win32u PE-Wine 7b620000-7b6a8000 Deferred gdi32 PE-Wine 7b6c0000-7b892000 Deferred user32 PE-Wine 7b8b0000-7b998000 Deferred ucrtbase PE-Wine 7b9b0000-7b9ce000 Deferred sechost PE-Wine 7b9e0000-7ba97000 Deferred msvcrt PE-Wine 7bab0000-7baef000 Deferred advapi32 PE 7bb00000-7bbbe000 Deferred msvcr100_clr0400 PE-Wine 7bbd0000-7be74000 Export kernelbase PE-Wine 7be90000-7bef5000 Deferred kernel32 PE-Wine 7bf30000-7bfea000 Export ntdll Threads: