Skip to content

Instantly share code, notes, and snippets.

@kmatt
Forked from RxDx/MacOSLogoutHook.txt
Last active November 23, 2022 19:19
Show Gist options
  • Save kmatt/28b5834a4a0ae7256a8aae575b5c0e07 to your computer and use it in GitHub Desktop.
Save kmatt/28b5834a4a0ae7256a8aae575b5c0e07 to your computer and use it in GitHub Desktop.
MacOS: Run script before shutdown
Create a file:
$ vim /Users/Shared/logoutHook.sh
File content:
#!/bin/bash
say 'Hasta la vista baby!'
Set execution permission:
$ sudo chmod +x /Users/Shared/logoutHook.sh
Script hook:
$ sudo defaults write com.apple.loginwindow LogoutHook /Users/Shared/logoutHook.sh
To remove the hook:
$ sudo defaults delete com.apple.loginwindow LogoutHook
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment