Devilspie2

Devilspie2 is based on the excellent program Devil's Pie by Ross Burton, and takes a folder as indata, and checks that folder for LUA scripts. These scripts are run each time a window is opened, and the rules in them are applied on the window. Unfortunately the rules of the original Devils Pie are not supported. If you don't give devilspie2 any folder with --folder, it will read LUA scripts from the folder that it gets from the GLib function g_get_user_config_dir - this returns the config directory as defined in the XDG Base Directory Specification. In most cases would be 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. Devilspie2 takes some options: -h, --help Show help options -d, --debug Print debug information to stdout -e, --emulate Don't apply any rules, but only emulate execution -f, --folder Set from which folder should we load our LUA scripts -v, --version Print program version and quit Example A simple script example can look like this: -- 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. (Strings are case sensitive, please note this when creating rule -- scripts.) 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 You can choose to have all script functionality in one file, or you can split it up into several, Devilspie2 searches the folder .config/devilspie2/ for all files with a .lua extension. Scripting The scripting language used is LUA (see www.lua.org) - See FAQ at www.lua.org/faq.html, documentation at www.lua.org/docs.html, and tutorials at http://lua-users.org/wiki/TutorialDirectory. Commands The following commands are recognized by the LUA interpreter: debug_print get_window_name get_window_has_name get_application_name get_window_geometry get_window_client_geometry get_window_is_maximized get_window_is_maximized_vertically get_window_is_maximized_horizontally get_window_type get_class_instance_name get_window_property get_window_role get_window_xid get_window_class get_workspace_count get_screen_geometry get_window_fullscreen set_window_position set_window_position2 set_window_geometry set_window_geometry2 make_always_on_top set_on_top shade unshade maximize unmaximize maximize_vertically maximize_horizontally minimize unminimize decorate_window undecorate_window close_window set_window_workspace change_workspace pin_window unpin_window stick_window unstick_window set_skip_tasklist set_skip_pager set_window_above set_window_below set_window_fullscreen set_viewport center set_opacity set_window_type focus focus_window set_window_strut xy xywh First, a function to show some debug info: debug_print(string) Debug helper that prints a string to stdout. The string is only printed to stdout if devilspie2 is run in debug mode (with the --debug option), otherwise nothing will be printed. Then, there's the functions to get the properties of windows: get_window_name returns as string containing the name of the current window. get_window_has_name returns a boolean (true or false) depending on if a window has a name or not. (from version 0.20) get_application_name() returns the application name of the current window. get_window_geometry() Returns the window geometry as four numbers - x-position, y-position, width and height. (from version 0.16) get_window_client_geometry() returns the window geometry excluding the window manager borders as four numbers, x-position, y-position, width and height. (from version 0.16) get_window_is_maximized() Returns true if the window is maximized, false otherwise. (available from version 0.21) get_window_is_maximized_vertically() Returns true if the window is vertically maximized, false otherwise. (available from version 0.21) get_window_is_maximized_horizontally() Returns true if the window is horizontally maximized, false otherwise. (available from version 0.21) get_window_type() Returns the type of the window - The result type is a string, and can be one of the following: "WINDOW_TYPE_NORMAL" "WINDOW_TYPE_DESKTOP" "WINDOW_TYPE_DOCK" "WINDOW_TYPE_DIALOG" "WINDOW_TYPE_TOOLBAR" "WINDOW_TYPE_MENU" "WINDOW_TYPE_UTILITY" "WINDOW_TYPE_SPLASHSCREEN" or "WINDOW_TYPE_UNRECOGNIZED" if libwnck didn't recognize the type. If the function for some reason didn't have a window to work on the string result is "WINDOW_ERROR". (available from version 0.21) get_class_instance_name() Gets the class instance name from the WM_CLASS Property for the current window. Only available on libwnck 3+, and in devilspie2 version 0.21 or later. get_window_property(property) Returns the window property described in the property string. For a list of available properties, you should see the page http://standards.freedesktop.org/wm-spec/wm-spec-latest.html (Available from version 0.21) get_window_role Returns a string describing the current window role of the matched window as defined by it's WM_WINDOW_ROLE hint. get_window_xid Returns the X window id of the current window. get_window_class Returns a string representing the class of the current window. get_workspace_count Returns the number of workspaces available (available from version 0.27) get_screen_geometry Returns the screen geometry (two numbers) for the screen of the current window (available from version 0.29) get_window_fullscreen Returns TRUE if the window is fullscreen, FALSE otherwise (available from version 0.32) set_window_position(xpos,ypos) Sets the position of a window. set_window_position2(xpos,ypos) Set the position of a window - Compared to set_window_position, this function uses XMoveWindow instead of wnck_window_set_geometry which gives a slightly different result. (Available from version 0.21) set_window_geometry(xpos,ypos,width,height) Sets both position and size of a window in one command. Takes four parameters, xpos, ypos, width and height. set_window_geometry2(xpos,ypos,width,height) Sets the window geometry just as set_window_geometry, using XMoveResizeWindow instead of its libwnck alternative. This results in different coordinates than the set_window_geometry function, and results are more similar to the results of the original devilspie geometry function. (available from version 0.21) make_always_on_top() Sets a window always on top. set_on_top() Sets a window on top of the others. (unlike make_always_on_top, it doesn't lock the window in this position.) 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_horizontally Maximizes the current window horizontally. 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 decorations. undecorate_window() Removes all window decorations. set_window_workspace() Moves a window to another workspace. The number variable starts counting at 1. change_workspace() 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 when the workspace or viewport scrolls. unstick_window() Asks the window manager to not have the window's position fixed on the screen when the workspace or viewport scrolls. set_skip_tasklist(skip) Set this to true if you would like the window to skip listing in your tasklist. Takes a boolean (true or false). (from version 0.16) set_skip_pager(skip) Set this to true if you would like the window to skip listing in your pager. Takes a boolean (true or false) as value. (from version 0.16) set_window_above Set the current window above all normal windows. (Available from version 0.21) set_window_below Set the current window below all normal windows. (Available from version 0.21) set_window_fullscreen Asks the window manager to set the fullscreen state of the window according to the fullscreen boolean. (Available from version 0.24) set_viewport Moves the window to the requested viewport - Counting starts at number 1. (Available from version 0.25) center Centers the current window on the current workspace. (Availible from version 0.26) set_opacity, set_window_opacity Sets the window opacity, takes a float value, 1.0 = completely opaque, 0.0, completely see-through. Both set_opacity and set_window_opacity will do the same thing. (Available from version 0.28, set_window_opacity from 0.29) set_window_type Sets the window type, according to _NET_WM_WINDOW_TYPE. The allowed types are the standard _NET_WM ones (formatted as a string): "_NET_WM_WINDOW_TYPE_DESKTOP" "_NET_WM_WINDOW_TYPE_DOCK" "_NET_WM_WINDOW_TYPE_TOOLBAR" "_NET_WM_WINDOW_TYPE_MENU" "_NET_WM_WINDOW_TYPE_UTILITY" "_NET_WM_WINDOW_TYPE_SPLASH" "_NET_WM_WINDOW_TYPE_DIALOG" "_NET_WM_WINDOW_TYPE_NORMAL" or shorter versions of the same values "WINDOW_TYPE_DESKTOP "WINDOW_TYPE_DOCK" "WINDOW_TYPE_TOOLBAR" "WINDOW_TYPE_MENU" "WINDOW_TYPE_UTILITY" "WINDOW_TYPE_SPLASH" "WINDOW_TYPE_DIALOG" "WINDOW_TYPE_NORMAL" (Function is available from version 0.28) focus, focus_window Focuses the current window. (Function is available from version 0.30) set_window_strut Sets the reserved area at the borders of the desktop for a docking area such as a taskbar or a panel (available from version 0.32) xy Set the position of a window, or if you don't give it any input, return the position of a window xywh Set the position and size of a window, or if you don't give any input, get the position and size of a window. Translations Devilspie2 is translatable using gettext - see README.translators for more information. Authors Andreas Rönnquist - <gusnan@gusnan.se> -- All code, Swedish translation Ross Burton -- Original Devilspie Robin Hahling - <robin.hahling@gw-computing.net> -- French translation Hélder Máximo Botter Ribas - <helderribas@gmail.com> -- Brasilian Portugese translation Contact Author: Andreas Rönnquist E-mail: gusnan@gusnan.se Homepage: http://www.gusnan.se/devilspie2 Google groups: http://groups.google.com/group/devilspie2 IRC: #devilspie2 on irc.freenode.net