System events and plist files

Usually i’m not interested at all what’s written in a plist, because these are parameters to set in our applications. The point is some application behaviour is poorly or lazily designed
So a shortcut comes in handy

set libPt to path to preferences folder from user domain
tell application "System Events"
	set plistFile to property list file (libPt & ".GlobalPreferences.plist" as text)  
	tell plistFile
		set HiddenToolbar to value of property list item "_HIHideMenuBar"
		if HiddenToolbar is true then
			set value of property list item "_HIHideMenuBar" to false
			log 1
			set value of property list item "_HIHideMenuBar" to true
			log 2
		end if
	end tell
end tell

The value is written, but doesn’t activate the desired effect.

You’re misunderstanding the role of these preference files. Generally they are a reflection of a setting, stored for the next reboot. To actually change a value, you need to use either the command-line tool defaults or NSUSerDefaults. Even then, you will probably have to quit and relaunch the relevant application.

Shane, thanks very much for your directions.

Can’t agree more with what you said, still… I’m puzzled as my script worked the very first time I ran it. I did it more for fun and the habit to push “run” …and for some strange coincidence things worked.

So I decided to create this post to clear up with my confusion, as it didn’t work anymore the next time I ran the script. :lol: