Tomas-M / xlunch

Graphical app launcher for X with minimal dependencies
http://xlunch.org
GNU General Public License v3.0
219 stars 37 forks source link

Easy way to center the window? #125

Open Botspot opened 3 years ago

Botspot commented 3 years ago

Yad has a useful flag: --center. It puts the window in the center of the screen.

I want to specify width and height for xlunch in windowed mode, but don't want my script to have to calculate the correct --xposition and --yposition to put it in the center of the screen.
Please consider adding a --center flag to xlunch.

PMunch commented 3 years ago

Hmm, another one of those things I've just never thought about as I've never tried using xlunch as an application. I guess we could add the switch and use it to set some WM hints to try and specify that we want to be centered. But calculating the actual center is a pain as you then need to integrate with xrandr to get monitors and such. It's not a perfect solution, but it should do what you expect on most normal WMs.

Botspot commented 3 years ago

Here's what I'm currently doing: (bash script)

screen_width="$(xdpyinfo | grep 'dimensions:' | tr 'x' '\n' | tr ' ' '\n' | sed -n 7p)"
screen_height="$(xdpyinfo | grep 'dimensions:' | tr 'x' '\n' | tr ' ' '\n' | sed -n 8p)"
height=700
width=800
xposition=$(((screen_width/2)-(width/2)))
yposition=$(((screen_height/2)-(height/2)))
xlunch -W --width $width --height $height --xposition $xposition --yposition $yposition

Maybe that would help you - who knows.

PMunch commented 3 years ago

The problem here is what xdpyinfo does, which we would need to build into xlunch for this feature. I have this feature in Notifishower, so I know how to implement it, but I'm not sure if it's worth it (especially since this is something that can be scripted).