Skip to content

Commit 2f322b8

Browse files
committed
feat: add script to enable menu bar on single screen
1 parent 92d8d3a commit 2f322b8

File tree

6 files changed

+70
-13
lines changed

6 files changed

+70
-13
lines changed

nix/_home-files.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,5 @@ in
3939
"Library/Application Support/obs-studio/global.ini".source = symlink "${dotfilesPath}/modules/private/mac/obs/global.ini";
4040
"Library/Application Support/zen/Profiles/8fh0vfxw.Default (alpha)/chrome/userChrome.css".source = symlink "${dotfilesPath}/os/mac/zen/userChrome.css";
4141
"Library/LaunchAgents/com.user.disable.airpods.microphone.plist".source = symlink "${dotfilesPath}/os/mac/LaunchAgents/com.user.disable.airpods.microphone.plist";
42+
"Library/LaunchAgents/com.user.toggle.menubar.plist".source = symlink "${dotfilesPath}/os/mac/LaunchAgents/com.user.toggle.menubar.plist";
4243
}

nix/flake.lock

Lines changed: 13 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

nix/flake.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
system.defaults = import ./_macos-defaults.nix;
3232
system.keyboard.enableKeyMapping = true;
3333
system.keyboard.remapCapsLockToEscape = true;
34+
system.primaryUser = "rafa.gomez";
3435

3536
# Necessary for using flakes on this system.
3637
nix.settings.experimental-features = "nix-command flakes";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>Label</key>
6+
<string>com.user.toggle.menubar</string>
7+
<key>ProgramArguments</key>
8+
<array>
9+
<string>/Users/rafa.gomez/.dotfiles/bin/sdot</string>
10+
<string>mac</string>
11+
<string>toggle_menu_bar</string>
12+
</array>
13+
<key>StartInterval</key>
14+
<integer>5</integer>
15+
<key>RunAtLoad</key>
16+
<true/>
17+
</dict>
18+
</plist>

scripts/mac/toggle_menu_bar

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
source "$DOTLY_PATH/scripts/core/_main.sh"
6+
7+
##? Ensure menu bar is visible only when there is one screen.
8+
#?? 1.1.0
9+
##?
10+
##? Usage:
11+
##? sync_menu_bar_visibility
12+
docs::parse "$@"
13+
14+
function should_toggle_menu_bar_visibility() {
15+
local -r total_screens=$(get_total_screens)
16+
local -r is_menu_bar_hidden=$(is_menu_bar_hidden)
17+
local -r should_be_hidden=$((total_screens > 1))
18+
19+
[[ "$is_menu_bar_hidden" -ne "$should_be_hidden" ]]
20+
}
21+
22+
function get_total_screens() {
23+
system_profiler SPDisplaysDataType | grep -c "Resolution"
24+
}
25+
26+
function is_menu_bar_hidden() {
27+
defaults read NSGlobalDomain _HIHideMenuBar
28+
}
29+
30+
function toggle_menu_bar() {
31+
open -g "raycast://extensions/iamyeizi/toggle-menu-bar/toggle"
32+
}
33+
34+
if should_toggle_menu_bar_visibility; then
35+
toggle_menu_bar
36+
fi

shell/exports.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export path=(
7373
"/opt/homebrew/opt/node@14/bin"
7474
"/opt/homebrew/bin"
7575
"/opt/homebrew/sbin"
76+
"/Users/rafa.gomez/.local/bin"
7677
"/usr/local/bin"
7778
"/bin"
7879
"/usr/bin"

0 commit comments

Comments
 (0)