Codebase list devilspie2 / HEAD
HEAD

Tree @HEAD (Download .tar.gz)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
#
# Copyright © 2011-2015 Andreas Rönnquist.
# This file is distributed under the same license
# as the devilspie2 package, see COPYING file.
#

Devilspie 2
-----------

Devilspie 2 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 or closed, 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 with
devilspie2/ added to the end - g_get_user_config_dir 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 will load all the Lua files in this folder in alphabetical order.

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        From which folder should we load our Lua scripts
-v, --version       Print program version and quit
-w, --wnck-version  Show version of libwnck and quit


Config
-------

A config is read from the folder where we read all scripts, and is customizable
by the --folder option. By default this folder is ~/.config/devilspie2/.

If there is a file named devilspie2.lua in this folder, it is read and it is
searched for a variable (a lua table of strings) named either
scripts_window_close, scripts_window_focus or scripts_window_blur -
The filenames in the strings in this table will be called when windows are
closed, focused or blurred respectively. If these variables isn't present in
this file, it will be called as a devilspie2 script file like any other.

For example:

--
scripts_window_close = {
   "file1.lua",
   "file2.lua"
}

This would make the files file1.lua and file2.lua interpreted when windows are
closing instead of when windows are opening.


Scripting
---------

You can choose to have all script functionality in one file, or you can split
it up into several, Devilspie2 runs on all Lua files in your requested
devilspie2 folder, by default ~/.config/devilspie2 - that is all files with a
.lua extension.

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


The following commands are recognized by the Devilspie2 Lua interpreter:

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 with the --debug option, otherwise nothing will
   be printed.




Then, there's the functions to get the properties of a window, and related
information:


get_window_name()

   returns a string containing the name of the current window.


get_window_has_name()

   return true or false depending on if the 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) - for example you can do something
	like this:

	x, y, width, height = get_window_geometry();
	print("X: "..x..", Y: "..y..", width: "..width..", height: "..height);


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) -
	see get_window_geometry for an example on how to use this function.


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

	Return 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
get_fullscreen

	Returns TRUE if the window is fullscreen, FALSE otherwise
	(available from version 0.32)


and the rest of the commands are used to modify the properties of the windows:


set_window_position(xpos, ypos)

   Set 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_size (xsize, ysize)

   Sets the size of a window - takes xsize and ysize as parameters.


set_window_geometry (xpos, ypos, xsize, ysize)

   Sets both size and position of a window in one command. Takes four
   parameters, xpos, ypos, xsize and ysize.


set_window_geometry2 (xpos, ypos, xsize, ysize)

   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 decoration.


undecorate_window()

   Removes all window decorations.


close_window()

	Closes the window. (Available from 0.31)


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.


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) as value. (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([above])

   Set the current window above all normal windows. (available from version
   0.21)
   Optionally takes a boolean(true or false) as value.


set_window_below([below])

   Set the current window below all normal windows. (available from version
   0.21)
   Optionally takes a boolean(true or false) as value.


set_window_fullscreen(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(viewport)

   Using one indata, moves the window to the requested viewport - Counting
	starts at number 1. (Available from version 0.25)
	- Also see the alternative usage of this function below.

set_viewport(x, y)
	
	If you are using two indata to the set_viewport function, you can decide
	where in the viewport the window will be placed.
	(Available from version 0.40)

center()

   Centers the current window on the current workspace.
   (Available from version 0.26)


set_opacity(value)
set_window_opacity(value)

	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(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(left, right, top, bottom)

	Set 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(x, y), xy()
    Set the position of a window, or if you don't give any input, get the
    position of a window


xywh(x, y, w, h), 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.


Please note that strings comparisons are case sensitive, comparing
"SomeProgram" with "someprogram" will not report equality.


Simple script example
---------------------


---------------------8<---------------------

-- 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. (String comparison 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

--------------------->8---------------------


Translations
------------

Devilspie2 is now translatable using gettext - see README.translators for more
information.


Authors
-------

see the AUTHORS file


Contact
-------

Author: Andreas Rönnquist
E-mail: devilspie2 (at) gusnan (dot) se
Homepage: http://www.gusnan.se/devilspie2
Mailinglist: devilspie2-discuss@nongnu.org,
             https://lists.nongnu.org/mailman/listinfo/devilspie2-discuss

IRC: #devilspie2 on irc.freenode.net