Devil's Pie

Note that Devil's Pie isn't really maintained - you may be more interested in the successor project Devil's Pie 2.

Introduction

A totally crack-ridden program for freaks and weirdos who want precise control over what windows do when they appear. If you want all XChat windows to be on desktop 3, in the lower-left, at 40% transparency, you can do it.

http://www.burtonini.com/blog/computers/devilspie

Script Files

Devil's Pie looks for scripts ending with ".ds" in a ".devilspie/" directory in your home directory. To get started writing scripts, you must first create this directory, then create script files within it. Each script file must contain exactly one expression (see below for information on the "begin" expression which lets you group multiple expressions within one.) Each time a new window is created, Devil's Pie executes each script that ends with the ".ds" extension in the ~/.devilspie directory.

Syntax File Reference

TODO

Logical Constructs

if

Syntax:

(if a b)
 
(if a b c)

A conditional flow based on the logical expression a. In the first case, if a is true, b gets executed and nothing otherwise. In the second case, if a is true, b is executed and c otherwise.

Example:

  • (if (is (application_name) “firefox_bin”) (set_workspace 2)) - Moves the window to workspace 2 if the application it belongs to is Firefox.

begin

Syntax:

(begin a b c ...)

A sequential execution of actions a, b, c, ...

Example:

  • (if (is (application_name) “firefox_bin”) (begin (set_workspace 2) (maximize))) - If the window belongs to the application Firefox, move it to workspace 2 and maximize it.

and

Syntax:

(and a b)

Returns the result of and-ing the logical expressions a and b.

Examples:

  • (and true true) - true

  • (and true false) - false

  • (and false false) - false

or

Syntax:

(or a b)

Returns the result of or-ing the logical expressions a and b.

Examples:

  • (or true true) - true

  • (or true false) - true

  • (or false false) - false

not

Syntax:

(not a)

Returns the negation of the given logical expression a.

Examples:

  • (not true) - false

  • (not false) - true

is

Syntax:

(is a b)

Returns true if strings a and b are the same.

Examples:

  • (is "foo" "foo") - true

  • (is "foo" "bar") - false

contains

Syntax:

(contains haystack needle)

Returns true if the string needle is a sub-string of the string haystack.

Examples:

  • (contains "somefoobar" "foo") - true

  • (contains "somefoobar" "fnord") - false

matches

Syntax:

(matches str pattern)

Returns true if string pattern matches on string str. pattern represents a Regular Expression.

Examples:

  • (matches “foobar” “[o]{2}b”) - true

  • (matches “foobar” “[0-9]+”) - false

Matchers

Matchers return certain properties of the available windows – namely title, name of application and role of the window – and are used to formulate conditions to match certain programs and/or windows they may spawn.

window_name

Syntax:

(window_name) 

Returns a string containing the name of the window as displayed in the windows titlebar.

window_role

Syntax:

(window_role)

Returns a string describing the current window role of the matched window as defined by its WM_WINDOW_ROLE hint.

application_name

Syntax:

(application_name)

Returns a string containing the name of the application that spawned the matched window.

window_workspace

Syntax:

(window_workspace)

Returns an int containing the number of the workspace that the window is on.

window_class

Syntax:

(window_class)

Returns a string, the "class" of the window. Not exactly sure what the semantics are, but it corresponds to the 'Emacs' in the following debug printout:

Window Title: 'emacs-snapshot-gtk@localhost.localdomain'; Application Name: 'emacs-snapshot-gtk'; Class: 'Emacs'; Geometry: 1024x718+0+49

Actions

TODO: maximize, maximize_vertically, maximize_horizontally, minimize, shade, unshade, close, pin, unpin, set_workspace, skip_pager, skip_tasklist, above, below, undecorate, wintype.

debug

Syntax:

(debug)

Prints information to stdout about matched open windows, including applicationname, windowtitle, windowrole and geometry.

print

Syntax:

(print text)

Prints the string text to stdout, useful for debugging rules.

geometry

Syntax:

(geometry geo)

Sets the geometry of the matched window. geo must be a STRING containing a valid X-GeometryString as parsed by XParseGeometry (see man XParseGeometry for details).

Examples:

  • (geometry "400x300+0-22") - Resizes the window to 400x300px and moves it to (0,-22)

  • (geometry "640x480") - Resizes the window to 640x480px

  • (geometry "+10+10") - Moves the window to (10,10)

fullscreen

Syntax:

(fullscreen)

Sets the matched window into fullscreen mode.

focus

Syntax:

(focus)

Gives focus to the matched window.

center

Syntax:

(center)

Centers the matched window on the screen.

Examples

To use one of the examples below, save it as something.ds in your ~/devilspie directory.

The following script sets the Geometry of the Gaim Buddy List to be the upper right corner of my screen. It could probably be modified to count pixels from the right instead of using the large, 2255 value.

(if
    (and
        (is (application_name) "gaim")
        (is (window_role) "buddy_list"))
    (geometry "300x500+2255+0"))

This script sets all Gaim windows to be pinned across all desktops. This is helpful for not losing conversations on a desktop you switched from recently. It moves the Buddy List too because clicking the buddy list icon in the Notification Area takes extra clicks when the Buddy List is left open on another desktop and can be confusing.

(if
    (is (application_name) "gaim")
    (pin "TRUE"))

See also

http://wiki.foosel.net/linux/devilspie - the fullest manual on Devil's pie I've found

Projects/DevilsPie (last edited 2013-11-22 02:33:27 by WilliamJonMcCann)