Created
September 2, 2025 00:11
-
-
Save meyt/b40139b9f1b34a0ade62cc5b7d47dfeb to your computer and use it in GitHub Desktop.
Fix xfce/xfwm lost maximized window state after second display attached/detached
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Get list of maximized windows (both horizontal and vertical) | |
| wmctrl -l | while read -r id desktop hostname title; do | |
| # Check if window is maximized (both directions) | |
| net_wm_state=$(xprop -id "$id" _NET_WM_STATE 2>/dev/null) | |
| if [[ "$net_wm_state" == *"_NET_WM_STATE_MAXIMIZED_HORZ"* ]] && \ | |
| [[ "$net_wm_state" == *"_NET_WM_STATE_MAXIMIZED_VERT"* ]]; then | |
| echo "Processing window: $title ($id)" | |
| # Unmaximize the window | |
| wmctrl -ir "$id" -b remove,maximized_vert,maximized_horz | |
| echo " → Unmaximized" | |
| # Wait 500ms | |
| sleep 0.5 | |
| # Maximize again | |
| wmctrl -ir "$id" -b add,maximized_vert,maximized_horz | |
| echo " → Remaximized" | |
| fi | |
| done | |
| echo "Operation completed" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment