Skip to content

Instantly share code, notes, and snippets.

@maxberggren
Created December 7, 2025 19:41
Show Gist options
  • Select an option

  • Save maxberggren/b1be62058519fd31080033bc2057c7de to your computer and use it in GitHub Desktop.

Select an option

Save maxberggren/b1be62058519fd31080033bc2057c7de to your computer and use it in GitHub Desktop.
Firefox auto-hide toolbar - shows only when mouse is in top 20px
#!/bin/bash
# Install Firefox with auto-hide toolbar configuration
# Shows toolbar only when mouse is in top 20px or URL bar is focused
set -e
echo "Setting up Firefox auto-hide profile..."
# Find the autohide profile directory
PROFILE_DIR=$(find ~/.mozilla/firefox -maxdepth 1 -name "*autohide*" -type d 2>/dev/null | head -1)
if [ -z "$PROFILE_DIR" ]; then
echo "Creating autohide profile..."
firefox --CreateProfile "autohide" 2>/dev/null
sleep 1
PROFILE_DIR=$(find ~/.mozilla/firefox -maxdepth 1 -name "*autohide*" -type d | head -1)
fi
if [ -z "$PROFILE_DIR" ]; then
echo "Error: Could not create or find autohide profile"
exit 1
fi
echo "Using profile: $PROFILE_DIR"
# Create chrome directory
mkdir -p "$PROFILE_DIR/chrome"
# Copy userChrome.css
cat > "$PROFILE_DIR/chrome/userChrome.css" << 'EOF'
/*
* Auto-hide Firefox toolbar - shows only when mouse is in top 20px
*/
/* Create a trigger zone using the toolbox-container */
#navigator-toolbox {
position: fixed !important;
top: 0 !important;
left: 0 !important;
right: 0 !important;
z-index: 9999 !important;
padding-top: 20px !important; /* This is the hover trigger zone */
margin-top: -20px !important; /* Offset to keep it at the very top */
background: transparent !important;
border: none !important;
box-shadow: none !important;
}
/* Remove any borders/lines from toolbox */
#navigator-toolbox::after,
#navigator-toolbox::before {
display: none !important;
}
/* Hide the actual toolbar content by default */
#navigator-toolbox > *,
#nav-bar,
#TabsToolbar,
#PersonalToolbar,
#urlbar-container,
#searchbar,
#search-container,
.urlbar-input-box,
#urlbar {
opacity: 0 !important;
transform: translateY(-100%) !important;
transition: opacity 0.2s ease, transform 0.2s ease !important;
pointer-events: none !important;
}
/* Give TabsToolbar same background as nav-bar */
#TabsToolbar {
background: var(--toolbar-bgcolor, #2b2a33) !important;
}
/* Show toolbar content when hovering the toolbox (including the 20px padding zone) */
#navigator-toolbox:hover > *,
#navigator-toolbox:hover #nav-bar,
#navigator-toolbox:hover #TabsToolbar,
#navigator-toolbox:hover #PersonalToolbar,
#navigator-toolbox:hover #urlbar-container,
#navigator-toolbox:hover #searchbar,
#navigator-toolbox:hover #search-container,
#navigator-toolbox:hover .urlbar-input-box,
#navigator-toolbox:hover #urlbar,
/* Show when URL bar or search bar is focused (e.g., new tab) */
#navigator-toolbox:focus-within > *,
#navigator-toolbox:focus-within #nav-bar,
#navigator-toolbox:focus-within #TabsToolbar,
#navigator-toolbox:focus-within #PersonalToolbar,
#navigator-toolbox:focus-within #urlbar-container,
#navigator-toolbox:focus-within #searchbar,
#navigator-toolbox:focus-within #search-container,
#navigator-toolbox:focus-within .urlbar-input-box,
#navigator-toolbox:focus-within #urlbar {
opacity: 1 !important;
transform: translateY(0) !important;
pointer-events: auto !important;
}
/* Remove the grey bar - hide titlebar spacers and other decorations */
.titlebar-spacer,
.titlebar-buttonbox-container,
#titlebar {
display: none !important;
}
/* NO margin - content goes to the very top, trigger zone overlays it */
#browser {
margin-top: 0 !important;
}
EOF
# Create user.js to enable userChrome.css
cat > "$PROFILE_DIR/user.js" << 'EOF'
// Enable userChrome.css customization
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
// Enable Wayland support
user_pref("widget.use-xdg-desktop-portal.file-picker", 1);
user_pref("media.ffmpeg.vaapi.enabled", true);
EOF
echo "✓ Firefox auto-hide profile configured!"
echo ""
echo "To use:"
echo " firefox -P autohide"
echo ""
echo "Features:"
echo " - Toolbar hidden by default"
echo " - Move mouse to top 20px to reveal toolbar"
echo " - Toolbar also shows when URL bar is focused (new tab)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment