A declarative window instantiation utility for x11 sessions, heavily inspired by tmuxp.
Project description
xsessionp
Overview
A declarative window instantiation utility for x11 sessions, heavily inspired by tmuxp.
Installation
From pypi.org
$ pip install xsessionp
From source code
$ git clone https://github.com/crashvb/xsessionp
$ cd xsessionp
$ virtualenv env
$ source env/bin/activate
$ python -m pip install --editable .[dev]
Usage
TL;DR
Define a configuration file(s) declaring the desired end state:
# ~/.xsessionp/example.yml
---
desktop: 0
environment:
xsp: makes_life_easy
windows:
- command:
- /usr/bin/xed
- --new-window
copy_environment: false
focus: true
dimensions: 926x656
hints:
name: ^Unsaved Document.*
position: 166,492
- command:
- /usr/bin/gnome-terminal
- --
- tmux
desktop: 0
environment:
GNOME_TERMINAL_SCREEN: ""
dimensions: 1174x710
hints:
name: ^Terminal$
class: ^\['gnome-terminal-server', 'Gnome-terminal'\]$
position: 213,134
shell: true
start_directory: /tmp
A configuration can be instantiated using the load command:
$ xsp load example
Loading: /home/user/.xsessionp/example.yml
Commands
This packages makes available the xsessionp
command, and the shorter xsp
alias.
A listing of commands is available by executing: xsp --help
. Command-specific usage is available by executing --help
after the command (e.g.: xsp ls --help
).
close-window
Closes a managed window(s).
$ xsp close-window --target /home/user/.xsessionp/example.yml:window[0]:262512556
Closed window: 119537674
learn
Capture metadata from a graphically selected window. Intended to assist with developing workspace configurations.
$ xsp learn
---
windows:
- command:
- nemo
- /home/user
desktop: 0
dimensions: 1667x918
environment:
- DBUS_SESSION_BUS_ADDRESS=unix:path /run/user/1000/bus
hints:
name: ^Home$
position: 1717,264
list-windows
Lists managed windows in a given format.
$ xsp list-windows
ID XSP:NAME DESKTOP POSITION DIMENSIONS NAME
119537674 /tmp/tmpqf3bcpzt/xclock.yml:window[0]:262512556 0 [25, 49] [300, 300] xclock
138412043 /tmp/tmpqf3bcpzt/xclock.yml:window[1]:262512711 0 [25, 399] [300, 40] xclock
load
Loads an xsessionp workspace for each instance of CONFIG specified.
$ xsp load example
Loading: /home/user/.xsessionp/example.yml
ls
Lists xsessionp workspace(s) discovered within each default configuration directory.
$ xsp ls
example
$ xsp ls --qualified
/home/user/.xsessionp/example.yml
reposition-window
Aligns the current position of a managed window(s) to match the embedded metadata.
$ xsp reposition-window -t /tmp/tmpqf3bcpzt/xclock.yml:window[0]:262512556
Repositioned window: 119537674
test
Perform basic acceptance tests by launching two xclock instances on the current desktop
$ xsp test
...
Loading: /tmp/tmpqf3bcpzt/xclock.yml
version
$ xsp version
x.y.z
Configuration
Any key defined at the root level (globals) will propagate to all windows as the default value for that key.
Globals can be overridden in individual window configurations (locals), or omitted by added a key with a "no_" prefix (e.g.: no_dimensions).
Keys with a no_
prefix have a higher precedence then those without.
command (type: list
, str
)
Command used to launch the window. Provided as args
to subprocess.Popen.
copy_environment (type: bool
, default: True
)
If true, the environment of xsessionp will be used as the base for launched windows. Otherwise, and empty environment will be used instead. This does not affect values declared via environment.
desktop (type: int
)
The X11 desktop to be assigned to the launched window. If not provided, desktop assignment is not performed, and defaults to the behavior of the underlying window manager.
dimensions (type: str
)
The dimensions (geometry) to assigned to the launched window. Values should take the form of {width}x{height}
or {width},{height}
. If not provided, no sizing is performed.
disabled (type: bool
, default: False
)
If true, the window will not be selected when the configuration is loaded. This is intended to allow complex window configuration(s) to remain inline without needing to comment them.
environment (type Dict[str, str]
)
Key value pairs to be provided via the environment of the launched window. These values have precedence over the "base" environment; see copy_environment.
focus (type: bool
, default: False
)
If true, the window will be activated after all windows have been launched. If more than one window contains this value, the value is ignored.
hint_method (type: enum
, values: AND
, OR
)
Boolean method by which hints are evaluated.
hints (type: Dict[str, str]
)
Distinguishing characteristics of the launched window that can be used to identify (guess) amongst otherwise ambiguous deltas.
Deterministically identifying the X11 window(s) that are created when a process is launched is difficult. Often the WM_PID
atom is missing, or doesn't align with the PID of the process that was invoked, for various reasons.
As such, a listing of X11 windows is captured both before and after the process is executed, and the difference (delta) is used to guess the correct window. If the size of the delta is equal to 1, then it is assumed to correspond to the execute process.
If the size of the delta is greater than 1, then these hints are used to restrict which window is selected.
Common hints include: class
, name
, state
, and type
. Hint values are compiled into regular expression patterns prior to evaluating.
name (type: str
, default: generated)
Name (xsp:name
) use to select windows when the configuration is loaded, and to identify the window when executing commands.
position (type: str
)
The position to assigned to the launched window. Values should take the form of {x},{y}
or {x},{y}
. If not provided, no positioning is performed.
search_delay (type: float
, default: 0
)
The amount of time, in seconds, to wait before searching for launched windows. See hints for an explanation of the methodology.
shell (type: bool
, default: False
)
If true, command will be executed via a shell. Provided as shell
to subprocess.Popen.
snapped (type: bool
, default: False
)
If true, supporting window managers will be instructed to snap, rather than tile, the launched window.
start_directory (type: str
, default: /
)
The working directory of the launched window. Provided as cwd
to subprocess.Popen.
start_timeout (type: int
, default: 3
)
The maximum amount of time, in seconds, to wait for launched windows to be visible, prior to sizing and positioning.
tile (type: str
)
Mode to use when tiling the launched window. Tiling occurs after window sizing and positioning. If not specified, no tiling is performed.
Supported Tiling Modes
Linux Mint Cinnamon: BOTTOM
, LEFT
, LEFT_BOTTOM
, LEFT_TOP
, MAXIMIZE
, NONE
, RIGHT
, RIGHT_BOTTOM
, RIGHT_TOP
, TOP
Environment Variables
Variable | Default Value | Description |
---|---|---|
XSESSIONP_CONFIGDIR | ~/.xsessionp | xsessionp configuration directory. |
Development
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
Built Distribution
File details
Details for the file xsessionp-0.1.3.tar.gz
.
File metadata
- Download URL: xsessionp-0.1.3.tar.gz
- Upload date:
- Size: 42.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64c345b91008edc0e58d9e52848fc72370825829ee3f1afef8dde3ca4c4e9030 |
|
MD5 | ec569d802381c28d6b2c73fb7047200f |
|
BLAKE2b-256 | fc521977cc6224a86e5150c5a9a25ca4a30e215d0ef97955531473ad44e65063 |
File details
Details for the file xsessionp-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: xsessionp-0.1.3-py3-none-any.whl
- Upload date:
- Size: 47.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99a7e33d5c03e7fa6897dc809923559001a13d9b5bb2a1724834658775dcc4b3 |
|
MD5 | 017c9d5054af2a8370fcc95a358b3577 |
|
BLAKE2b-256 | 34c4c049e3a88b51bb7fdf3856e771ae593400d2c3eda377a5a5bb28b60dc38f |