Files
parana/scripts/open-calendar-floating.sh
2026-07-10 20:07:29 -04:00

86 lines
2.5 KiB
Bash
Executable File

#!/usr/bin/env bash
# Open Google Calendar as a floating web app window using Firefox
# Check if Firefox is already running with the calendar
EXISTING=$(pgrep -f "firefox.*calendar.google.com" | head -1)
if [ ! -z "$EXISTING" ]; then
# Focus the existing window instead
WINDOW_ADDRESS=$(hyprctl clients -j | jq -r ".[] | select(.pid == $EXISTING) | .address" | head -1)
if [ ! -z "$WINDOW_ADDRESS" ]; then
hyprctl dispatch focuswindow "address:$WINDOW_ADDRESS"
fi
exit 0
fi
# Create a dedicated Firefox profile for calendar app
PROFILE_DIR="$HOME/.mozilla/firefox/calendar-app"
if [ ! -d "$PROFILE_DIR" ]; then
mkdir -p "$PROFILE_DIR/chrome"
# Create user.js to customize Firefox UI
cat > "$PROFILE_DIR/user.js" << 'EOF'
// Hide Firefox UI elements
user_pref("browser.chrome.toolbar_tips", false);
user_pref("browser.tabs.drawInTitlebar", true);
user_pref("browser.tabs.tabmanager.enabled", false);
user_pref("browser.uidensity", 2);
// Disable notifications and other UI clutter
user_pref("extensions.activeThemeID", "firefox-compact-dark@mozilla.org");
user_pref("browser.startup.homepage_override.mstone", "ignore");
// Hide various UI elements
user_pref("toolkit.legacyUserProfileCustomizations.stylesheets", true);
EOF
# Create userChrome.css to hide the toolbar and tabs
cat > "$PROFILE_DIR/chrome/userChrome.css" << 'EOF'
/* Hide the entire toolbar area */
#navigator-toolbox {
display: none !important;
}
/* Hide tabs bar */
#TabsToolbar {
display: none !important;
}
/* Hide sidebar button */
#sidebar-button {
display: none !important;
}
/* Make content fill the window */
#content {
margin: 0 !important;
}
EOF
fi
# Open Firefox with the dedicated profile in a new window
firefox --new-instance --profile "$PROFILE_DIR" "https://calendar.google.com" &
FIREFOX_PID=$!
# Wait for window to open
sleep 1.5
# Get the window address
WINDOW_ADDRESS=$(hyprctl clients -j | jq -r ".[] | select(.pid == $FIREFOX_PID) | .address" | head -1)
if [ ! -z "$WINDOW_ADDRESS" ]; then
# Make it floating
hyprctl dispatch togglefloating "address:$WINDOW_ADDRESS"
# Resize to a smaller window size (900x700)
hyprctl dispatch resizewindowpixel "exact 900 700" "address:$WINDOW_ADDRESS"
# Center it on screen
hyprctl dispatch centerwindow "address:$WINDOW_ADDRESS"
# Collapse sidebar - press 'm' to toggle sidebar in Google Calendar
(
sleep 2
xdotool search --name "calendar" key "m" 2>/dev/null || true
) &
fi