Reload menu bar from terminal (not SystemUIServer)
I am looking for a way to reload/refresh the "apple symbol" menu in the upper left corner from the terminal.
Searching for ways to refresh the menu has only led me to find the command
killall -KILL SystemUIServer
this only reload the "widgets" on the right side of the menu and not the content on the left.
I am looking for a way to do this since I have emptied the "recent files" menu programatically (by removing the info from the com.apple.recentitems.plist
file with defaults delete com.apple.recentitems RecentDocuments
) but it doesn't show up. (I know that it is possible to turn off the recent files menu completly but that is not what I want).
Solution 1:
So I finally found a solution to this.
I compiled the following Objective-c code and call it through the terminal.
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
@autoreleasepool {
LSSharedFileListRef recentDocsList = LSSharedFileListCreate(NULL, kLSSharedFileListRecentDocumentItems, NULL);
LSSharedFileListRemoveAllItems(recentDocsList);
NSLog(@"Cleared files!");
}
return 0;
}