diff --git a/.config/display-modes/README.md b/.config/display-modes/README.md deleted file mode 100644 index 37952e9..0000000 --- a/.config/display-modes/README.md +++ /dev/null @@ -1,172 +0,0 @@ -# Display Mode Switching Scripts - -Automated display switching for multi-Mac desk setup with DDC control and display connection management. - -## Overview - -These scripts control: -1. **Monitor input switching** via DDC/CI (VCP code 0x60) -2. **Display connection management** via BetterDisplay's `connected` feature - -The second part is critical: when a monitor's input is switched away from a Mac, that Mac's display connection should be "disconnected" in BetterDisplay. This prevents macOS from continuing to use a display that's showing a different computer's output. - -## Prerequisites - -### Software (install on all Macs) - -1. **BetterDisplay Pro** - https://betterdisplay.pro - - Purchase Pro license (required for `connected` feature and CLI) - - Enable CLI integration: Settings → Application → Integration - - Enable HTTP integration: Settings → Application → Integration - - Note the HTTP port (default: 55777) - -2. **BetterDisplay CLI** - ```bash - brew install waydabber/betterdisplay/betterdisplaycli - ``` - -3. **display-switch** (optional, for automatic USB-triggered switching) - ```bash - brew install display-switch - ``` - -## Installation - -1. **Copy scripts to each Mac** - ```bash - mkdir -p ~/.config/display-modes - cp *.sh ~/.config/display-modes/ - chmod +x ~/.config/display-modes/*.sh - ``` - -2. **Run discovery to find your DDC values** - ```bash - ~/.config/display-modes/discover.sh - ``` - Follow the prompts to discover input values for each monitor/input combination. - -3. **Edit config.sh with your values** - ```bash - nano ~/.config/display-modes/config.sh - ``` - Fill in: - - Hostnames/IPs for each Mac - - DDC input values discovered in step 2 - - Facecam Pro USB ID (if using display-switch) - -4. **Test scripts manually** - ```bash - ~/.config/display-modes/mode-1-work.sh # Both displays → MBP - ~/.config/display-modes/mode-4-nonwork.sh # Both displays → Mini - ``` - -## Display Modes - -| # | Mode | Dell U4025QW | BenQ MA320U | Use Case | -|---|------|--------------|-------------|----------| -| 1 | Work | MBP (Thunderbolt) | MBP (HDMI 1) | Normal work hours | -| 2 | Split (MBP/Air) | MBP (Thunderbolt) | Air (USB-C) | Work + personal laptop | -| 3 | Split (MBP/Mini) | MBP (Thunderbolt) | Mini (HDMI 2) | Work + glanceable personal | -| 4 | Non-work | Mini (HDMI) | Mini (HDMI 2) | Evenings/weekends/freelance | -| 5 | Alt Non-work | Mini (HDMI) | Air (USB-C) | Mini primary + Air secondary | - -## Automatic Switching with display-switch - -The display-switch utility monitors USB device connections. When the USB switch moves the Facecam Pro between computers, display-switch triggers the corresponding display mode. - -### Setup on Mac Mini - -1. Copy template and customize: - ```bash - cp display-switch-mini.ini.template ~/Library/Preferences/display-switch.ini - nano ~/Library/Preferences/display-switch.ini - ``` - -2. Replace placeholders with your values - -3. Start service: - ```bash - brew services start display-switch - ``` - -### Setup on Work MBP - -Same process using `display-switch-mbp.ini.template`. - -### Advanced: Full Script Execution - -By default, display-switch only switches monitor inputs. To also manage display connections (recommended), uncomment the `on_usb_connect_execute` line and point it to the full mode script. - -## Stream Deck Integration - -### Option A: Local Script Execution -If Stream Deck is connected to the same Mac running the script: -1. Add a "System → Open" action -2. Set path to script, e.g., `~/.config/display-modes/mode-1-work.sh` - -### Option B: HTTP API (Remote) -If Stream Deck is on a different machine, use curl: -```bash -# Example: Switch Dell to HDMI input on Mini -curl "http://macmini.local:55777/set?nameLike=dell&ddc&vcp=0x60&value=17" -``` - -Or use the "Website" action to call the script via HTTP. - -## How Display Connection Management Works - -BetterDisplay's `connected` feature is key to this setup: - -- **connected=on**: macOS sees the display and uses it normally -- **connected=off**: macOS "forgets" the display, removes it from display layout - -When you switch Mode 1 → Mode 4: -1. Script disconnects Dell and BenQ from MBP's perspective -2. Script switches monitor inputs to Mini sources -3. Script connects Dell and BenQ from Mini's perspective - -This prevents issues like: -- Windows appearing on a display you can't see -- GPU rendering to an invisible display -- Display arrangement confusion - -## Troubleshooting - -### DDC commands not working -- Ensure DDC/CI is enabled in monitor OSD settings -- Some cables/adapters don't pass DDC; try different cable -- USB-C to HDMI adapters are sometimes problematic for DDC - -### Display won't reconnect -- Run: `betterdisplaycli set -nameLike=dell -connected=on` -- Check BetterDisplay app for any errors -- Restart BetterDisplay if needed - -### HTTP API not responding -- Verify HTTP integration is enabled in BetterDisplay settings -- Check firewall isn't blocking port 55777 -- Test with: `curl http://localhost:55777/get?proAvailable` - -### display-switch not triggering -- Verify USB ID matches exactly (case-sensitive hex) -- Check service status: `brew services list` -- Check logs: `log show --predicate 'process == "display-switch"' --last 5m` - -## File Reference - -``` -~/.config/display-modes/ -├── config.sh # Your DDC values and hostnames -├── helpers.sh # Shared functions -├── discover.sh # DDC value discovery utility -├── mode-1-work.sh # Both displays → MBP -├── mode-2-split-air.sh # Dell → MBP, BenQ → Air -├── mode-3-split-mini.sh # Dell → MBP, BenQ → Mini -├── mode-4-nonwork.sh # Both displays → Mini -├── mode-5-nonwork-air.sh # Dell → Mini, BenQ → Air -├── display-switch-mini.ini.template -└── display-switch-mbp.ini.template - -~/Library/Preferences/ -└── display-switch.ini # display-switch config (per machine) -``` diff --git a/.config/display-modes/config-air.sh b/.config/display-modes/config-air.sh deleted file mode 100755 index da5ea0a..0000000 --- a/.config/display-modes/config-air.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -# Display Mode Configuration - MacBook Air -# Run discover.sh to find your DDC input values, then fill in below. -# -# Note: The Air typically only drives the BenQ via USB-C in split modes. -# DDC values are still needed for switching the BenQ input when this -# machine triggers a mode change. - -# ============================================================================= -# HOSTNAMES / IPs -# ============================================================================= -MINI_HOST="macmini.local" -MBP_HOST="mbp.local" - -# ============================================================================= -# DDC INPUT VALUES -# ============================================================================= -# Discover these values by: -# 1. Manually switch monitor to desired input -# 2. Run: betterdisplaycli get -nameLike=dell -ddc -vcp=inputSelect -value -# 3. Record the decimal value below - -# Dell U4025QW inputs -DELL_TB="" # Thunderbolt/USB-C input (for MBP) -DELL_HDMI="" # HDMI input (for Mini) - -# BenQ MA320U inputs -BENQ_HDMI1="" # HDMI 1 (for MBP) -BENQ_HDMI2="" # HDMI 2 (for Mini via USB-C adapter) -BENQ_USBC="" # USB-C 90W port (for Air) - -# ============================================================================= -# USB SWITCH (for display-switch integration) -# ============================================================================= -# Facecam Pro USB ID (format: VID:PID, e.g., 0fd9:0084) -FACECAM_USB_ID="" diff --git a/.config/display-modes/config-mbp.sh b/.config/display-modes/config-mbp.sh deleted file mode 100755 index d78ffa2..0000000 --- a/.config/display-modes/config-mbp.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Display Mode Configuration - Work MacBook Pro -# Run discover.sh to find your DDC input values, then fill in below. - -# ============================================================================= -# HOSTNAMES / IPs -# ============================================================================= -MINI_HOST="macmini.local" -MBP_HOST="mbp.local" - -# ============================================================================= -# DDC INPUT VALUES -# ============================================================================= -# Discover these values by: -# 1. Manually switch monitor to desired input -# 2. Run: betterdisplaycli get -nameLike=dell -ddc -vcp=inputSelect -value -# 3. Record the decimal value below - -# Dell U4025QW inputs -DELL_TB="" # Thunderbolt/USB-C input (for MBP) -DELL_HDMI="" # HDMI input (for Mini) - -# BenQ MA320U inputs -BENQ_HDMI1="" # HDMI 1 (for MBP) -BENQ_HDMI2="" # HDMI 2 (for Mini via USB-C adapter) -BENQ_USBC="" # USB-C 90W port (for Air) - -# ============================================================================= -# USB SWITCH (for display-switch integration) -# ============================================================================= -# Facecam Pro USB ID (format: VID:PID, e.g., 0fd9:0084) -FACECAM_USB_ID="" diff --git a/.config/display-modes/config-mini.sh b/.config/display-modes/config-mini.sh deleted file mode 100755 index 8a26cfe..0000000 --- a/.config/display-modes/config-mini.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash -# Display Mode Configuration - Mac Mini -# Run discover.sh to find your DDC input values, then fill in below. - -# ============================================================================= -# HOSTNAMES / IPs -# ============================================================================= -MINI_HOST="macmini.local" -MBP_HOST="mbp.local" - -# ============================================================================= -# DDC INPUT VALUES -# ============================================================================= -# Discover these values by: -# 1. Manually switch monitor to desired input -# 2. Run: betterdisplaycli get -nameLike=dell -ddc -vcp=inputSelect -value -# 3. Record the decimal value below - -# Dell U4025QW inputs -DELL_TB="" # Thunderbolt/USB-C input (for MBP) -DELL_HDMI="" # HDMI input (for Mini) - -# BenQ MA320U inputs -BENQ_HDMI1="" # HDMI 1 (for MBP) -BENQ_HDMI2="" # HDMI 2 (for Mini via USB-C adapter) -BENQ_USBC="" # USB-C 90W port (for Air) - -# ============================================================================= -# USB SWITCH (for display-switch integration) -# ============================================================================= -# Facecam Pro USB ID (format: VID:PID, e.g., 0fd9:0084) -FACECAM_USB_ID="" diff --git a/.config/display-modes/config.sh b/.config/display-modes/config.sh deleted file mode 100755 index 6e70e03..0000000 --- a/.config/display-modes/config.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# Display Mode Switching Configuration -# This file auto-detects the current machine and sources the appropriate config. -# -# Machine-specific config files contain: -# - Hostnames for remote HTTP API calls -# - DDC input values (discovered per-machine using discover.sh) -# - USB device IDs (for display-switch integration) - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - -# ============================================================================= -# MACHINE DETECTION -# ============================================================================= -_detect_machine() { - local hostname - hostname=$(hostname -s | tr '[:upper:]' '[:lower:]') - case "$hostname" in - *mini*) echo "mini" ;; - *mbp*|*macbookpro*) echo "mbp" ;; - *air*|*mba*) echo "air" ;; - *) echo "unknown" ;; - esac -} - -CURRENT_MACHINE="$(_detect_machine)" - -# ============================================================================= -# LOAD MACHINE-SPECIFIC CONFIG -# ============================================================================= -MACHINE_CONFIG="$SCRIPT_DIR/config-${CURRENT_MACHINE}.sh" - -if [[ -f "$MACHINE_CONFIG" ]]; then - source "$MACHINE_CONFIG" -else - echo "WARNING: No config found for machine '$CURRENT_MACHINE'" >&2 - echo "Expected: $MACHINE_CONFIG" >&2 - echo "Run discover.sh to find DDC values, then create the config file." >&2 -fi - -# ============================================================================= -# SHARED CONFIGURATION -# ============================================================================= -# BetterDisplay HTTP port (default: 55777) -BD_PORT="${BD_PORT:-55777}" - -# Display name patterns for BetterDisplay queries (case-insensitive partial match) -DELL_NAME="${DELL_NAME:-dell}" -BENQ_NAME="${BENQ_NAME:-benq}" diff --git a/.config/display-modes/discover.sh b/.config/display-modes/discover.sh deleted file mode 100755 index a5e0104..0000000 --- a/.config/display-modes/discover.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/bin/bash -# ============================================================================= -# Display Discovery Script -# ============================================================================= -# Run this script to discover DDC input values for your monitors. -# You'll need to manually switch inputs on each monitor and run the -# corresponding read command to discover each value. -# ============================================================================= - -echo "========================================" -echo "Display Mode Discovery" -echo "========================================" -echo "" - -# Check if betterdisplaycli is installed -if ! command -v betterdisplaycli &> /dev/null; then - echo "ERROR: betterdisplaycli not found" - echo "Install with: brew install waydabber/betterdisplay/betterdisplaycli" - exit 1 -fi - -echo "Step 1: Finding connected displays..." -echo "----------------------------------------" -betterdisplaycli get -identifiers 2>/dev/null | head -20 -echo "" - -echo "Step 2: DDC Capabilities" -echo "----------------------------------------" -echo "Dell monitor capabilities:" -betterdisplaycli get -nameLike=dell -ddcCapabilities 2>/dev/null || echo " (Dell not found or DDC not available)" -echo "" -echo "BenQ monitor capabilities:" -betterdisplaycli get -nameLike=benq -ddcCapabilities 2>/dev/null || echo " (BenQ not found or DDC not available)" -echo "" - -echo "Step 3: Current Input Values" -echo "----------------------------------------" -echo "To discover input values, manually switch each monitor to the desired" -echo "input using the monitor's controls, then run the read command below." -echo "" -echo "Dell - current input value:" -betterdisplaycli get -nameLike=dell -ddc -vcp=inputSelect -value 2>/dev/null || echo " (not available)" -echo "" -echo "BenQ - current input value:" -betterdisplaycli get -nameLike=benq -ddc -vcp=inputSelect -value 2>/dev/null || echo " (not available)" -echo "" - -echo "========================================" -echo "INSTRUCTIONS" -echo "========================================" -echo "" -echo "1. Switch Dell to Thunderbolt input (for MBP), run:" -echo " betterdisplaycli get -nameLike=dell -ddc -vcp=inputSelect -value" -echo " Record this as DELL_TB in config.sh" -echo "" -echo "2. Switch Dell to HDMI input (for Mini), run:" -echo " betterdisplaycli get -nameLike=dell -ddc -vcp=inputSelect -value" -echo " Record this as DELL_HDMI in config.sh" -echo "" -echo "3. Switch BenQ to HDMI 1 (for MBP), run:" -echo " betterdisplaycli get -nameLike=benq -ddc -vcp=inputSelect -value" -echo " Record this as BENQ_HDMI1 in config.sh" -echo "" -echo "4. Switch BenQ to HDMI 2 (for Mini adapter), run:" -echo " betterdisplaycli get -nameLike=benq -ddc -vcp=inputSelect -value" -echo " Record this as BENQ_HDMI2 in config.sh" -echo "" -echo "5. Switch BenQ to USB-C (for Air), run:" -echo " betterdisplaycli get -nameLike=benq -ddc -vcp=inputSelect -value" -echo " Record this as BENQ_USBC in config.sh" -echo "" - -echo "========================================" -echo "USB Device Discovery (for display-switch)" -echo "========================================" -echo "" -echo "Facecam Pro USB ID:" -system_profiler SPUSBDataType 2>/dev/null | grep -A8 "Facecam Pro" || echo " (Facecam Pro not connected)" -echo "" -echo "Look for 'Vendor ID' and 'Product ID' above." -echo "Format for config: 0fd9:XXXX (where XXXX is the product ID)" diff --git a/.config/display-modes/display-switch/mbp.ini b/.config/display-modes/display-switch/mbp.ini deleted file mode 100644 index 5cbb12b..0000000 --- a/.config/display-modes/display-switch/mbp.ini +++ /dev/null @@ -1,20 +0,0 @@ -# display-switch configuration for Work MacBook Pro -# Copy to: ~/Library/Preferences/display-switch.ini -# Start service: brew services start display-switch -# -# This config triggers WORK mode when Facecam Pro connects to MBP -# (meaning you pressed the USB switch to move webcam to MBP) - -[general] -# Replace with Facecam Pro's Product ID (run discover.sh to find it) -# Format: VID:PID (e.g., 0fd9:0084) -usb_device = "0fd9:XXXX" - -# When Facecam connects to MBP, switch displays to MBP -# Replace with your discovered DDC input values -on_usb_connect = "dell:DELL_TB_VALUE" -on_usb_connect = "benq:BENQ_HDMI1_VALUE" - -# Optional: Execute full mode script for display connection management -# Uncomment and update path for the full mode-1-work.sh behavior -# on_usb_connect_execute = "~/.config/display-modes/mode-1-work.sh" diff --git a/.config/display-modes/display-switch/mini.ini b/.config/display-modes/display-switch/mini.ini deleted file mode 100644 index 275df7a..0000000 --- a/.config/display-modes/display-switch/mini.ini +++ /dev/null @@ -1,20 +0,0 @@ -# display-switch configuration for Mac Mini -# Copy to: ~/Library/Preferences/display-switch.ini -# Start service: brew services start display-switch -# -# This config triggers NON-WORK mode when Facecam Pro connects to Mini -# (meaning you pressed the USB switch to move webcam to Mini) - -[general] -# Replace with Facecam Pro's Product ID (run discover.sh to find it) -# Format: VID:PID (e.g., 0fd9:0084) -usb_device = "0fd9:XXXX" - -# When Facecam connects to Mini, switch displays to Mini -# Replace with your discovered DDC input values -on_usb_connect = "dell:DELL_HDMI_VALUE" -on_usb_connect = "benq:BENQ_HDMI2_VALUE" - -# Optional: Execute full mode script for display connection management -# Uncomment and update path for the full mode-4-nonwork.sh behavior -# on_usb_connect_execute = "~/.config/display-modes/mode-4-nonwork.sh" diff --git a/.config/display-modes/helpers.sh b/.config/display-modes/helpers.sh deleted file mode 100755 index 48ca95b..0000000 --- a/.config/display-modes/helpers.sh +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/bash -# Display Mode Switching - Helper Functions -# Source this file in mode scripts: source "$(dirname "$0")/helpers.sh" - -SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" -source "$SCRIPT_DIR/config.sh" - -# ============================================================================= -# DDC INPUT SWITCHING -# ============================================================================= - -# Switch Dell monitor input via DDC (local) -switch_dell_local() { - local input_value="$1" - if [[ -n "$input_value" ]]; then - betterdisplaycli set -nameLike="$DELL_NAME" -ddc -vcp=0x60 -value="$input_value" - fi -} - -# Switch BenQ monitor input via DDC (local) -switch_benq_local() { - local input_value="$1" - if [[ -n "$input_value" ]]; then - betterdisplaycli set -nameLike="$BENQ_NAME" -ddc -vcp=0x60 -value="$input_value" - fi -} - -# Switch Dell monitor input via HTTP (remote) -switch_dell_remote() { - local host="$1" - local input_value="$2" - if [[ -n "$input_value" ]]; then - curl -s "http://${host}:${BD_PORT}/set?nameLike=${DELL_NAME}&ddc&vcp=0x60&value=${input_value}" > /dev/null - fi -} - -# Switch BenQ monitor input via HTTP (remote) -switch_benq_remote() { - local host="$1" - local input_value="$2" - if [[ -n "$input_value" ]]; then - curl -s "http://${host}:${BD_PORT}/set?nameLike=${BENQ_NAME}&ddc&vcp=0x60&value=${input_value}" > /dev/null - fi -} - -# ============================================================================= -# DISPLAY CONNECTION MANAGEMENT -# ============================================================================= -# These functions connect/disconnect displays from macOS's perspective -# "Disconnecting" removes the display from the display layout so macOS -# doesn't try to use it when that input isn't selected on the monitor - -# Connect a display locally -connect_display_local() { - local display_name="$1" - betterdisplaycli set -nameLike="$display_name" -connected=on 2>/dev/null || true -} - -# Disconnect a display locally -disconnect_display_local() { - local display_name="$1" - betterdisplaycli set -nameLike="$display_name" -connected=off 2>/dev/null || true -} - -# Connect a display via HTTP (remote) -connect_display_remote() { - local host="$1" - local display_name="$2" - curl -s "http://${host}:${BD_PORT}/set?nameLike=${display_name}&connected=on" > /dev/null 2>&1 || true -} - -# Disconnect a display via HTTP (remote) -disconnect_display_remote() { - local host="$1" - local display_name="$2" - curl -s "http://${host}:${BD_PORT}/set?nameLike=${display_name}&connected=off" > /dev/null 2>&1 || true -} - -# ============================================================================= -# COMPOUND OPERATIONS -# ============================================================================= - -# Connect both displays locally -connect_both_local() { - connect_display_local "$DELL_NAME" - connect_display_local "$BENQ_NAME" -} - -# Disconnect both displays locally -disconnect_both_local() { - disconnect_display_local "$DELL_NAME" - disconnect_display_local "$BENQ_NAME" -} - -# Connect both displays on remote host -connect_both_remote() { - local host="$1" - connect_display_remote "$host" "$DELL_NAME" - connect_display_remote "$host" "$BENQ_NAME" -} - -# Disconnect both displays on remote host -disconnect_both_remote() { - local host="$1" - disconnect_display_remote "$host" "$DELL_NAME" - disconnect_display_remote "$host" "$BENQ_NAME" -} - -# ============================================================================= -# MACHINE DETECTION -# ============================================================================= - -# Detect which machine this script is running on -get_current_machine() { - local hostname=$(hostname -s | tr '[:upper:]' '[:lower:]') - case "$hostname" in - *mini*) echo "mini" ;; - *mbp*|*macbook*pro*) echo "mbp" ;; - *air*|*mba*) echo "air" ;; - *) echo "unknown" ;; - esac -} - -# Check if a remote host is reachable -is_host_reachable() { - local host="$1" - curl -s --connect-timeout 2 "http://${host}:${BD_PORT}/get?proAvailable" > /dev/null 2>&1 -} - -# ============================================================================= -# LOGGING -# ============================================================================= - -log_info() { - echo "[$(date '+%H:%M:%S')] $1" -} - -log_error() { - echo "[$(date '+%H:%M:%S')] ERROR: $1" >&2 -} diff --git a/.config/display-modes/mode-1-work.sh b/.config/display-modes/mode-1-work.sh deleted file mode 100755 index 52077ff..0000000 --- a/.config/display-modes/mode-1-work.sh +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/bash -# ============================================================================= -# Mode 1: WORK -# ============================================================================= -# Dell = MBP (Thunderbolt) -# BenQ = MBP (HDMI 1) -# -# Use case: Normal work hours, both displays driven by Work MBP -# ============================================================================= - -source "$(dirname "$0")/helpers.sh" - -log_info "Switching to WORK mode (both displays → MBP)" - -# Validate config -if [[ -z "$DELL_TB" || -z "$BENQ_HDMI1" ]]; then - log_error "Missing DDC values in config.sh. Run discovery first." - exit 1 -fi - -# Step 1: Disconnect displays from Mini (so macOS Mini stops using them) -if is_host_reachable "$MINI_HOST"; then - log_info "Disconnecting displays from Mini..." - disconnect_both_remote "$MINI_HOST" -else - log_info "Mini not reachable, skipping disconnect" -fi - -# Step 2: Switch monitor inputs to MBP sources -log_info "Switching Dell to Thunderbolt input..." -switch_dell_local "$DELL_TB" -sleep 0.5 - -log_info "Switching BenQ to HDMI 1..." -switch_benq_local "$BENQ_HDMI1" - -# Step 3: Connect displays on MBP (in case they were disconnected) -# This runs locally assuming the script is executed on MBP -# If running from Mini, we'd need to call MBP via HTTP instead -current_machine=$(get_current_machine) -if [[ "$current_machine" == "mbp" ]]; then - log_info "Connecting displays locally on MBP..." - connect_both_local -elif is_host_reachable "$MBP_HOST"; then - log_info "Connecting displays on MBP via HTTP..." - connect_both_remote "$MBP_HOST" -fi - -log_info "WORK mode active" diff --git a/.config/display-modes/mode-2-split-air.sh b/.config/display-modes/mode-2-split-air.sh deleted file mode 100755 index ea1da8a..0000000 --- a/.config/display-modes/mode-2-split-air.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -# ============================================================================= -# Mode 2: SPLIT (MBP / Air) -# ============================================================================= -# Dell = MBP (Thunderbolt) -# BenQ = Air (USB-C) -# -# Use case: Work on primary display + personal laptop for research/reference -# ============================================================================= - -source "$(dirname "$0")/helpers.sh" - -log_info "Switching to SPLIT mode (Dell → MBP, BenQ → Air)" - -# Validate config -if [[ -z "$DELL_TB" || -z "$BENQ_USBC" ]]; then - log_error "Missing DDC values in config.sh. Run discovery first." - exit 1 -fi - -# Step 1: Disconnect BenQ from Mini (Dell stays disconnected too) -if is_host_reachable "$MINI_HOST"; then - log_info "Disconnecting displays from Mini..." - disconnect_both_remote "$MINI_HOST" -fi - -# Step 2: On MBP, disconnect BenQ but keep Dell connected -# (MBP only drives Dell in this mode) -if is_host_reachable "$MBP_HOST"; then - log_info "Configuring MBP: Dell connected, BenQ disconnected..." - connect_display_remote "$MBP_HOST" "$DELL_NAME" - disconnect_display_remote "$MBP_HOST" "$BENQ_NAME" -fi - -# Step 3: Switch monitor inputs -log_info "Switching Dell to Thunderbolt input..." -switch_dell_local "$DELL_TB" -sleep 0.5 - -log_info "Switching BenQ to USB-C input..." -switch_benq_local "$BENQ_USBC" - -# Note: Air's BenQ connection is managed by Air itself via USB-C -# The Air should have BenQ connected when plugged in - -log_info "SPLIT (MBP/Air) mode active" diff --git a/.config/display-modes/mode-3-split-mini.sh b/.config/display-modes/mode-3-split-mini.sh deleted file mode 100755 index 63b41a7..0000000 --- a/.config/display-modes/mode-3-split-mini.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/bash -# ============================================================================= -# Mode 3: SPLIT (MBP / Mini) -# ============================================================================= -# Dell = MBP (Thunderbolt) -# BenQ = Mini (HDMI 2 via USB-C adapter) -# -# Use case: Work on primary + glanceable personal desktop on secondary -# ============================================================================= - -source "$(dirname "$0")/helpers.sh" - -log_info "Switching to SPLIT mode (Dell → MBP, BenQ → Mini)" - -# Validate config -if [[ -z "$DELL_TB" || -z "$BENQ_HDMI2" ]]; then - log_error "Missing DDC values in config.sh. Run discovery first." - exit 1 -fi - -# Step 1: Configure Mini - only BenQ connected, Dell disconnected -if is_host_reachable "$MINI_HOST"; then - log_info "Configuring Mini: BenQ connected, Dell disconnected..." - disconnect_display_remote "$MINI_HOST" "$DELL_NAME" - connect_display_remote "$MINI_HOST" "$BENQ_NAME" -fi - -# Step 2: Configure MBP - only Dell connected, BenQ disconnected -if is_host_reachable "$MBP_HOST"; then - log_info "Configuring MBP: Dell connected, BenQ disconnected..." - connect_display_remote "$MBP_HOST" "$DELL_NAME" - disconnect_display_remote "$MBP_HOST" "$BENQ_NAME" -fi - -# Step 3: Switch monitor inputs -log_info "Switching Dell to Thunderbolt input..." -switch_dell_local "$DELL_TB" -sleep 0.5 - -log_info "Switching BenQ to HDMI 2..." -switch_benq_local "$BENQ_HDMI2" - -log_info "SPLIT (MBP/Mini) mode active" diff --git a/.config/display-modes/mode-4-nonwork.sh b/.config/display-modes/mode-4-nonwork.sh deleted file mode 100755 index 1c6048c..0000000 --- a/.config/display-modes/mode-4-nonwork.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# ============================================================================= -# Mode 4: NON-WORK -# ============================================================================= -# Dell = Mini (HDMI) -# BenQ = Mini (HDMI 2 via USB-C adapter) -# -# Use case: Evenings/weekends, freelance work, both displays driven by Mac Mini -# ============================================================================= - -source "$(dirname "$0")/helpers.sh" - -log_info "Switching to NON-WORK mode (both displays → Mini)" - -# Validate config -if [[ -z "$DELL_HDMI" || -z "$BENQ_HDMI2" ]]; then - log_error "Missing DDC values in config.sh. Run discovery first." - exit 1 -fi - -# Step 1: Disconnect displays from MBP (so macOS MBP stops using them) -if is_host_reachable "$MBP_HOST"; then - log_info "Disconnecting displays from MBP..." - disconnect_both_remote "$MBP_HOST" -else - log_info "MBP not reachable, skipping disconnect" -fi - -# Step 2: Switch monitor inputs to Mini sources -log_info "Switching Dell to HDMI input..." -switch_dell_local "$DELL_HDMI" -sleep 0.5 - -log_info "Switching BenQ to HDMI 2..." -switch_benq_local "$BENQ_HDMI2" - -# Step 3: Connect displays on Mini (in case they were disconnected) -current_machine=$(get_current_machine) -if [[ "$current_machine" == "mini" ]]; then - log_info "Connecting displays locally on Mini..." - connect_both_local -elif is_host_reachable "$MINI_HOST"; then - log_info "Connecting displays on Mini via HTTP..." - connect_both_remote "$MINI_HOST" -fi - -log_info "NON-WORK mode active" diff --git a/.config/display-modes/mode-5-nonwork-air.sh b/.config/display-modes/mode-5-nonwork-air.sh deleted file mode 100755 index 19b68f0..0000000 --- a/.config/display-modes/mode-5-nonwork-air.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash -# ============================================================================= -# Mode 5: ALT NON-WORK (Mini / Air) -# ============================================================================= -# Dell = Mini (HDMI) -# BenQ = Air (USB-C) -# -# Use case: Personal time with Mini on primary + Air on secondary -# ============================================================================= - -source "$(dirname "$0")/helpers.sh" - -log_info "Switching to ALT NON-WORK mode (Dell → Mini, BenQ → Air)" - -# Validate config -if [[ -z "$DELL_HDMI" || -z "$BENQ_USBC" ]]; then - log_error "Missing DDC values in config.sh. Run discovery first." - exit 1 -fi - -# Step 1: Disconnect both displays from MBP -if is_host_reachable "$MBP_HOST"; then - log_info "Disconnecting displays from MBP..." - disconnect_both_remote "$MBP_HOST" -fi - -# Step 2: Configure Mini - only Dell connected, BenQ disconnected -if is_host_reachable "$MINI_HOST"; then - log_info "Configuring Mini: Dell connected, BenQ disconnected..." - connect_display_remote "$MINI_HOST" "$DELL_NAME" - disconnect_display_remote "$MINI_HOST" "$BENQ_NAME" -fi - -# Step 3: Switch monitor inputs -log_info "Switching Dell to HDMI input..." -switch_dell_local "$DELL_HDMI" -sleep 0.5 - -log_info "Switching BenQ to USB-C input..." -switch_benq_local "$BENQ_USBC" - -# Note: Air's BenQ connection is managed by Air itself - -log_info "ALT NON-WORK (Mini/Air) mode active" diff --git a/bin/README.md b/bin/README.md index 3575970..a3cf45e 100644 --- a/bin/README.md +++ b/bin/README.md @@ -43,6 +43,18 @@ Desktop systems install full GUI apps (VS Code, 1Password). Server systems insta **Usage:** `unlock-keychain` **Description:** Unlocks the login keychain, useful for automation scripts that need keychain access. +### `display-wake` + +**Purpose:** Wake the macOS display (macOS only) +**Usage:** `display-wake` +**Description:** Wakes the display by asserting user activity via `caffeinate`. Works over SSH for remote triggering and integrates with automation tools. + +### `display-sleep` + +**Purpose:** Put the macOS display to sleep (macOS only) +**Usage:** `display-sleep` +**Description:** Puts the display to sleep immediately via `pmset displaysleepnow`. Works over SSH for remote triggering and integrates with automation tools. + ## Development Utilities ### `check-env` diff --git a/bin/display-sleep b/bin/display-sleep new file mode 100755 index 0000000..9262a8f --- /dev/null +++ b/bin/display-sleep @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Put the macOS display to sleep immediately. +# Useful for remote triggering via SSH or automation tools. +set -euo pipefail + +if [[ "$(uname -s)" != "Darwin" ]]; then + echo "Error: this script only works on macOS" >&2 + exit 1 +fi + +pmset displaysleepnow diff --git a/bin/display-wake b/bin/display-wake new file mode 100755 index 0000000..39a03c6 --- /dev/null +++ b/bin/display-wake @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +# Wake the macOS display by asserting user activity. +# Useful for remote triggering via SSH or automation tools. +set -euo pipefail + +if [[ "$(uname -s)" != "Darwin" ]]; then + echo "Error: this script only works on macOS" >&2 + exit 1 +fi + +caffeinate -u -t 2