Created
July 9, 2025 11:51
-
-
Save jghankins/a6c607179e16dae6a36c1b51fa7b01f4 to your computer and use it in GitHub Desktop.
Revisions
-
jghankins created this gist
Jul 9, 2025 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ #!/usr/bin/env node // Required parameters: // @raycast.schemaVersion 1 // @raycast.title Toggle Menu Bar // @raycast.mode compact // @raycast.packageName System // Optional parameters: // @raycast.icon 🔄 // @raycast.description Toggle the visibility of the Mac menu bar // @raycast.author Jim Hankins // @raycast.authorURL https://cloudbedrock.com const { execSync } = require('child_process'); try { // Use AppleScript to toggle menu bar auto-hide const script = ` tell application "System Events" tell dock preferences set currentState to autohide menu bar set autohide menu bar to not currentState if autohide menu bar then return "Menu bar will auto-hide" else return "Menu bar will always show" end if end tell end tell `; const result = execSync(`osascript -e '${script}'`, { encoding: 'utf8' }).trim(); console.log(result); } catch (error) { console.error('Error toggling menu bar:', error.message); // Fallback method using defaults try { const currentState = execSync('defaults read com.apple.dock autohide-menu-bar', { encoding: 'utf8' }).trim(); if (currentState === '1') { execSync('defaults write com.apple.dock autohide-menu-bar -bool false'); console.log('Menu bar set to always show'); } else { execSync('defaults write com.apple.dock autohide-menu-bar -bool true'); console.log('Menu bar set to auto-hide'); } execSync('killall Dock'); } catch (fallbackError) { console.error('Fallback method also failed:', fallbackError.message); } }