Tips and Tricks from the Xfce Forum
Re: Tips and Tricks from the Xfce Forum
Thanks. Just to be clear: I didn't create the script, just linked to it. Most of those on the Wiki site go back to Xfce 4.12 and GTK2, so much has changed in the meantime.
Production: 5.10, MX-23 Xfce, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 16 GB, SSD 120 GB, Data 1TB
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin
Personal: Lenovo X1 Carbon with MX-23 Fluxbox and Windows 10
Other: Raspberry Pi 5 with MX-23 Xfce Raspberry Pi Respin
Re: Center a window using the keyboard
This script does not work for my two monitors b/c " xdpyinfo | grep dimensions" gives me a combined dimension of both screens.JRG wrote: ↑Thu May 07, 2020 2:22 pm While the script may have worked in the past, it now does not. There may have been issues (e.g., "smart quotes") when the script was copied into the post. In the process of debugging it for my own use, I found a number of things in the script and rewrote it (based on the script posted by Jerry3904). I assigned it to the Right Win key.
Here it is:Code: Select all
#!/bin/bash # Based on the script by Jerry3904 IFS='x'; read screenWidth screenHeight < <(xdpyinfo | grep dimensions | grep -o '[0-9x]*' | head -n1) winId=`xdotool getactivewindow` width=$(xdotool getwindowgeometry -shell $winId | head -4 | tail -1 | sed 's/[^0-9]*//') height=$(xdotool getwindowgeometry -shell $winId | head -5 | tail -1 | sed 's/[^0-9]*//') newPosX=$((screenWidth/2-width/2)) newPosY=$((screenHeight/2-height/2)) xdotool windowmove $winId $newPosX $newPosY
So the script moves the window in the center of/between both monitors.
Here is and adjusted and slightly shorter version which moves the window into the center of the primary monitor:
Code: Select all
#!/bin/bash
# this script moves the active window into center of the primary monitor
# inspired by mx-linux forum memember JRG within this thread:
# https://forum.mxlinux.org/viewtopic.php?p=573895#p573895
#
eval $(xdotool getactivewindow getwindowgeometry --shell --prefix=WIN_)
eval $(xdotool getdisplaygeometry --shell)
xdotool getactivewindow windowmove $(( ($WIDTH - $WIN_WIDTH)/2 )) $(( ($HEIGHT - $WIN_HEIGHT)/2 ))
Gigabyte Z77M-D3H, Intel Xeon E3-1240 V2 (Quad core), 32GB RAM,
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB
GeForce GTX 770, Samsung SSD 850 EVO 500GB, Seagate Barracuda 4TB
Re: Tips and Tricks from the Xfce Forum
@Fehlix
Nicely done.
Nicely done.