diff --git a/home_dotfiles/.config/sway/config b/home_dotfiles/.config/sway/config index f140521..34e012d 100644 --- a/home_dotfiles/.config/sway/config +++ b/home_dotfiles/.config/sway/config @@ -63,6 +63,19 @@ set $menu fuzzel # File manager (Arch alternatives) set $filemanager thunar +# Defaults (kept here so the config still loads even if the included file is missing) +set $dp1_mode 3840x2160@165Hz +set $dp1_bar_height 40 +set $dp1_bar_font pango: FontAwesome, monospace 14 + +set $dp2_x 3840 +set $dp2_bar_height 24 +set $dp2_bar_font pango: FontAwesome, monospace 10 + +# Display/bar profile overrides (written by a toggle script). +# If this file doesn't exist, sway will just use the defaults below. +include /home/raga/.config/sway/display-profile.conf + ############################################################################### # Output configuration ############################################################################### @@ -81,11 +94,11 @@ output DP-1 { # mode 2560x1440@60Hz # FULL - mode 3840x2160@165Hz + mode $dp1_mode } output DP-2 { - position 3840 0 + position $dp2_x 0 # ECO # mode 2560x1440@60Hz @@ -510,9 +523,9 @@ bar { output DP-1 position bottom mode dock - height 40 + height $dp1_bar_height #font pango:monospace 10 - font pango: FontAwesome, monospace 14 + font $dp1_bar_font separator_symbol " " strip_workspace_numbers yes workspace_min_width 36 @@ -537,9 +550,9 @@ bar { output DP-2 position bottom mode dock - height 24 + height $dp2_bar_height #font pango:monospace 10 - font pango: FontAwesome, monospace 10 + font $dp2_bar_font separator_symbol " " strip_workspace_numbers yes workspace_min_width 36 diff --git a/home_dotfiles/.config/sway/display-profile-status.sh b/home_dotfiles/.config/sway/display-profile-status.sh new file mode 100644 index 0000000..58ffa6c --- /dev/null +++ b/home_dotfiles/.config/sway/display-profile-status.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +set -euo pipefail + +PROFILE_FILE="/home/raga/.config/sway/display-profile.conf" + +mode_str="" +if [[ -f "$PROFILE_FILE" ]]; then + mode_str="$(awk '$1=="set" && $2=="$dp1_mode" {print $3; found=1} END {if(!found) print ""}' "$PROFILE_FILE" 2>/dev/null)" +fi + +# Display-related FontAwesome icon + a short label. +case "$mode_str" in + 3840x2160@*|4096x2160@*) echo " 4K";; + 1920x1080@*) echo " 1080p";; + "") echo "";; + *) echo " ${mode_str}";; +esac diff --git a/home_dotfiles/.config/sway/display-profile-toggle.sh b/home_dotfiles/.config/sway/display-profile-toggle.sh new file mode 100644 index 0000000..0ae1d97 --- /dev/null +++ b/home_dotfiles/.config/sway/display-profile-toggle.sh @@ -0,0 +1,75 @@ +#!/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/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 "$@" diff --git a/home_dotfiles/.config/sway/display-profile.conf b/home_dotfiles/.config/sway/display-profile.conf new file mode 100644 index 0000000..2557d19 --- /dev/null +++ b/home_dotfiles/.config/sway/display-profile.conf @@ -0,0 +1,13 @@ +# This file is intended to be rewritten by scripts (see display-profile-toggle.sh). +# Keep it small so the toggle is fast. + +# DP-1 (4K / gaming output) +set $dp1_mode 3840x2160@165Hz +set $dp1_bar_height 40 +set $dp1_bar_font pango: FontAwesome, monospace 14 + +# DP-2 (secondary output) +set $dp2_x 3840 +set $dp2_bar_height 24 +set $dp2_bar_font pango: FontAwesome, monospace 10 + diff --git a/home_dotfiles/.config/sway/i3status-rust.toml b/home_dotfiles/.config/sway/i3status-rust.toml index 423379e..5a7739d 100644 --- a/home_dotfiles/.config/sway/i3status-rust.toml +++ b/home_dotfiles/.config/sway/i3status-rust.toml @@ -10,6 +10,15 @@ click = [ {button = "left", cmd = "~/.config/sway/osrs-mode-toggle.sh", update = true} ] +[[block]] +block = "custom" +command = "~/.config/sway/display-profile-status.sh" +format = " $text " +interval = 1 +click = [ + {button = "left", cmd = "~/.config/sway/display-profile-toggle.sh", update = true} +] + [[block]] block = "custom" command = "echo ''"