Skip to content

Instantly share code, notes, and snippets.

@jeremy4971
Last active January 6, 2024 10:30
Show Gist options
  • Save jeremy4971/b8f31d12651457c491955546b67958cb to your computer and use it in GitHub Desktop.
Save jeremy4971/b8f31d12651457c491955546b67958cb to your computer and use it in GitHub Desktop.
#!/bin/sh
###
#
# Created : 2022-09-19
# Last Modified : 2022-11-12
# Version : 1.2
# Tested with : macOS 13.0.1
#
###
###
#
# Common app IDs
#
# Microsoft Teams : com.microsoft.teams
# Slack : com.tinyspeck.slackmacgap
# Google Chrome : com.google.Chrome
# Chrome Remote Desktop : com.google.chrome.remote_desktop.remote-assistance-host-v2
# Mozilla Firefox : org.mozilla.firefox
# Zoom : us.zoom.xos
# TeamViewer : com.teamviewer.TeamViewer
# TeamViewer QuickSupport : com.teamviewer.TeamViewerQS
# AnyDesk : com.philandro.anydesk
# Parsec : tv.parsec.www
# Discord : com.hnc.Discord
# Skype for Business : com.microsoft.SkypeForBusiness
# Skype : com.skype.skype
#
###
# In order to read TCC.db, full disk access must be granted for Terminal.app if executed with it.
# Mac@IBM Notifications binary path
NA_PATH="/Applications/IBM Notifier.app/Contents/MacOS/IBM Notifier"
# What's the app?
appName="Google Chrome"
appID="com.google.Chrome"
# Variables for IBM Notifier
WINDOWTYPE="popup"
ICON="/Applications/Google Chrome.app/Contents/Resources/app.icns"
TITLE="Autoriser le partage dʼécran :"
BUTTON_1="Terminer"
IMAGE="https://i.imgur.com/ngdWQ2J.gif"
SUBTITLE="Dans la fenêtre Enregistrement dʼécran, vérifiez que $appName soit ajouté et activé.
Une fois réalisé, cliquez sur le bouton Terminer."
#SUBTITLE="In the Screen Recording window, please add $appName and activate it.
#Once done, click the button bellow."
promptUser(){
echo "Opening Screen Recording Privacy"
open "/System/Library/PreferencePanes/Security.prefPane"
sleep 3
open "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"
"${NA_PATH}" "-type" "${WINDOWTYPE}" "-icon_path" "${ICON}" "-title" "${TITLE}" "-subtitle" "${SUBTITLE}" "-main_button_label" "${BUTTON_1}" "-accessory_view_type" "image" "-accessory_view_payload" "$IMAGE" "-always_on_top"; echo $?
}
auth_value=$(/usr/bin/sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "SELECT auth_value FROM access WHERE client = '$appID' AND service='kTCCServiceScreenCapture';")
until [ "$auth_value" = "2" ]; do
echo "Waiting for 2..."
open "x-apple.systempreferences:com.apple.preference.security?Privacy_ScreenCapture"
promptUser
sleep 2
auth_value=$(/usr/bin/sqlite3 "/Library/Application Support/com.apple.TCC/TCC.db" "SELECT auth_value FROM access WHERE client = '$appID' AND service='kTCCServiceScreenCapture';")
done
echo "$appName permission has been enabled"
osascript -e 'tell app "System Preferences" to quit'
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment