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: http://www.lua.org/

Installation.

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 
setup,

if (get_window_name()=="Terminal") then
	-- x,y, xsize, ysize
	set_window_geometry(1600,300,900,700);
end

Make Iceweasel always start maximized.

if (get_application_name()=="Iceweasel") then
	maximize();
end

To learn more about the scripting language visit the following:

See FAQ at

www.lua.org/FAQ.html 

Documentation at

www.lua.org/docs.html 

Tutorials at 

http://lua-users.org/wiki/TutorialDirectory
	

Sript Commands.

get_window_name()
     returns a string containing the name of the current window.

get_application_name()
     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.

make_always_on_top()
     Set the windows always on top flag.

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

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

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

unshade()
     Unshades a window - the opposite of "shade"

maximize()
     maximizes a window

unmaximize()
     unmaximizes a window

maximize_vertically()
     maximizes the current window vertically.

maximize_horisontally()
     maximizes the current window horisontally.

minimize()
     minimizes a window

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

decorate_window()
     Shows all window decoration.

undecorate_window()
     Removes all window decorations.

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

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

pin_window()
     asks the window manager to put the window on all workspaces.

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

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

unstick_window()
     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)