Skip to content

Commit

Permalink
Disabled window filtering to improve performance
Browse files Browse the repository at this point in the history
- disabled window filtering and added option to enable it
 - windows are filtered only when option is enabled and using the simple
layout
 - simplified argument checking and option execution
 - updated README to explain stilerrc options and known issues
 - default stilerrc is automatically generated from ConfigParser
defaults
 - unmaximize windows before attempting to resize and move them
  • Loading branch information
John Elkins authored and TheWanderer committed Apr 9, 2009
1 parent 4b4bf88 commit 1fbe347
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 79 deletions.
66 changes: 52 additions & 14 deletions README
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
Basically a simple python script which does tiling on any windowmanager (Perfectly on pekwm and openbox. Partly on compiz due to the fact that compiz says it has a single desktop even if there are 4 virtual desktops, which means all the windows you have will be tiled).
It uses wmctrl to get the info and manage the windows. Bind options to keys or to autowhatever-on-window-creation-hook. A sample xbindkeysrc file is included.
stiler.py is a simple python script which does tiling on any X window-manager.

Usage: OPTION
stiler.py is known to work with pekwm, openbox, metacity, and compiz.

Requirements:

wmctrl - used to get the window and desktop information and manage the windows
xdotools - used to get the currently active window

Usage: stiler.py OPTION

Standard options:
simple - The basic tiling layout . 1 Main + all other at the side.
swap - Will swap the active window to master column
cycle - Cycle all the windows in the master pane
vertical - Simple vertical tiling
horizontal - Simple horizontal tiling
maximize - Maximize the active window/ for openbox which doesn't permit resizing of max windows
max_all - Maximize all windows
simple - The basic tiling layout . 1 Main + all other at the side.
swap - Will swap the active window to master column
cycle - Cycle all the windows in the master pane
vertical - Simple vertical tiling
horizontal - Simple horizontal tiling
maximize - Maximize the active window/ for openbox which doesn't permit resizing of max windows
max_all - Maximize all windows

Grid options:

Expand All @@ -19,16 +25,48 @@ The following grid options mimic the functionality of compiz's grid plugin which
top_left - Place the active window in the top left corner of the screen
top - Place the active window along the top of the screen
top_right - Place the active window in the top right corner of the screen
left,right - Does the new windows7 ish style of sticking to the sides.
left,right - Does the new windows7 ish style of sticking to the sides.
middle - Place the active window in the middle of the screen
bottom_left - Place the active window in the bottom left corner of the screen
bottom - Place the active window along the bottom of the screen
bottom_right - Place the active window in the bottom right corner of the screen

Multiple calls to any of the grid options on the same active window will select different widths. Grid widths can be changed in the ~/.stilerrc file.
Multiple calls to any of the grid options on the same active window will select different widths.

On first run stiler will create a config file ~/.stilerrc. Modify the values to suit your window decorations/Desktop padding.

~/.stilerrc file options:

leftpadding - pads the left hand side of the screen the given number of pixels
toppadding - pads the top of the screen the given number of pixels
bottompadding - pads the bottom of the screen the given number of pixels
rightpadding - pads the right hand side of the screen the given number of pixels

window padding options:

winborder - pads the given number of pixels around each window
wintitle - pads the given number of pixels above each window

For a dual monitor setup set Monitors = 2 in the ~/.stilerrc file.
miscellaneous options

On first run stiler will create a config file ~/.stilerrc. Modify the values to suit your window decorations/Desktop padding. Change the GridWidths list to define different widths for the grid options.
tempfile - cache file for holding window positions

simple layout options:

mwfactor - width of the bigger window in the simple layout
windowfilter - exclude minimized and UTILITY windows from being tiled

grid layout options:

monitors - for a dual monitor setup set this to 2
gridwidths - a list of grid widths to use for splitting the screen. 0.33 should always be in the list

If you need other layouts modify get_simple_tile

Known Issues:

compiz - compiz says it has a single desktop even if there are 4 virtual desktops, which means all the windows you have will be tiled.
firefox - firefox get a little stubborn when resized below a certain point

See Also:
xbindkeys - map keyboard keys to stiler.py options. a sample xbindkeysrc is provided.
117 changes: 52 additions & 65 deletions stiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,33 @@
import pickle
import ConfigParser

usage = sys.argv[0] + " option"

def initconfig():
rcfile=os.getenv('HOME')+"/.stilerrc"

configDefaults={
'BottomPadding':'0',
'TopPadding': '0',
'LeftPadding': '0',
'RightPadding': '0',
'WinTitle': '21',
'WinBorder': '1',
'MwFactor': '0.65',
'Monitors': '1',
'GridWidths': '0.50,0.67,0.33',
'TempFile': '/tmp/tile_winlist',
'WindowFilter':'off',
}

config=ConfigParser.RawConfigParser(configDefaults)


if not os.path.exists(rcfile):
cfg=open(rcfile,'w')
cfg.write("""#Tweak these values
[default]
BottomPadding = 0
TopPadding = 0
LeftPadding = 0
RightPadding = 0
WinTitle = 21
WinBorder = 1
MwFactor = 0.65
Monitors = 1
GridWidths = 0.50,0.67,0.33
TempFile = /tmp/tile_winlist
""")
config.write(cfg)
cfg.close()

config=ConfigParser.RawConfigParser()
config.read(rcfile)
return config

Expand Down Expand Up @@ -103,16 +110,21 @@ def retrieve(file):

# Get all global variables
Config = initconfig()
BottomPadding = Config.getint("default","BottomPadding")
TopPadding = Config.getint("default","TopPadding")
LeftPadding = Config.getint("default","LeftPadding")
RightPadding = Config.getint("default","RightPadding")
WinTitle = Config.getint("default","WinTitle")
WinBorder = Config.getint("default","WinBorder")
MwFactor = Config.getfloat("default","MwFactor")
TempFile = Config.get("default","TempFile")
Monitors = Config.getint("default","Monitors")
CORNER_WIDTHS = map(lambda y:float(y)/Monitors,Config.get("default","GridWidths").split(","))
cfgSection="DEFAULT"
if Config.has_section("default"):
cfgSection="default"

BottomPadding = Config.getint(cfgSection,"BottomPadding")
TopPadding = Config.getint(cfgSection,"TopPadding")
LeftPadding = Config.getint(cfgSection,"LeftPadding")
RightPadding = Config.getint(cfgSection,"RightPadding")
WinTitle = Config.getint(cfgSection,"WinTitle")
WinBorder = Config.getint(cfgSection,"WinBorder")
MwFactor = Config.getfloat(cfgSection,"MwFactor")
TempFile = Config.get(cfgSection,"TempFile")
Monitors = Config.getint(cfgSection,"Monitors")
WindowFilter = Config.getboolean(cfgSection,"WindowFilter")
CORNER_WIDTHS = map(lambda y:float(y)/Monitors,Config.get(cfgSection,"GridWidths").split(","))
CENTER_WIDTHS = [1.0/Monitors,min(CORNER_WIDTHS)]

(Desktop,OrigXstr,OrigYstr,MaxWidthStr,MaxHeightStr,WinList) = initialize()
Expand Down Expand Up @@ -206,6 +218,8 @@ def move_window(windowid,PosX,PosY,Width,Height):
window = "-i -r "+windowid

# NOTE: metacity doesn't like resizing and moving in the same step
# unmaximize
os.system("wmctrl "+window+" -b remove,maximized_vert,maximized_horz")
# resize
command = " wmctrl " + window + " -e 0,-1,-1," + str(Width) + "," + str(Height)
os.system(command)
Expand Down Expand Up @@ -354,13 +368,15 @@ def create_win_list():

# remove windows that shouldn't be tiled
def filter_excluded(Windows):

for win in Windows:
window_type = commands.getoutput("xprop -id "+win+" _NET_WM_WINDOW_TYPE | cut -d_ -f10").split("\n")[0]
window_state = commands.getoutput("xprop -id "+win+" WM_STATE | grep \"window state\" | cut -d: -f2").split("\n")[0]

if WindowFilter == True and (sys.argv[1] == "swap" or sys.argv[1] == "cycle" or sys.argv[1] == "simple") :

for win in Windows:
window_type = commands.getoutput("xprop -id "+win+" _NET_WM_WINDOW_TYPE | cut -d_ -f10").split("\n")[0]
window_state = commands.getoutput("xprop -id "+win+" WM_STATE | grep \"window state\" | cut -d: -f2").split("\n")[0]

if window_type == "UTILITY" or window_state == " Iconic" :
Windows.remove(win)
if window_type == "UTILITY" or window_state == " Iconic" :
Windows.remove(win)

return Windows

Expand Down Expand Up @@ -392,7 +408,7 @@ def vertical():
arrange(get_vertical_tile(len(winlist)),winlist)


def horiz():
def horizontal():
winlist = create_win_list()
active = get_active_window()
winlist.remove(active)
Expand Down Expand Up @@ -422,38 +438,9 @@ def max_all():
winlist.insert(0,active)
arrange(get_max_all(len(winlist)),winlist)



if sys.argv[1] == "left":
left()
elif sys.argv[1] == "right":
right()
elif sys.argv[1] == "simple":
simple()
elif sys.argv[1] == "vertical":
vertical()
elif sys.argv[1] == "horizontal":
horiz()
elif sys.argv[1] == "swap":
swap()
elif sys.argv[1] == "cycle":
cycle()
elif sys.argv[1] == "maximize":
maximize()
elif sys.argv[1] == "top_left":
top_left()
elif sys.argv[1] == "top_right":
top_right()
elif sys.argv[1] == "top":
top()
elif sys.argv[1] == "bottom_left":
bottom_left()
elif sys.argv[1] == "bottom_right":
bottom_right()
elif sys.argv[1] == "bottom":
bottom()
elif sys.argv[1] == "middle":
middle()
elif sys.argv[1] == "max_all":
max_all()
if len(sys.argv) == 1:
print usage
sys.exit(1)
else:
eval(sys.argv[1]+"()")

0 comments on commit 1fbe347

Please sign in to comment.