jaymonkey
Moderator
- Joined
- Aug 27, 2011
- Messages
- 4,075
- Motherboard
- GB Z490 Vision D
- CPU
- i9-10850K OC @ 5.2 GHz
- Graphics
- RX6800-XT+UHD630
- Mac
- Mobile Phone
Background
Despite MacOS presenting a dialogue box that gives you the option to reopen (or not) apps on a restart or shutdown, in my experience I've found that most times MacOS seem to ignore whatever option you select and just goes ahead and reopens the previous open apps regardless .... even if I uncheck the reopen option.
All my hacks appear to suffer from this problem and it can become very annoying if you had a lot of apps open when you shut the computer down and you have to wait for MacOS to load them all again next time you boot up, and then close them all ...
After some digging I found that MacOS stores the current session info in the following file :-
Where 'USENAME' is your User ID and '*' is a UUID type alpha-hexadecimal string.
This file is actively managed by MacOS while your logged on and stores info on what Apps are currently open, window size and position. By disabling system access to this file we can permanently stop MacOS from re-opening Apps from the last session.
Method
If you need to re-enable the feature you can simply delete the existing file with the following terminal command :-
MacOS will then automatically re-create the file with the correct permissions and the feature will be re-enabled.
Cheers
Jay
Despite MacOS presenting a dialogue box that gives you the option to reopen (or not) apps on a restart or shutdown, in my experience I've found that most times MacOS seem to ignore whatever option you select and just goes ahead and reopens the previous open apps regardless .... even if I uncheck the reopen option.
All my hacks appear to suffer from this problem and it can become very annoying if you had a lot of apps open when you shut the computer down and you have to wait for MacOS to load them all again next time you boot up, and then close them all ...
After some digging I found that MacOS stores the current session info in the following file :-
Code:
/Users/USERNAME/Library/Preferences/ByHost/com.apple.loginwindow.*.plist
Where 'USENAME' is your User ID and '*' is a UUID type alpha-hexadecimal string.
This file is actively managed by MacOS while your logged on and stores info on what Apps are currently open, window size and position. By disabling system access to this file we can permanently stop MacOS from re-opening Apps from the last session.
Method
- Open Terminal
- First we need to flag the file as owned by root (otherwise MacOS will replace it) with the following command :-
-
Code:
sudo chown root ~/Library/Preferences/ByHost/com.apple.loginwindow.*
- Next we need to remove all permissions (so that it can not be read or written to) with the following command :-
-
Code:
sudo chmod 000 ~/Library/Preferences/ByHost/com.apple.loginwindow.*
If you need to re-enable the feature you can simply delete the existing file with the following terminal command :-
Code:
sudo rm -f ~/Library/Preferences/ByHost/com.apple.loginwindow.*
MacOS will then automatically re-create the file with the correct permissions and the feature will be re-enabled.
Cheers
Jay
Last edited: