Xfce Forum

Sub domains
 

You are not logged in.

#1 2017-04-19 07:34:12

tastyminerals
Member
Registered: 2017-04-19
Posts: 2

[SOLVED] How to centrify a window in XFCE?

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)

Offline

#2 2017-04-19 10:17:10

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 10,949

Re: [SOLVED] How to centrify a window in XFCE?

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.


Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2017-04-19 10:23:12

tastyminerals
Member
Registered: 2017-04-19
Posts: 2

Re: [SOLVED] How to centrify a window in XFCE?

I see. Thank you for the solution.

Offline

Board footer

Powered by FluxBB