Fixing where windows come up on RHEL 9

Thomas Cameron thomas.cameron at camerontech.com
Mon Jan 22 23:58:27 CET 2024


Thanks, Ralf, I appreciate it!

-- 
Thomas

On 1/22/24 16:31, Ralf Mardorf wrote:
> Hi,
> 
> years ago I wrote a script to ensure that windows that open with the
> title bar (or more) below a top panel, get moved below the panel.
> 
> When using X it's possible to automatically move windows wherever you
> want by using a combination of xdotool and wmctrl.
> 
> The script at the end of this email isn't well written and the
> combination of xdotool and wmctrl has it's pitfalls as well, but it at
> least works for me to move the extcalc and hdspmixer windows. I also
> wrote several other scripts using a combination of xdotool and wmctrl.
> It's usually easy to get what you want, even with quickly typed, clumsy
> scripts that you actually wanted to rewrite, but since they do what they
> are supposed to do, you never did it.
> 
> You are unlikely using fbpanel too, so you likely need to override the
> desktop file of each application or you need to find another workaround.
> 
> FWIW the below script does reposition the script, but you need to edit
> the values to position a window in the middle of the screen and one of
> the already mentioned pitfalls is, that there might be a drift, the
> windows might not open exactly where they should open.
> 
> Regards,
> Ralf
> 
>rocketmouse at archlinux ~
> $ grep window2unhide\ \" ~/.config/fbpanel/lcd-realignment
> 	      action = window2unhide "extcalc"
>        action = window2unhide "hdspmixer"
>rocketmouse at archlinux ~
> $ cat /usr/local/bin/window2unhide
> #!/bin/dash
> 
> # window2unhide 2017-08-25 Ralf Mardorf
> 
> # To configure window2unhide you could use /etc/profile.d/window2unhide.sh
> #
> # values of the wanted x and y position of the window
> # export WINDOW2UNHIDE_X_POS=hold
> # export WINDOW2UNHIDE_Y_POS=141
> #
> # delay required to ensure that a launched application's window is active
> # export WINDOW2UNHIDE_SLEEP=1
> #
> # values to eliminate x and y drift of the window
> #   this fix is needed for all windows
> # export WINDOW2UNHIDE_X_FIX=2
> # export WINDOW2UNHIDE_Y_FIX=54
> #
> # offset required to eliminate x and y drift of the window if x and/or y do/does not change
> #   this offset is needed for windows that open under the top panel
> #     but its unfavorable for windows that don't open under the top panel
> # export WINDOW2UNHIDE_X_OFF=1
> # export WINDOW2UNHIDE_Y_OFF=25
> 
> unhide_window ()
> {
>    # values of the wanted x and y position of the window
>    case $WINDOW2UNHIDE_X_POS in
>      ""|hold)
>        WINDOW2UNHIDE_X_POS=$X
>      ;;
>    esac
>    case $WINDOW2UNHIDE_Y_POS in
>      "")
>        WINDOW2UNHIDE_Y_POS=141
>      ;;
>      hold)
>        WINDOW2UNHIDE_Y_POS=$Y
>      ;;
>    esac
> 
>    # value to eliminate x drift of the window
>    case $WINDOW2UNHIDE_X_FIX in
>      "")
>        WINDOW2UNHIDE_X_FIX=2
>      ;;
>    esac
> 
>    # calculate value for x position of the window...
>    case $WINDOW2UNHIDE_X_POS in
>      $X) # ...if the x position doesn't change subtract the value to eliminate x drift and add an offset
>        case $WINDOW2UNHIDE_X_OFF in
>        "")
>          WINDOW2UNHIDE_X_OFF=1
>        ;;
>        esac
>        X_POS=$(expr $WINDOW2UNHIDE_X_POS - $WINDOW2UNHIDE_X_FIX + $WINDOW2UNHIDE_X_OFF)
>      ;;
>      *) # ...if the x position does change subtract the value to eliminate x drift
>        X_POS=$(expr $WINDOW2UNHIDE_X_POS - $WINDOW2UNHIDE_X_FIX)
>      ;;
>    esac
> 
>    # value to eliminate y drift of the window
>    case $WINDOW2UNHIDE_Y_FIX in
>      "")
>        WINDOW2UNHIDE_Y_FIX=54
>      ;;
>    esac
> 
>    # calculate value for y position of the window...
>    case $WINDOW2UNHIDE_Y_POS in
>      $Y) # ...if the y position doesn't change subtract the value to eliminate y drift and add an offset
>        case $WINDOW2UNHIDE_Y_OFF in
>          "")
>            WINDOW2UNHIDE_Y_OFF=25
>          ;;
>        esac
>        Y_POS=$(expr $WINDOW2UNHIDE_Y_POS - $WINDOW2UNHIDE_Y_FIX + $WINDOW2UNHIDE_Y_OFF)
>      ;;
>      *) # ...if the x position does change subtract the value to eliminate x drift
>        Y_POS=$(expr $WINDOW2UNHIDE_Y_POS - $WINDOW2UNHIDE_Y_FIX)
>      ;;
>    esac
> 
>    # move the window to new position
>    wmctrl -i -r $WINDOW -b remove,maximized_vert,maximized_horz
>    wmctrl -i -r $WINDOW -e "0,$X_POS,$Y_POS,$WIDTH,$HEIGHT"
> }
> 
> case $1 in
>    "") # unhide active window
>      eval $(xdotool getwindowgeometry --shell $(xdotool getactivewindow))
>      unhide_window
>    ;;
>    *)  # launch an application and unhide its window
>      case $WINDOW2UNHIDE_SLEEP in
>        "")
>          WINDOW2UNHIDE_SLEEP=1
>        ;;
>      esac
>      $@ &
>      sleep $WINDOW2UNHIDE_SLEEP # ensure that the window of the launched application...
>      eval $(xdotool getwindowgeometry --shell $(xdotool getactivewindow))
>      wmctrl -l | grep $(printf '%x\n' $WINDOW) | grep -qi $1 # ...is the active window
>      case $? in
>        0)
>          unhide_window
>        ;;
>      esac
>    ;;
> esac
> exit
> _______________________________________________
> Xfce mailing list
> Xfce at xfce.org
> https://mail.xfce.org/mailman/listinfo/xfce
> http://www.xfce.org


More information about the Xfce mailing list