My environment: Sonoma 14.2.1 on MacBook Pro 14 (2021).
What I wnat do to is:
(1) If I press the F6 key,
(2) then DND is on, and at the same time the menu bar auto hide is on.
(3) If I again press F6,
(4) then DND and menu bar auto hide are off.
(5) This have to work both in desktop and full screen mode.
What I have tried are:
(a). As a partial solution, I opened AppleScript and typed:
tell application "System Events"
if autohide menu bar of dock preferences then
set autohide menu bar of dock preferences to false
else
set autohide menu bar of dock preferences to true
end if
end tell
But (a) is not good because this works only in desktop; that is, this does not work in the full screen mode.
(b). Another partial solution I tried is to use the Automator which runs bin/bash contaning the commands like:
(...some 'if' statements...)
defaults write -g AppleMenuBarVisibleInFullscreen -bool false
(...and 'delete' in the place of 'write'...)
But this didn't make any change to my menu bar.
So what can I do now? Thanks to any helps and suggestions.