Scripted window actions on Ubuntu with Devilspie 2

Devilspie2 is a program that detects windows as they are created, and performs scripted actions on them. The scripts are written in LUA, allowing a great deal of customization. This tutorial will show you the installation of Devilspie 2 on Ubuntu 14.04 and give you a introduction into Devilspie scripting.

What is LUA?

Lua is a powerful, fast, lightweight, embeddable scripting language. Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. Lua is dynamically typed, runs by interpreting bytecode for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping.

For futher infomation visit:


Type in the following:

sudo apt-get install devilspie2

(make sure it is devilspie2, because the devilspie is kinda messed up and no longer in development.)

Unfortunately the rules of the original Devils Pie are not supported in Devilspie 2 anymore.

Config and Scripting.

If you don't give devilspie2 any folder with --folder, it will read LUA scripts from the ~/.config/devilspie2/ folder, and this folder will be created if it doesn't already exist. This folder is changeable with the --folder option. If devilspie2 doesn't find any LUA files in the folder, it will stop execution.

Above are some usage options...

Sample Scripts.

the debug_print command does only print anything to stdout 
-- if devilspie2 is run using the --debug option

debug_print("Window Name: "..	get_window_name());
debug_print("Application name: "..get_application_name())

I want my Xfce4-terminal to the right on the second screen of my two-monitor 

if (get_window_name()=="Terminal") then
	-- x,y, xsize, ysize

Make Iceweasel always start maximized.

if (get_application_name()=="Iceweasel") then

To learn more about the scripting language visit the following:

See FAQ at 

Documentation at 

Tutorials at

Sript Commands.

     returns a string containing the name of the current window.

     returns the application name of the current window.

set_window_position(xpos, ypos)
     Sets the position of a window.

set_window_size(xsize, ysize)
     Sets the size of a window.

set_window_geometry(xpos, ypos, xsize ysize)
     Set the geometry of a window.

     Set the windows always on top flag.

     Sets a window on top of the others (this will however not lock the window in this position).

     Debug helper that prints a string to stdout. It is only printed if devilspie2 is run with the --debug option.

     "Shades" a window, showing only the title-bar.

     Unshades a window - the opposite of "shade"

     maximizes a window

     unmaximizes a window

     maximizes the current window vertically.

     maximizes the current window horisontally.

     minimizes a window

     unminimizes a window, that is bringing it back to screen from the minimized position/size.

     Shows all window decoration.

     Removes all window decorations.

     Moves a window to another workspace. The number variable starts counting at 1.

     Changes the current workspace to another. The number variable starts counting at 1.

     asks the window manager to put the window on all workspaces.

     Asks the window manager to put window only in the currently active workspace.

     Asks the window manager to keep the window's position fixed on the screen, even when the workspace or viewport scrolls.

     Asks the window manager to not have window's position fixed on the screen when the workspace or viewport scrolls.

This will be the end of the tutorial for using devilspie2.

Share this page:

0 Comment(s)