#!/usr/bin/env bash set -euo pipefail # Toggle DP-1 between 4K@165 and 1080p@330 and keep DP-2 positioned flush so # you don't get a "dead gap" for the mouse. PROFILE_FILE="/home/raga/.config/sway/scripts/display-profile/display-profile.conf" MODE_4K="3840x2160@165Hz" MODE_GAME="1920x1080@330Hz" # Bar tuning per mode BAR_HEIGHT_4K="40" BAR_FONT_4K="pango: FontAwesome, monospace 14" BAR_HEIGHT_GAME="16" BAR_FONT_GAME="pango: FontAwesome, monospace 8" # DP-2 bar settings (static) DP2_BAR_HEIGHT="24" DP2_BAR_FONT="pango: FontAwesome, monospace 10" get_current_profile_mode() { # Reads the last-written profile state instead of querying the monitor. # This makes toggling deterministic even if the display reports odd modes. if [[ ! -f "$PROFILE_FILE" ]]; then echo "$MODE_4K" return fi # Example line: set $dp1_mode 3840x2160@165Hz awk '$1=="set" && $2=="$dp1_mode" {print $3; found=1} END {if(!found) exit 1}' "$PROFILE_FILE" 2>/dev/null \ || echo "$MODE_4K" } write_profile() { local dp1_mode="$1" local dp1_bar_height="$2" local dp1_bar_font="$3" local dp2_x="$4" local tmp tmp="$(mktemp)" cat >"$tmp" </dev/null } main "$@"