Skip to main content

When using X11 launch and application at a particular location

Project description

x-open-point

@readwithai - X - blog - [machine-aided reading](https://www.reddit.com/r/machineAidedReading/

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

x-open-at-1.0.1.tar.gz (4.8 kB view details)

Uploaded Source

File details

Details for the file x-open-at-1.0.1.tar.gz.

File metadata

  • Download URL: x-open-at-1.0.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for x-open-at-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d48e4724b5e26f6aa2d82071b5996d5e1909bb5db18561e1bd7b4b4661fae8a2
MD5 37d2cb96996298eec0b17e221cf2bc38
BLAKE2b-256 da322d4b798b4d00394ca7c5965954c01339d589e88207b6eb4d885f25a40d57

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page