Window Position Session

Yesterday I finally sat down to properly set up some mechanisms to restore my desktop and the window arrangements on all workspaces (I use four). I use GNOME and it features Startup Applications, allowing to run everything at login. Cool, but now all those applications are slapped into the first workspace, with window positions and sizes all over the place, so I started googling, and a few links down found this post on Mattman's blog.

He also explains how to set up Startup Applications (and give terminals specific titles) and provides two scripts to save and restore window geometry and put them on the right workspace. It was just what I needed, but there were three problems I had, which weren't solved by the scripts yet:

wnckprop

I looked at his scripts and they use a tool called wnckprop, which in Ubuntu 9.04 for instance can be obtained by

~> sudo apt-get install libwnck-dev

wnckprop apparently follows EWMH specifications, so my script might work with KDE as well. I haven't tried that, but if you do, please comment.

Usage

Usage is straightforward:

~> ./window_position.py --help

Gives some help...

Usage: window_position.py [options] [file]

Options:
  -h, --help            show this help message and exit
  -s, --save            save all window positions
  -r, --restore         restore all window positions
  -i, --case-insensitive
                        case insensitive window title matching

file is optional. If not given, then -r will read from stdin and -s will write to stdout.

Saving

Using -s will result in a conf file with one section per window, the section name is the window title:

...
[Terminal]
x = 123
y = 50
width = 500
height = 400
workspace = 0

[Amarok - The Times They Are A-Changin' by Bob Dylan]
x = 50
y = 50
width = 600
height = 500
workspace = 1
actions = pin
...

Restoring

This file can now be used with -r to restore the exact arrangements again. Tho you usually want to edit it and only use the windows and attributes you really want to set.

Title Matching

Sections can have spaces, so no problem there. It is also possible to use regular expressions in those section names, so this would be more useful:

[Amarok .*]
x = 50
y = 50
width = 600
height = 500
workspace = 1
actions = pin

NOTE! due to the way ConfigParser parses the conf file there is no way to determine the order of the sections (at least not that I could see in the docs), so you can't just overwrite attributes:

WRONG:

[Terminal .*]
x = 0
y = 0
workspace = 3

[Terminal 1]
x = 50
y = 60

[Terminal 2]
x = 500
y = 60

This might produce odd results, if Terminal.* is looked at -after- one of the others, resetting the x and y attributes again. Use distinct sections:

CORRECT:

[Terminal .*]
workspace = 3

[Terminal 1]
x = 50
y = 60

[Terminal 2]
x = 500
y = 60

Actions

You can add several actions like so:

[Terminal]
actions = pin, minimize, unmake above

Which would pin the window to all workspaces, minimize it, and make sure it isn't set to above (always on top). See below for a reference of all available actions.

Example

Here's a snippet of what I use:

# all 'Dev Terminal *' terminals go to workspace 1,
# have same dimensions
[Dev Terminal .*]
workspace = 1
width = 700
height = 480

# then arrange them top-left, top-right, bottom-right, bottom-left
[Dev Terminal 1]
x = 0
y = 0

[Dev Terminal 2]
x = 983
y = 0

[Dev Terminal 3]
x = 983
y = 548

[Dev Terminal 4]
x = 0
y = 548

# Eclipse is put somewhere in the middle on the same workspace
[.*Eclipse.*]
workspace = 1
x = 232
y = 102
width = 1219
height = 838

# KVIrc is on the first workspace and maximized
[KVIrc.*]
workspace = 0
actions = maximize

# my Pidgin window initially is opened, but I want it closed,
# this will only close the window, Pidgin will still by in the Panel
[Buddy List]
actions = close

# Amarok should be available on all workspaces and initially minimized
[Amarok.*]
actions = pin, minimize

Reference

x         = 0
y         = 0
width     = 500
height    = 500
workspace = 2 (usually starts at 0)
actions   = close, move, shade, unshade,
            maximize horizontally, unmaximize horizontally,
            maximize vertically, unmaximize vertically,
            pin, unpin, minimize, unminimize, maximize, unmaximize,
            make above, unmake above,
            make below, unmake below

To Do

There's a slight problem with wnckprop when reading the x and y values. If I put a window to the top left of the workspace, for instance, then I get the y value 25, because of the Panel that is still above the window. But when it then sets y to 25, it actually ends up 25 down relative to the Panel. The solution is to put y = 0 manually.

I'd also like to find a way to specify the tab order in the bottom Panel. wnckprop can't handle that, I don't think, so if anyone has an idea for that: please comment. As an example: I'd like to have Dev Terminal 1, Dev Terminal 2, Dev Terminal 3, Dev Terminal 4 as tabs in that order, but GNOME's Startup Applications of course don't guarantee any order.

 

Comments

Show older comments

AlfredMop 03:40 March 23, 2017

wh0cd198927 <a href=http://cafergot2014.top/>found it for you</a> <a href=http://buyproscar2012.top/>buy proscar</a> <a href=http://buyrimonabant2012.top/>buy acomplia rimonabant</a>

BennyGep 04:05 March 23, 2017

wh0cd486611 <a href=http://hydrochlorothiazide2017.bid/>hydrochlorothiazide</a> <a href=http://cafergot2017.bid/>buy cafergot online</a> <a href=http://adalat17.science/>adalat online</a>

AaronBow 04:53 March 23, 2017

wh0cd614487 <a href=http://buytretinoin.us.com/>buy tretinoin</a>

BennyGep 05:17 March 23, 2017

wh0cd550541 <a href=http://allopurinol-247.us/>allopurinol</a> <a href=http://buyatarax7.us/>atarax</a> <a href=http://buyadalat100.us/>web site</a> <a href=http://cephalexin2.top/>cephalexin</a> <a href=http://buyadvair-365.us/>buy advair diskus online</a>

Eugenekit 05:21 March 23, 2017

wh0cd16218 <a href=http://chloroquine.science/>chloroquine malaria prophylaxis</a>

Add comment