@@ -37,10 +37,15 @@ set command to "
3737my withTimeout(command, timeoutSeconds)
3838` ;
3939
40- const enableFocusModeVenturaAppleScript = ( locale : string ) => {
40+ const enableFocusModeVenturaAppleScript = (
41+ locale : string ,
42+ platformMajor : number
43+ ) => {
4144 // TODO: attempt to rewrite scripts without any locale specific instructions
4245 // so this setup can be used regardless of user locale preferences.
4346 const center = locale . trim ( ) === "en_GB" ? "Centre" : "Center" ;
47+ const checkboxPosition =
48+ platformMajor < 25 ? "checkbox 2 of group 1" : "checkbox 7 of group 1" ;
4449
4550 return `-- Startup delay to reduce chance of "Application isn't running (-600)" errors
4651delay 1
@@ -52,34 +57,38 @@ set command to "
5257 tell application \\"System Events\\"
5358 key down 63
5459 key down \\"c\\"
55- delay 0.5
60+ delay 1
5661 key up \\"c\\"
5762 key up 63
63+ delay 2
5864 end tell
5965
6066 tell application \\"System Events\\"
6167 tell its application process \\"Control ${ center } \\"
6268 tell its window 1
6369 -- Check if Do Not Disturb already enabled
64- set doNotDisturbCheckbox to checkbox 2 of group 1
70+ set doNotDisturbCheckbox to ${ checkboxPosition }
6571 set doNotDisturbCheckboxStatus to value of doNotDisturbCheckbox as boolean
6672
6773 tell doNotDisturbCheckbox
6874 if doNotDisturbCheckboxStatus is false then
69- perform action 1 of doNotDisturbCheckbox
75+ click doNotDisturbCheckbox
7076 end if
7177 end tell
7278 end tell
7379 end tell
7480 end tell
7581
82+ delay 2
83+
7684 -- Close Control Center drop down
7785 tell application \\"System Events\\"
7886 key down 63
7987 key down \\"c\\"
80- delay 0.5
88+ delay 1
8189 key up \\"c\\"
8290 key up 63
91+ delay 2
8392 end tell
8493"
8594
@@ -101,7 +110,7 @@ export async function enableDoNotDisturb() {
101110
102111 // From MacOS 13 Ventura (Darwin 22) there is no known way to enable DND via system settings
103112 await retryOnError ( ( ) =>
104- runAppleScript ( enableFocusModeVenturaAppleScript ( locale ) )
113+ runAppleScript ( enableFocusModeVenturaAppleScript ( locale , platformMajor ) )
105114 ) ;
106115 }
107116 } catch ( e ) {
0 commit comments