Skip to content

Instantly share code, notes, and snippets.

@x-magic
Created December 15, 2024 08:57
Show Gist options
  • Save x-magic/b3ed457042cc8a9dc57fa88faf0a380c to your computer and use it in GitHub Desktop.
Save x-magic/b3ed457042cc8a9dc57fa88faf0a380c to your computer and use it in GitHub Desktop.
Change the full-screen menu bar visibility on a per-app-basis on macOS
#!/bin/bash
if [ $# -eq 0 ]; then
echo "Change the full-screen menu bar visibility on a per-app-basis on macOS"
echo "Usage: $0 APP_NAME [show|hide|revert]"
echo -e "\nPlease provide the name of the application to continue."
exit 1
else
# Get the app ID first
APP_ID=$(osascript -e "id of app \"$1\"" 2> /dev/null)
if [ -z "$APP_ID" ]; then
echo -e "Cannot fetch the App ID of \"$1\"!\nLaunch the app and keep it open then try again."
exit 255
fi
echo -e "The full-screen menu bar visibility for\n $1 ($APP_ID)"
case "$2" in
show)
defaults write $APP_ID AppleMenuBarVisibleInFullscreen -bool true
echo -e "is set to: \033[1mAlways show\033[0m"
;;
hide)
defaults write $APP_ID AppleMenuBarVisibleInFullscreen -bool false
echo -e "is set to: \033[1mAlways hide\033[0m"
;;
revert)
defaults delete $APP_ID AppleMenuBarVisibleInFullscreen
echo -e "is set to: \033[1mFollow system settings\033[0m"
;;
*)
echo -e -n "is currently set to:\n "
APP_DEFAULT=$(defaults read $APP_ID AppleMenuBarVisibleInFullscreen 2> /dev/null)
case "$APP_DEFAULT" in
1)
echo -e "\033[1mAlways show\033[0m"
;;
0)
echo -e "\033[1mAlways hide\033[0m"
;;
*)
echo -e "\033[1mFollow system settings\033[0m"
;;
esac
echo -e "\nSet the 2nd argument to one of 'show', 'hide' or 'revert' to change the full-screen menu bar behaviour."
;;
esac
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment