Last active
December 20, 2021 08:11
-
-
Save ELLIOTTCABLE/414e22123693bab059682f15204bf7f3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
APP=$1 | |
# This script is intended to temporarily bypass the "blank screen" bug in Anki on unsupported(?) | |
# GPUs (Dec 2021): <https://forums.ankiweb.net/t/anki-opens-but-all-windows-are-blank/8920/16> | |
# | |
# Adapted from a similar script by @ahihi for an app called "SuperCollider" that also uses qt on | |
# macOS: <https://github.com/supercollider/supercollider/issues/4136#issuecomment-605447703> | |
if [ -z "$APP" ]; then | |
echo "usage: $(basename "$0") <path to Anki.app>" | |
exit 1 | |
fi | |
MACOS_DIR="$APP/Contents/MacOS" | |
if [ ! -d "$MACOS_DIR" ]; then | |
echo "not a directory: $MACOS_DIR" | |
exit 1 | |
fi | |
SCRIPT_NAME='anki-disable-gpu' | |
SCRIPT="$MACOS_DIR/$SCRIPT_NAME" | |
if [ -e "$SCRIPT" ]; then | |
echo "$SCRIPT already exists" | |
exit 1 | |
fi | |
# shellcheck disable=SC2016 | |
SCRIPT_CONTENT='#!/bin/bash | |
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)" | |
exec env QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu" "$DIR/anki"' | |
echo "creating $SCRIPT" | |
echo "$SCRIPT_CONTENT" > "$SCRIPT" | |
echo "setting execute permissions on $SCRIPT" | |
chmod a+x "$SCRIPT" | |
INFO_PLIST="$APP/Contents/Info.plist" | |
echo "setting CFBundleExecutable = $SCRIPT_NAME in $INFO_PLIST" | |
defaults write "$INFO_PLIST" CFBundleExecutable "$SCRIPT_NAME" | |
# `defaults write` saves a binary plist, convert back to xml | |
plutil -convert xml1 "$INFO_PLIST" | |
echo 'done' | |
echo 'rebuilding the LaunchServices database may be needed' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
/Applications/Anki.app/Contents/MacOS/anki-disable-gpu show error:
env: /Applications/Anki.app/Contents/MacOS/anki: Permission denied
so I change
exec env QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu" "$DIR/anki"
toexec env QTWEBENGINE_CHROMIUM_FLAGS="--disable-gpu" "$DIR/AnkiMac"
It runs