Hi everyone,
Since Apple removed the sac_switchuser function and the old CGSession binary no longer works on recent macOS versions (Sonoma/Sequoia), it has become quite difficult to trigger a specific user switch via a shortcut.
I found a reliable way to do this using a UI-based AppleScript that interacts with the Control Center. This is particularly useful if you want a one-click shortcut to jump to a specific secondary account.
The Script
Assign this code to a shortcut or a trackpad gesture using the "Execute AppleScript" action:
tell application "System Events"
tell process "ControlCenter"
-- Find the User icon in the menu bar (localized for French/English)
set userMenu to (first menu bar item of menu bar 1 whose description contains "User" or description contains "Utilisateur" or description contains "Account")
click userMenu
-- Wait for the panel to pop up
delay 0.5
-- Focus the first user in the list
key code 48 -- Tab key
delay 0.2
-- Move to the right to select the second user (adjust if you have more)
key code 48 -- Tab key
delay 0.2
-- Press Space to confirm the switch (more reliable than Enter here)
key code 49 -- Space key
end tell
end tell
Hope this helps anyone struggling with the "No such file or directory" errors on the old terminal commands!