You are not logged in.

#1 2009-08-23 22:06:59

BurntSushi
Member
From: Massachusetts
Registered: 2009-06-28
Posts: 362
Website

PyTyle: Manual tiling manager for EWMH compliant WM's

Introducing PyTyle - a manual tiling manager inspired by XMonad; written in Python. PyTyle will sit in the background and allow you to manage your windows in much same fashion as XMonad- on a per screen basis. PyTyle will not do anything with your windows until you enable tiling on your screen.

What you need:

Python and the Python X Library.

Any EWMH compliant window manager. I personally use OpenBox, so PyTyle is going to work on that the best. I've also done some testing with Fluxbox and PekWM. Fluxbox appears to support it as flawlessly as OpenBox, and PekWM has pretty good support. (Looks like full functionality, although the window alignment is a bit off because PekWM isn't reporting window decoration sizes correctly- as far as I know.) I've also tried it with Compiz for kicks, and it doesn't work too well. (Compiz uses virtual desktops, or viewports, instead of desktops. Desktops *can* be used, but it appears that it would also remove much of the neat functionality of Compiz if you did so. The good news is that it looks like Compiz can be supported in the future- bearing that there's some demand for it to make it worth my time.) I haven't tested it with any other window manager yet, but I have plans to do so. If you've gotten it working on a window manager I haven't reported here, please let me know!

How it works:

When tiling is enabled for a screen, PyTyle will automatically organize all of your windows into two sets (masters and slaves), and organize your windows to use up your screen real estate. By default, one window is put into the "master" set, and the rest are put into the "slave" set. From there, you can increase/decrease the area of the masters, or even increase/decrease the number of windows in the master area (from 0 masters to all current windows). This is exactly how XMonad works by default, as well.

Why is it better?
PyTyle gives you a tremendous amount of control over your tiling layout, like XMonad. This means you get things like a grid layout (any number of windows) for free by increasing/decreasing the number of master windows. It also runs in the background and thus automatically manages windows for you: including moving them from screen to screen (xinerama), launching new windows, closing windows, moving them from workspace to workspace, etc.

Highlighted features:

* Manual toggling for tiling and untiling on a per workspace per screen basis.
* Full support built-in for mutli-screen displays (using Xinerama). Yes, this means nVidia TwinView is supported as well.
* Comes pre-packaged with two default layout algorithms: Vertical and Horizontal. You can toggle between them at any time.
* Object-oriented and ridiculously easy to add your own layout algorithms (if you know Python).
* A rich set of features triggered by key presses: toggle tiling, cycle windows, cycle layouts, switch the screen focus, move windows to another screen, increase the size of windows, move focus to next/previous windows, switch the current window with the next/previous window, switch the current window with the master window, maximize all windows, and restore all windows.
* The code is heavily documented (ridiculously so).

Configuration options:

* Specify your panels/docks on your screen(s) if PyTyle can't detect it automatically.
* Key bindings can be completely customized. The default key mappings are almost an exact clone of XMonad's key mappings.
* Easily add new layout algorithms. (Drop your custom written layout class in PyTyle/Tilers/ and add it to the list in the config file.)
* Experimental support for removing window decorations. (OpenBox only, currently.)
* Tell PyTyle to ignore certain windows. (The default configuration file specifies gmrun, gimp, and the firefox download window.) PyTyle will automatically ignore the more traditional popup windows.
* Configure default layouts on a per screen per workspace basis.

TODO:

My two main concerns are:

* Adding support for additional window managers (given that they at least somewhat comply with EWMH), although OpenBox will certainly be my primary focus.
* Adding more layout algorithms. I would love to hear some ideas on other layouts. (I'm already thinking about a Circle layout, like XMonad has, and canning the Maximize/Restore features and simply adding a full screen or maximized layout.)

Why?

To my knowledge, there are three existing tools that do something similar: wumwum, stiler, and even a proof-of-concept pytiler.

stiler was actually what gave me the idea to write this. I had tried it out, but fell far short of the experience I wanted: manual tiling, XMonad style. It was also using wmctrl, and I wanted something a bit more integrated (Xlib). wumwum is written in PERL (a personal downside, yuck), and I didn't see pytiler until I was half way done with PyTyle. (I was searching for possible names, and I found pytiler.) Pytiler is also using XCB- something that could be in the future for PyTyle, but likely not any time soon.

I'm essentially an OpenBox convert that came from XMonad. While I loved XMonad, I wasn't really a fan of its configuration style, and there are too many times when I just want to use a floating WM. (XMonad has weak support for this.) Of course, nothing, IMO, beats the productivity of using a tiling environment. Thus, PyTyle was born when stiler told me: it can be done.

Finally, I wanted to learn Python. This seemed like a perfect project to learn it with.

Other information:

If any of you are interested in doing some Xlib programming of your own, I strongly urge you to take a look at the Probe.py and Event.py source files in PyTyle. They represent approximately 98% of the effort I put into this project, as documentation for the Python X Library is abysmal. (I had to infer a lot of it from source code, the C xlib implementation docs, X protocol descriptions, and free desktop standards.) I've thoroughly documented every portion of PyTyle, and I've listed a few X related reference sites in the README.

Give it to me

PyTyle is in the AUR and I have a project page at Sourceforge using GIT where you can download/browse the source: https://sourceforge.net/projects/pytyle/

How do I use it?

After PyTyle runs for the first time, it will create the default configuration file in your XDG_CONFIG_HOME directory (probably: ~/.config/pytyle/pytylerc). It is also heavily documented and should explain everything. You can also add it to your ~/.xinitrc in the traditional style.

Quick run: open up a terminal, type "pytyle", hit enter, and press Alt-A: it should tile your windows. (Of course, if Alt-A is already bound to something else, you'll have to change the key binding in ~/.config/pytyle/pytylerc.)


Enjoy! :-)


EDIT:

* Updated the config file information. (It's been moved to the XDG_CONFIG_HOME directory.)

Last edited by BurntSushi (2009-08-24 14:49:30)


Education is favorable to liberty. Freedom can exist only in a society of knowledge. Without learning, men are incapable of knowing their rights, and where learning is confined to a few people, liberty can be neither equal nor universal.

Tu ne cede malis sed contra audentior ito

Offline

#2 2009-08-23 22:28:28

rine
Member
From: Germany
Registered: 2008-03-04
Posts: 217

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

That's funny. I was reading the thread about window managers today (http://bbs.archlinux.org/viewtopic.php?id=78205). There was a lot about xmonad. I tried it once but didn't feel comfortable with haskell and thought to myself I wish there was something like this in python big_smile Will definitely look at that next week, thanks smile

Offline

#3 2009-08-23 23:09:01

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,688
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Please put the configuration file in $XDG_CONFIG_HOME/pytyle instead of cluttering the user's home directory. If $XDG_CONFIG_HOME isn't set then use /home/<user>/.config/pytyle/ by default. I haven't looked at the code but here's an example that you should be able to use:

import os, sys
def get_default_conf():
  fpath = os.getenv('XDG_CONFIG_HOME')
  if not fpath:
    fpath = os.getenv('HOME') + '/.config'
    sys.stderr.write("Error: the environment variable \"XDG_CONFIG_HOME\" is not set\nDefaulting to %s.\n" % fpath)
  return fpath + '/pytyle/pytylerc'

def save_config(fpath):
  dpath = os.path.dirname(fpath)
  if not os.path.exists(dpath):
    os.makedirs(dpath)
  ...

Last edited by Xyne (2009-08-23 23:10:12)

Offline

#4 2009-08-24 00:24:16

BurntSushi
Member
From: Massachusetts
Registered: 2009-06-28
Posts: 362
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Thank you Xyne for the tip. AUR has been updated. :-)

@rine- I look forward to your feedback!


Education is favorable to liberty. Freedom can exist only in a society of knowledge. Without learning, men are incapable of knowing their rights, and where learning is confined to a few people, liberty can be neither equal nor universal.

Tu ne cede malis sed contra audentior ito

Offline

#5 2009-08-24 03:23:48

BurntSushi
Member
From: Massachusetts
Registered: 2009-06-28
Posts: 362
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

I've added a full screen layout algorithm. AUR has been updated.


Education is favorable to liberty. Freedom can exist only in a society of knowledge. Without learning, men are incapable of knowing their rights, and where learning is confined to a few people, liberty can be neither equal nor universal.

Tu ne cede malis sed contra audentior ito

Offline

#6 2009-08-24 03:31:08

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Hey BurntSushi, cheers for the PM, this project looks awesome, I will give it a try some time smile

Offline

#7 2009-08-24 11:24:23

moljac024
Member
From: Serbia
Registered: 2008-01-29
Posts: 2,676

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Very nice man!
Hats off to you smile


The day Microsoft makes a product that doesn't suck, is the day they make a vacuum cleaner.
--------------------------------------------------------------------------------------------------------------
But if they tell you that I've lost my mind, maybe it's not gone just a little hard to find...

Offline

#8 2009-08-24 12:30:49

evr
Arch Linux f@h Team Member
Registered: 2009-01-23
Posts: 554

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

wow, this project looks pretty interesting.  I'm definitely gonna try it out when I get home tonight. smile

Offline

#9 2009-08-24 17:26:16

daneel971
Member
Registered: 2008-03-28
Posts: 179

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

I tried it: really good, so thanks smile
There's a chance for a "cascade" option, too? I noticed some code has been posted in the stiler thread, but I have no idea how to use it.

Offline

#10 2009-08-24 17:52:07

BurntSushi
Member
From: Massachusetts
Registered: 2009-06-28
Posts: 362
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Hmmm, interesting suggestion daneel. I wonder, how would you expect it to work?

PyTyle does continuous tiling, so the idea isn't to "tile and forget" (or in your case, "cascade and forget").

What I mean by this is, let's go over a simple use case: I have four windows on my screen, and I opt to cascade them. Initially, I'm thinking it might look something like this:

initial.th.jpg

Now let's say we hit the "next window key"... Maybe it cycles back around to the last window (where the "previous window key" might go to the one right under the initial top window). Like this:

nextwindow1.th.jpg

And then I think the rest of the keys would be pretty straight forward. (Making the highlighted window the "master" would bring it to the front. And cycling would probably give you the Windows Vista 3D window switcher effect... Errrmm or something like it.)

So the other thing: taking up the whole screen. Maybe the initial tile should instead look something like this:

initial2.th.jpg

Or maybe this:

initial3.th.jpg

OOhh, I like that much better :-) (Let me know which one you think makes the most sense.)

Please let me know *any* thoughts you may have. I'm pretty crazy on getting behavior to be exactly right, and as intuitive as possible. You don't need to tell me how to code it, just how it should work from a user stand point.

And any other descriptions of tiling layouts would be great as well- they are pretty easy to add.

Also, if anyone has gotten this working on any WM besides OB, FluxBox and PekWM- I'd love to know.

Last edited by BurntSushi (2009-08-24 17:52:50)


Education is favorable to liberty. Freedom can exist only in a society of knowledge. Without learning, men are incapable of knowing their rights, and where learning is confined to a few people, liberty can be neither equal nor universal.

Tu ne cede malis sed contra audentior ito

Offline

#11 2009-08-24 18:08:22

daneel971
Member
Registered: 2008-03-28
Posts: 179

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Wow - screenshot 1 and 2 are exactly what I was thinking/hoping... smile
as for the "full screen" option, the last screenshot looks better, I agree.

Offline

#12 2009-08-24 18:30:00

Wintervenom
Member
From: /home/wintervenom
Registered: 2008-08-20
Posts: 1,011
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

I like the last screenshot.  It is like WMII's stacking mode.


My [GitHub] and my [artwork].
Data is guaranteed to stay crunchy in milk.
Keep your _✍ hand strong.

Offline

#13 2009-08-25 04:48:02

BurntSushi
Member
From: Massachusetts
Registered: 2009-06-28
Posts: 362
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

I've added a Cascade layout, in the same fashion as the last screenshot in my post above.

If you already have PyTyle installed, simply update it via the AUR, and add "Cascade" to the "tilers" list in your pytylerc. (Don't forget to add "Maximal" as well, if you had an earlier version of PyTyle.)

Any other layout suggestions, feature requests, behavior changes, etc. are welcome!


Education is favorable to liberty. Freedom can exist only in a society of knowledge. Without learning, men are incapable of knowing their rights, and where learning is confined to a few people, liberty can be neither equal nor universal.

Tu ne cede malis sed contra audentior ito

Offline

#14 2009-08-25 05:10:47

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Hi, just tried this and it works very well smile One minor problem, Im using cairo-dock and it treats the dock like a window, so it will move it around when the windows are being tiled.

Offline

#15 2009-08-25 12:42:52

BurntSushi
Member
From: Massachusetts
Registered: 2009-06-28
Posts: 362
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

wankel wrote:

Hi, just tried this and it works very well smile One minor problem, Im using cairo-dock and it treats the dock like a window, so it will move it around when the windows are being tiled.

Really? Hmmm, do you have cairo-dock to be set to only one workspace? Or is it sticky across all of them?

In any case, could you:

1. Open a terminal.
2. Run 'xprop'
3. Click on your cairo-dock
4. Copy the output back here.

And finally, for a work around immediately, put "cairo-dock" in the list of windows to filter in the configuration file.

Thanks.


Education is favorable to liberty. Freedom can exist only in a society of knowledge. Without learning, men are incapable of knowing their rights, and where learning is confined to a few people, liberty can be neither equal nor universal.

Tu ne cede malis sed contra audentior ito

Offline

#16 2009-08-25 19:06:55

daneel971
Member
Registered: 2008-03-28
Posts: 179

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

This are four layout i'd like to use: apologies if they are already in the code - I hadn't enaugh time to play today smile

89893964.th.jpg 18102027.th.jpg 28087232.th.jpg 28602401.th.jpg

(1) main + column (2) main + rows (3) rolled-up column (4) little cascade


And a little question: I didn't understand how to bind a key to a specific tiling mode.  ALT+A will tile the windows in the mode defined as default, and then I can cycle through all the others tiling styles - but can I have for instance ALT+S for "tile in cascade" and ALT+H for "tile Horizontally"?

Offline

#17 2009-08-25 19:23:47

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

BurntSushi wrote:
wankel wrote:

Hi, just tried this and it works very well smile One minor problem, Im using cairo-dock and it treats the dock like a window, so it will move it around when the windows are being tiled.

Really? Hmmm, do you have cairo-dock to be set to only one workspace? Or is it sticky across all of them?

In any case, could you:

1. Open a terminal.
2. Run 'xprop'
3. Click on your cairo-dock
4. Copy the output back here.

And finally, for a work around immediately, put "cairo-dock" in the list of windows to filter in the configuration file.

Thanks.

Here is the output:

atayh [~]: xprop
_NET_WM_USER_TIME(CARDINAL) = 65893607
_NET_WM_STRUT_PARTIAL(CARDINAL) = 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 194, 1085
WM_STATE(WM_STATE):
        window state: Normal
        icon window: 0x0
_NET_WM_DESKTOP(CARDINAL) = 0
_NET_WM_STATE(ATOM) = _NET_WM_STATE_STICKY, _NET_WM_STATE_SKIP_TASKBAR, _NET_WM_STATE_SKIP_PAGER
WM_HINTS(WM_HINTS):
        Client accepts input or input focus: True
        Initial state is Normal State.
        window id # of group leader: 0x800001
_NET_WM_ALLOWED_ACTIONS(ATOM) = _NET_WM_ACTION_ABOVE, _NET_WM_ACTION_BELOW
XdndAware(ATOM) = BITMAP
_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x0, 0x0, 0x0
_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 8388614
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_DOCK
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x800005
WM_CLIENT_LEADER(WINDOW): window id # 0x800001
_NET_WM_PID(CARDINAL) = 31080
WM_LOCALE_NAME(STRING) = "en_US.utf8"
WM_CLIENT_MACHINE(STRING) = "cerberus"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
        program specified minimum size: 0 by 0
        window gravity: Static
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "cairo-dock", "Cairo-dock"
WM_ICON_NAME(STRING) = "cairo-dock"
_NET_WM_ICON_NAME(UTF8_STRING) = 0x63, 0x61, 0x69, 0x72, 0x6f, 0x2d, 0x64, 0x6f, 0x63, 0x6b
WM_NAME(STRING) = "cairo-dock"
_NET_WM_NAME(UTF8_STRING) = 0x63, 0x61, 0x69, 0x72, 0x6f, 0x2d, 0x64, 0x6f, 0x63, 0x6b

Adding cairo-dock to the filters seems to have fixed the problem. Also, Im using this on compiz standalone and all the options work flawlessly, so feel free to add that to your list of compatible window managers smile

Offline

#18 2009-08-25 21:04:48

Ghost1227
Forum Fellow
From: Omaha, NE, USA
Registered: 2008-04-21
Posts: 1,418
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Very nice!

Offline

#19 2009-08-25 21:39:43

evr
Arch Linux f@h Team Member
Registered: 2009-01-23
Posts: 554

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

i've played with this a bit and it works great. i just wanted to say awesome job man!

Offline

#20 2009-08-25 21:44:33

BurntSushi
Member
From: Massachusetts
Registered: 2009-06-28
Posts: 362
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

@wankel - Thanks for the info. I've fixed the bug. Any dock/panel reporting itself as so should be left alone now. (I've also done this for splash screen and a few other types of windows, if they are reporting themselves correctly.) GIT is updated for now, I'll make a release soon. (I don't have a PKGBUILD for pytyle-git, yet.)

@daneel - Well, you can have the first one for free smile Simply run the Vertical tiler, and increase the number of masters. (That's Alt-comma.)

I like the second screen shot. While PyTyle can currently do a horizontal layout that resembles that, it cannot do rows of windows like you said. That could actually be a fairly complicated layout, so I'd need to know exactly how you would expect it to work... For instance:

1. Should it always be two horizontal rows of windows? So that, when a new window is added, does it simply add itself on to one of those? Or do we have a fixed number of windows in each row... So for instance, if I added a window to your screenshot, it would actually create a third row?

2. How would the next/previous window work? i.e., when I'm at arbitrary window X, how do I find X previous and X next?

So yeah, if you could describe how you see it working, that'd be great.

As for screenshots 3 and 4... I've already added a cascading layout, although it is full screen. I am hesitant to add what you've shown, though, as it is a bit similar to what I've added. Let me know what you think of the cascading layout I've put in and any other thoughts on the matter. (I'm not completely sold either way.)

And simple answer to triggering specific layouts with key bindings: you can't right now. But I like the idea. I need to re-work the config file a little bit to accommodate that though. (Also note that you can set the default layout on a per screen per workspace basis, if you like.) I'll post back here when that's done. You could also change the order that the tiling algorithms are specified in the configuration- this will reflect the cycling order.


Everyone else- Thanks for the encouragement! smile

Last edited by BurntSushi (2009-08-25 21:47:43)


Education is favorable to liberty. Freedom can exist only in a society of knowledge. Without learning, men are incapable of knowing their rights, and where learning is confined to a few people, liberty can be neither equal nor universal.

Tu ne cede malis sed contra audentior ito

Offline

#21 2009-08-26 06:30:27

Rasi
Member
From: Germany
Registered: 2007-08-14
Posts: 1,844
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

hmmm... cant find it in aur:

pytile: No packages matched your search criteria.


He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.

Douglas Adams

Offline

#22 2009-08-26 06:47:10

wankel
Member
From: Iowa, USA
Registered: 2008-05-30
Posts: 218
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Rasi wrote:

hmmm... cant find it in aur:

pytile: No packages matched your search criteria.

pytyle, not pytile smile

Offline

#23 2009-08-26 12:09:21

daneel971
Member
Registered: 2008-03-28
Posts: 179

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

BurntSushi wrote:

1. Should it always be two horizontal rows of windows?
So that, when a new window is added, does it simply add itself on to one of those? Or do we have a fixed number of windows in each row... So for instance, if I added a window to your screenshot, it would actually create a third row? 2. How would the next/previous window work? i.e., when I'm at arbitrary window X, how do I find X previous and X next?

I think of it like two columns of equal width under the main window; the main window is full stretched horizontally and for the 60% of the screen height vertically.
Windows order should be like |/|; a new windows add itself to the last position (yes, I like complicated things tongue).

Let me know what you think of the cascading layout I've put in and any other thoughts on the matter.

It's great - but sometimes I need to access my desktop, so a "little cascade" will be useful. Anyway, I'm more than happy as it is, so don't worry if it's not possible.

And simple answer to triggering specific layouts with key bindings: you can't right now. But I like the idea. You could also change the order that the tiling algorithms are specified in the configuration- this will reflect the cycling order.

Thanks for this. A final note: if the program, other than running as a demon, could be used even by invocation with a keyword (something like "pytyle horiz", we could bind a specific layout to an openbox menù item.

BTW: what about calling it pywire (python windows rearrange)? it sounds cool... smile

Offline

#24 2009-08-27 01:57:38

Wintervenom
Member
From: /home/wintervenom
Registered: 2008-08-20
Posts: 1,011
Website

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Could there be an option to automatically enable tiling on all wokspaces and screens whenever it starts (as opposed to pressing Tile.tile on every one)?

Last edited by Wintervenom (2009-08-27 01:59:30)


My [GitHub] and my [artwork].
Data is guaranteed to stay crunchy in milk.
Keep your _✍ hand strong.

Offline

#25 2009-08-27 08:45:57

zodmaner
Member
Registered: 2007-07-11
Posts: 653

Re: PyTyle: Manual tiling manager for EWMH compliant WM's

Works like a charm! Thank you for this great little utility, BurntSushi. big_smile

I especially like the that fact PyTyle remember position and size of the window. Very convenient.

Now with Openbox + Uzbl + PyTyle, my life is complete! smile

Last edited by zodmaner (2009-08-27 09:00:35)


Memento mori

Offline

Board footer

Powered by FluxBB