0 purchases
xsessionp 0.1.4
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 executed 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}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
Source Control
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.