Skip to content

Instantly share code, notes, and snippets.

@jeremy4971
Last active January 6, 2024 10:30
Show Gist options
  • Save jeremy4971/cfded443e18798875073259108797d75 to your computer and use it in GitHub Desktop.
Save jeremy4971/cfded443e18798875073259108797d75 to your computer and use it in GitHub Desktop.
#!/bin/sh
###
#
# Created : 2022-09-13
# Last Modified : 2022-09-21
# Version : 1.01
# Tested with : macOS 12.6
#
###
# Read logged in user
loggedInUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/ { print $3 }')
echo "Hello, I am $loggedInUser"
# Exit if Intel CPU
if [ "$(/usr/bin/arch)" = "i386" ]; then
echo "Intel CPU, exiting."
exit 0
else
echo "Apple Silicon, continue."
fi
# Exit if OS language is not in French
OS_LANG=$(defaults read /Library/Preferences/.GlobalPreferences.plist "AppleLanguages" | tr -d '\n' | awk -F'"' '{print $2}')
echo "$OS_LANG"
if ! [ "$OS_LANG" = "fr-FR" ]; then
echo "OS language is NOT in French. Exiting"
exit 0
else
echo "Pas mal non, c’est français."
fi
# Enable Rosetta
# For each window title, you must add ".app" if you have enabled filename extensions
sudo -u "$loggedInUser" osascript -e '
activate application "Finder"
tell application "System Events"
tell process "Finder"
tell application "Finder" to open ("/Applications/Adobe Premiere Pro 2022" as POSIX file)
delay 2.0
tell application "System Events" to keystroke "a"
delay 1.0
tell application "System Events" to keystroke "i" using {command down}
repeat until exists scroll area 1 of window "Infos sur Adobe Premiere Pro 2022"
end repeat
delay 1.0
if not (value of checkbox "Ouvrir avec Rosetta" of scroll area 1 of window "Infos sur Adobe Premiere Pro 2022" as boolean) then
click checkbox "Ouvrir avec Rosetta" of scroll area 1 of window "Infos sur Adobe Premiere Pro 2022"
end if
delay 1.0
click button 1 of window "Infos sur Adobe Premiere Pro 2022"
delay 1.0
click button 1 of window "Adobe Premiere Pro 2022"
end tell
end tell
'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment