When using X11 launch and application at a particular location
Project description
x-open-point
@readwithai - X - blog - machine-aided reading
Open an application at a particular location and with a particular size when using X11.
Motivation
I was experimenting with positioning applications at particular positions in the interests of productivity while writing a blog post. Many applications support a --geometry option, however I found that this was far from always the cause and some applications like the popular image viewer feh did not support different gravities (i.e. you could not use a - for positions).
I decided to write a wrapper which externally start an application at a particular location.
Alternatives and prior work
wmctrl can move and resize a windows with the -e option. I am not aware of any tools that launch an application and then match the window id to the process id like this tool does.
Many applications have a -geometry or --geometry to provide this functionality but this is determined on an application-by-application basis, may be missing, and the features and inconsistent.
This application was partically inspired by the kstart launcher in KDE that launches an application while setting a few properties - though not the geometry.
Installation
You can install x-open-point with pipx:
pipx install x-open-point
Usage
The size and location for a window is specified using a syntax similar to X11 geometries.
To open xterm at 100 pixels from the left and 200 pixels from the top you can use:
x-open-point +100+200 xterm
node the plus sign before 100. This indicates that this is a distance from the left.
To open a window that is 200 pixels wide and 800 pixels tall you can run:
x-open-point 200x800 xterm
To open a window at the top-right corner you can use
x-open-point -0+0 xterm
Similarly you can use -0-0 for the bottom-right and +0-0 for the bottom-left.
To place the window at 100 from the left and 200 from the top and have it 300 pixels wide and 400 pixels high you can use:
x-open-point 300x400+100+200 xterm
In general, if you and expression of the form
expression := height "x" width x_gravity X y_gravity Y
height, width, X, Y := integer | percentage
x_gravity, y_gravity := "+" | "-"
An x_gravity of + means that the horizontal is from the left side of the screen to the window, - from the right side of the screen. Similarly for y_gravity.
X is the horizontal distance from a screen edge to the window.
Y is the vertical distance.
Support
If you found this tool useful, you could support it by giving me money ($3 maybe) on my ko-fi.
You could also my tools json-wmctrl which lists windows with additional information, or json-xwininfo. Or read some of my writing on how to take effective notes in Obsidian.
I've personally found that Obsidian has allowed me for drive-by note taking while coding quite valuable. You could read something I wrote about this on my blog.
About me
I am @readwithai, I make tools related to reading, research and agency sometimes using Obsidian.
You can follow me on X on my blog.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file x-open-point-1.1.1.tar.gz.
File metadata
- Download URL: x-open-point-1.1.1.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
089e9d3315cac249314b3d07a143fa7439fa55ce130046854de37576c6aaf685
|
|
| MD5 |
eaee47f4d2056cdd060bd21600740fe2
|
|
| BLAKE2b-256 |
edac00831ddbe03ac273e84eb17fa2ebfdd80299ccdcdf015454c81b88c10951
|