I am running xfce 4.12 desktop and actively using keyboard to reposition my windows. Unfortunately, this is one of xfce weakest spots since in comparison to openbox it either hides or does not have the same amount of window moving functions. Since on my other machine I use openbox and `Win-c` keybind to center the window I wanted the same functionality in xfce alas could not find it via settings manager. So, how can I center a window in xfce via keyboard?
Last edited by tastyminerals (2017-04-19 10:22:13)
Hello and welcome.
You can use a script like this (requires xdotool):
#!/bin/bash IFS='x' read screenWidth screenHeight < <(xdpyinfo | grep dimensions | grep -o '[0-9x]*' | head -n1) width=$(xdotool getactivewindow getwindowgeometry --shell | head -4 | tail -1 | sed 's/[^0-9]*//') height=$(xdotool getactivewindow getwindowgeometry --shell | head -5 | tail -1 | sed 's/[^0-9]*//') newPosX=$((screenWidth/2-width/2)) newPosY=$((screenHeight/2-height/2)) xdotool getactivewindow windowmove "$newPosX" "$newPosY"
...save it somewhere (/usr/local/bin if you want all users to access it), make it executable and assign it to a keyboard shortcut. It will centre the currently active window.
I see. Thank you for the solution.