Debian Codegraph @

tyrannical/README.md

raw symbols SCIP
1 Tyrannical—A simple tag managment engine for Awesome
2 -----------------------------------------------------
3
4 ### News
5
6 #### January 2019
7
8 Tyrannical 2.0.0 has been released. It is the first and last official release
9 for Awesome 4.0 to 4.2. The new `no_tag_deselect` option has been added (
10 thanks to @cherti).
11
12 From now on, only AwesomeWM 4.3+ is supported. Parts of Tyrannical were merged
13 into AwesomeWM 4.3 and it will make everything more reliable.
14
15 #### April 2016
16
17 Tyrannical 1.0.0 has been released. This is the first and last version for
18 Awesome 3.5. Tyrannical is still in active developement and a brand new
19 implementation will be released shortly after Awesome 4.0 is released.
20
21 Tyrannical goal is and has always been to avoid re-inventing the wheel and
22 use existing Awesome APIs to manage tags. This will now get much easier with
23 Awesome 4.0 and a new "request" API designed with Tyrannical like workflows
24 in mind. This will avoid turning the code into a unreadable ball of spagetti
25 as the current implementation became.
26
27 #### December 2016
28
29 The master branch **is for Awesome 4.4+**. If you use **Awesome 3.5,**
30 **use the 1.0.0 version**. If you use Awesome 4.0-2.4, use the 2.0.0 version.
31
32 ### Description
33
34 Tyrannical is a tag management system for Awesome 3.5+. It is inspired and
35 intend to replace the Shifty module popular in older versions of Awesome.
36
37 Compared to Shifty, Tyrannical doesn't try to replace `awful.tag` and
38 `awful.rules`, but rather extend them to support the following features:
39
40 * Declarative tags declaration description
41 * Rules based around the tags rather than the clients
42 * Rules based around the client properties rather than the clients
43 * A dynamic tag workflow where tags are created and removed on demand
44 * A stateful tag model
45 * More powerful focus stealing rules
46
47 Tyrannical was created because:
48
49 * Shifty code is too complex and outdated to be maintained
50 * `awful` support dynamic tagging, but it's awkward to use
51 * It implements a workflow that better fit my taste than the default one
52
53 Tyrannical 1.0 versus 2.0-alpha:
54
55 While I am among the first AwesomeWM user, I only became a major contributor
56 during the 4.0 development cycle. The new version of Awesome has new APIs
57 designed to improve alternate workflows such as the one proposed by Tyrannical.
58
59 The new version aims to rewrite Tyrannical to use these APIs instead of the
60 hacks that allowed the original version to work. The original code also became
61 unmaintainable due to horrible coding practices and repeated hacks to fine tune
62 its behavior.
63
64 Finally, Awesome 4.0 introduces support for adding and removing screen at
65 runtime. Therefor, being able to expand and contract the tag set dynamically
66 is finally possible. Being able to support the use case where a laptop is
67 optionally plugged to an external monitor will be implemented once feature
68 parity has been achieved.
69
70 Future:
71
72 My first attempt at implementing dynamic layouts failed back in 2012, but for a
73 year I have been using a new implementation. This isn't expected to land in
74 Awesome anytime soon. But once it does, Tyrannical will gain the ability to
75 describe whole dynamic layouts instead of "just" its tag.
76
77 #### Tag model
78
79 Tyrannical turn awful.rule upside down. Instead of having to define rules for
80 specific classes or matches, you define an array of tags, each with their own
81 set of properties and rules. When a new client will arrive, it will be matched
82 with a set of tags without any client specific configuration.
83
84 All tags can have one "current" state:
85
86 * **inclusive:** The default state. All new clients will be allowed
87 * **exclusive:** Clients have be part of the allowed classes to be added
88 * **locked:** No new clients will be allowed in the tag
89 * **fallback:** If a client cannot be added to the current tag, then it will go there
90
91 These rules are bypassed by `intrusive` clients. In that case, the client will
92 be allowed no matter what. If there is no fallback tag and the client cannot be
93 added to an existing tag, then a new one will be created with the client class
94 as name. If the tag is set to `volatile`, then it will be destroyed when the
95 last client is closed. If set to `init`, it will be present by default even if
96 there is nothing in it.
97
98 #### Client properties model
99
100 Tyrannical offer a bunch of dynamic table for each properties (see below).
101 When a class is present in one of those table, clients will be assigned the
102 properties from the table name. For example, if you add Firefox to
103 `tyrannical.properties.floating`, then it will float by default. Specific values
104 can also to other value by using the class name as table key:
105
106 ```lua
107 tyrannical.properties.maximized = {
108 amarok = false,
109 }
110 ```
111
112 #### Focus model
113
114 Tyrannical focus model is very fine tuned. It is possible to add rules on how
115 the focus will be attributes to clients and tags.
116
117 **block_children_focus_stealing:**
118 This is a fancy X11 name for something very common: modal dialogs and popups.
119 If this is set to `true`, then a dialog wont be able to steal the focus from
120 whatever your doing. This is useful for some misbehaving apps such as Firefox
121 that can decide to show an update popup at the worst possible moment.
122
123 **group_children:**
124 While not directly related to focus, when using with `no_focus_stealing_out`,
125 it allow new "children" clients to silently be added to their "parent" tag.
126 A good taglist widgets such as Radical can take care of notifying the user
127 without disturbing your workflow.
128
129 **no_focus_stealing_in:**
130 When a new client is added to a tag with `no_focus_stealing_in` set to true,
131 then the tag wont be selected and the current one will be kept.
132
133 **no_focus_stealing_out:**
134 Similar to `no_focus_stealing_in`. If a tag enable this, then the tag will stay
135 selected no matter what event happen. This is useful for video games and video
136 players.
137
138 **no_tag_deselect:**
139 When a new client is added somewhere, that tag gets selected in addition to the
140 current selection of tags instead of being selected solely.
141
142 **no_autofocus:**
143 When a class has this flag, then new clients wont be focused when they are
144 launched. This is useful for download managers or background terminals tasks.
145
146 ### Installation
147
148 This is how to install Tyrannical for Awesome 4.X:
149
150 ```
151 mkdir -p ~/.config/awesome
152 cd ~/.config/awesome
153 git clone https://github.com/Elv13/tyrannical.git
154 ```
155
156 Awesome 3.5 users should fetch the version 1.0.0.
157
158 Then either use the sample rc.lua or upgrade your existing one.
159
160 ### Configuration
161
162 If you previously used Shifty, you will feel comfortable using Tyrannical. The
163 only difference is that in Tyrannical class matching is integrated into the tag
164 configuration section. More advanced rules can be created using
165 ```awful.rules```. Again, Tyrannical was not created to duplicate awful, but to
166 make dynamic (and static, as a side effect) tagging configuration easier. This
167 module doesn't require any major initialisation. Compared to shifty, it is much
168 more transparent.
169
170 The first modification is to include the module at the top of your `rc.lua`
171 (after `awful.rules = require("awful.rules")`):
172
173 ```lua
174 local tyrannical = require("tyrannical")
175 --require("tyrannical.shortcut") --optional
176 ```
177
178 Then this line has to be removed:
179
180 ```lua
181 awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, s, awful.layout.layouts[1])
182 ```
183
184 And this added **outside** of the `awful.screen.connect_for_each_screen` section:
185
186 ```lua
187 tyrannical.tags = {
188 {
189 name = "Term", -- Call the tag "Term"
190 init = true, -- Load the tag on startup
191 exclusive = true, -- Refuse any other type of clients (by classes)
192 screen = {1,2}, -- Create this tag on screen 1 and screen 2
193 layout = awful.layout.suit.tile, -- Use the tile layout
194 instance = {"dev", "ops"}, -- Accept the following instances. This takes precedence over 'class'
195 class = { --Accept the following classes, refuse everything else (because of "exclusive=true")
196 "xterm" , "urxvt" , "aterm","URxvt","XTerm","konsole","terminator","gnome-terminal"
197 }
198 } ,
199 {
200 name = "Internet",
201 init = true,
202 exclusive = true,
203 --icon = "~net.png", -- Use this icon for the tag (uncomment with a real path)
204 screen = screen.count()>1 and 2 or 1,-- Setup on screen 2 if there is more than 1 screen, else on screen 1
205 layout = awful.layout.suit.max, -- Use the max layout
206 class = {
207 "Opera" , "Firefox" , "Rekonq" , "Dillo" , "Arora",
208 "Chromium" , "nightly" , "minefield" }
209 } ,
210 {
211 name = "Files",
212 init = true,
213 exclusive = true,
214 screen = 1,
215 layout = awful.layout.suit.tile,
216 exec_once = {"dolphin"}, --When the tag is accessed for the first time, execute this command
217 class = {
218 "Thunar", "Konqueror", "Dolphin", "ark", "Nautilus","emelfm"
219 }
220 } ,
221 {
222 name = "Develop",
223 init = true,
224 exclusive = true,
225 screen = 1,
226 layout = awful.layout.suit.max ,
227 class ={
228 "Kate", "KDevelop", "Codeblocks", "Code::Blocks" , "DDD", "kate4"}
229 } ,
230 {
231 name = "Doc",
232 init = false, -- This tag wont be created at startup, but will be when one of the
233 -- client in the "class" section will start. It will be created on
234 -- the client startup screen
235 exclusive = true,
236 layout = awful.layout.suit.max,
237 class = {
238 "Assistant" , "Okular" , "Evince" , "EPDFviewer" , "xpdf",
239 "Xpdf" , }
240 } ,
241 }
242
243 -- Ignore the tag "exclusive" property for the following clients (matched by classes)
244 tyrannical.properties.intrusive = {
245 "ksnapshot" , "pinentry" , "gtksu" , "kcalc" , "xcalc" ,
246 "feh" , "Gradient editor", "About KDE" , "Paste Special", "Background color" ,
247 "kcolorchooser" , "plasmoidviewer" , "Xephyr" , "kruler" , "plasmaengineexplorer",
248 }
249
250 -- Ignore the tiled layout for the matching clients
251 tyrannical.properties.floating = {
252 "MPlayer" , "pinentry" , "ksnapshot" , "pinentry" , "gtksu" ,
253 "xine" , "feh" , "kmix" , "kcalc" , "xcalc" ,
254 "yakuake" , "Select Color$" , "kruler" , "kcolorchooser", "Paste Special" ,
255 "New Form" , "Insert Picture" , "kcharselect", "mythfrontend" , "plasmoidviewer"
256 }
257
258 -- Make the matching clients (by classes) on top of the default layout
259 tyrannical.properties.ontop = {
260 "Xephyr" , "ksnapshot" , "kruler"
261 }
262
263 -- Force the matching clients (by classes) to be centered on the screen on init
264 tyrannical.properties.placement = {
265 kcalc = awful.placement.centered
266 }
267
268 tyrannical.settings.block_children_focus_stealing = true --Block popups ()
269 tyrannical.settings.group_children = true --Force popups/dialogs to have the same tags as the parent client
270
271 ```
272
273 Then edit this section to fit your needs.
274
275 ##### The available tag properties are:
276
277 | Property | Description | Type |
278 | ------------------------- | ---------------------------------------------------- |:----------------:|
279 | **class** | Match these classes to this tag | array of string |
280 | **instance** | Match these instances to this tag. ★ | array of string |
281 | **exclusive** | Allow only client from the "class" attributes | boolean |
282 | **exec_once** | Execute when the tag is first selected | string (command) |
283 | **force_screen** | Force a screen | boolean |
284 | **hide** | Hide this tag from view | boolean |
285 | **icon** | Tag icon | path |
286 | **init** | Create when awesome launch | boolean |
287 | **layout** | The tag layout | layout |
288 | **master_width_factor** | Tiled layout master/slave ratio | float(0-1) |
289 | **column_count** | Number of columns | number |
290 | **master_count** | Number of master clients | number |
291 | **no_focus_stealing_in** | Do not select this tag when a new client is added | boolean |
292 | **no_focus_stealing_out** | Do not unselect when a new client is added elsewhere | boolean |
293 | **no_tag_deselect** | Do not unselect other tags spawning/selecting this | boolean |
294 | **screen** | Tag screen(s) | number or array |
295 | **selected** | Select when created | boolean |
296 | **volatile** | Destroy when the last client is closed | boolean |
297 | **fallback** | Use this tag for unmatched clients | boolean |
298 | **locked** | Do not add any more clients to this tag | boolean |
299 | **max_clients** | Maximum number of clients before creating a new tag | number or func |
300 | **onetimer** | Once deleted, this tag cannot be created again | boolean |
301
302 ★Takes precedence over class
303
304 See: http://new.awesomewm.org/apidoc/classes/tag.html
305
306 ##### The available client properties are:
307
308 Note that every property can also be a function. In that case it has a client
309 as the first parameter and the property array as the second. It must return a
310 value with a compatible type. Those properties are directly converted into
311 `awful.rules`.
312
313 | Property | Description | Type |
314 | ------------------------- | ---------------------------------------------- |:----------------:|
315 | **above** | Display above other clients | boolean |
316 | **below** | Display below other clients | boolean |
317 | **border_color** | Change client default border color* | string |
318 | **border_width** | Change the client border width | number |
319 | **placement** | Center the client on the screen at launch | awful.placement |
320 | **floating** | Make the client floating or insert into layout | boolean |
321 | **focusable** | Allow focus | boolean |
322 | **fullscreen** | Cover the whole screen | boolean |
323 | **hidden** | Hide this client (minimize) | boolean |
324 | **intrusive** | Ignore tag "exclusive" property | boolean |
325 | **maximized_horizontal** | Cover all horizontal space | boolean |
326 | **maximized_vertical** | Cover all vertical space | boolean |
327 | **ontop** | Display on top of the normal layout layer | boolean |
328 | **skip_taskbar** | Do not add to tasklist | boolean |
329 | **sticky** | Display in all tags | boolean |
330 | **master** | Open a client as master (bigger) | boolean |
331 | **slave** | Open a client as slave (smaller) | boolean |
332 | **no_autofocus** | Do not focus a new instance | boolean |
333 | **tag** | Asign to a pre-existing tag object | tag/array/string |
334 | **tags** | Asign to a pre-existing tag object | array |
335 | **new_tag** | Do not focus a new instance | boolean or array |
336 | **callback** | A function returning an array or properties | function |
337
338 *Need default rc.lua modifications in the "client.connect_signal('focus')" section
339
340 See:
341
342 * http://new.awesomewm.org/apidoc/classes/client.html
343 * http://new.awesomewm.org/apidoc/libraries/awful.rules.html
344
345 ##### The available global settings are:
346
347 | Property | Description | Type |
348 | -------------------------------------- | --------------------------------------------------- |:----------------:|
349 | **block_children_focus_stealing** | Prevent popups from stealing focus | boolean |
350 | **default_layout** | The default layout for tags | layout |
351 | **group_children** | Add dialogs to the same tags as their parent client | boolean |
352 | **master_width_factor** | The default master/slave ratio | float (0-1) |
353 | **force_odd_as_intrusive** | Make all non-normal (dock, splash) intrusive | boolean |
354 | **no_focus_stealing_out** | Do not unselect tags when a new client is added | boolean |
355 | **favor_focused** | Prefer the focused screen to the screen property | boolean |
356
357
358 It's worth noting that some settings like `master_width_factor` and `default_layout` should
359 be set **before** the tag arrow. Otherwise they wont take effect at startup.
360
361 **favor_focused** Is enabled by default for tags created after startup for
362 convinience. Use *force_screen* or `tyrannical.settings.favor_focused = false`
363 to do otherwise.
364
365 -----------------------------------------------------
366
367 ### FAQ
368
369 * [Is Tyrannical under active development](https://github.com/Elv13/tyrannical#is-tyrannical-under-active-development)
370 * [Is it possible to add, remove and move tags?](https://github.com/Elv13/tyrannical#is-it-possible-to-add-remove-and-move-tags)
371 * [How do I get a client class?](https://github.com/Elv13/tyrannical#how-do-i-get-a-client-class)
372 * [Is it possible to have relative indexes (position) for tags?](https://github.com/Elv13/tyrannical#is-it-possible-to-have-relative-indexes-position-for-tags)
373 * [Is it possible to change the layout when adding a new client?](https://github.com/Elv13/tyrannical#is-it-possible-to-change-the-layout-when-adding-a-new-client)
374 * [Is it possible to directly launch clients in the current tag or a new one?](https://github.com/Elv13/tyrannical#is-it-possible-to-directly-launch-clients-in-the-current-tag-or-a-new-one)
375 * [Can I alter the client properties based on runtime criterias?](https://github.com/Elv13/tyrannical#can-i-alter-the-client-properties-based-on-runtime-criterias)
376 * [Is it possible to match clients based on properties other than class or instance?](https://github.com/Elv13/tyrannical#is-it-possible-to-match-clients-based-on-properties-other-than-class-or-instance)
377
378 #### Is Tyrannical under active development
379
380 Yes.
381
382 Note that the Tyrannical feature set is complete and the scope isn't likely to
383 be expanded. The new features, if any, are intended to refining the current
384 algorithm. Parts by part, Tyrannical features are upstreamed into Awesome itself
385 and it is where the main development is happening.
386
387 #### Is it possible to add, remove and move tags?
388
389 Yes, this feature is now part of awful. It does not require an external module
390 anymore. Awful's dynamic tag implementation is compatible with Tyrannical. See
391 the [API](http://awesome.naquadah.org/doc/api/) and this
392 [user contribution](https://github.com/Elv13/tyrannical/issues/15#issuecomment-18227575)
393
394 #### How do I get a client class?
395
396 From a terminal, execute `xprop`, then click on an instance of that client.
397 There will be a "CLASS" line with one or more class. Always pick the second one,
398 Tyrannical is not case sensitive.
399
400 #### Is it possible to have relative indexes (position) for tags?
401
402 Tyrannical shares awful's tag list. It does not keep its own indexes since this
403 would make it harder to implement this feature in the core. Given that, this
404 feature is outside the project scope. That being said, nothing prevents you
405 from adding a "position" property to the tag. Once this is done, edit the
406 default `rc.lua` keybindings to find the position by looping the tags. In
407 case the tag is not yet created, you can access it with
408 `tyrannical.tags_by_name["your tag name"]` array. This array is
409 automatically generated. You can then add it using
410 `awful.tag.add(tyrannical.tags_by_name["your tag
411 name"].name,tyrannical.tags_by_name["your tag name"])`. Tyrannical's purpose
412 is not to duplicate or change `awful.tag` behavior, it is simply a
413 configuration wrapper.
414
415 #### Is it possible to change the layout when adding a new client?
416
417 Yes and no. There is a workaround using a `max_clients` callback. This function
418 has to return a number of clients for a given tag, but can also be used to alter
419 them. The function take a client as first parameter and a possible tag as the
420 second. Returning `0` will always force a new tag to be created. Returning nil
421 will allow the client into that tag. This function switch between `tile` and
422 `magnifier`:
423
424 ```lua
425 local function aero_or_magnifier(c,tag)
426 local count = #match:clients() + 1 --The client is not there yet
427 if count == 2 then
428 tag.layout = awful.layout.suit.tile
429 tag.master_width_factor = 0.5
430 else
431 tag.layout = awful.layout.suit.magnifier
432 end
433 return 5 -- Use a maximum of 5 clients
434 end
435 ```
436
437 #### Is it possible to directly launch clients in the current tag or a new one?
438
439 This feature is mostly available for Awesome 3.5.3+, 3.5.6+ is recommanded.
440 Tyrannical will use the "startup notification" field in clients that support it
441 to track a spawn request. Some applications, such as GVim and XTerm, doesn't
442 support this. URxvt, Konsole and Gnome terminal does.
443
444 Here are some example:
445
446 ```lua
447 -- Spawn in a new tag
448 awful.spawn("urxvt",{new_tag=true})
449
450 -- Or for more advanced use case, you can use a full tag definition too
451 awful.spawn("urxvt",{ new_tag= {
452 name = "MyNewTag",
453 exclusive = true,
454 })
455
456 -- Spawn in the current tag, floating and on top
457 awful.spawn(terminal,{intrusive=true, floating=true, ontop=true})
458
459 -- Spawn in an existing tag (assume `my_tag` exist)
460 -- Note that `tag` can also be an array of tags or a function returning
461 -- an array of tags
462 awful.spawn(terminal,{tag=my_tag})
463 ```
464
465 For Awesome 3.5.6+, it is possible to replace the default mod4+r keybinding with
466 a more powerful one:
467
468 ```lua
469 awful.key({ modkey }, "r",
470 function ()
471 awful.prompt.run({ prompt = "Run: ", hooks = {
472 {{ },"Return",function(command)
473 local result = awful.spawn(command)
474 mypromptbox[mouse.screen].widget:set_text(type(result) == "string" and result or "")
475 return true
476 end},
477 {{"Mod1" },"Return",function(command)
478 local result = awful.spawn(command,{intrusive=true})
479 mypromptbox[mouse.screen].widget:set_text(type(result) == "string" and result or "")
480 return true
481 end},
482 {{"Shift" },"Return",function(command)
483 local result = awful.spawn(command,{intrusive=true,ontop=true,floating=true})
484 mypromptbox[mouse.screen].widget:set_text(type(result) == "string" and result or "")
485 return true
486 end}
487 }},
488 mypromptbox[mouse.screen].widget,nil,
489 awful.completion.shell,
490 awful.util.getdir("cache") .. "/history")
491 end),
492 ```
493
494 When using this, instead of pressing `Return` to spawn the application, you can
495 use `Alt+Return` to launch it as an `intrusive` client. You can add more sections
496 to support more use case (such as `Shift+Return` to launch as `floating` as shown
497 above)
498
499 #### Can I alter the client properties based on runtime criterias?
500
501 Yes, everytime Tyrannical consider a client, it will call the `callback` function.
502 This function can return an array or properties that will have precedence over
503 any properties set by rules. The only limitation of this system is that the
504 callback function need to be synchronious. So long bash commands will cause
505 Awesome to block until the result is parsed.
506
507 #### Is it possible to match clients based on properties other than class or instance?
508
509 Yes, but not directly. You need to create a new `awful.rule` that overrides the class property and then match that to your tag:
510
511 ```lua
512 awful.rules.rules = {
513 --default stuff here,
514 {
515 rule = { class = "URxvt", name = "dev" },
516 callback = function(c)
517 c.overwrite_class = "urxvt:dev"
518 end
519 }
520 }
521 ```
522 This example changes the class of URxvt with name "dev" from "urxvt" to "urxvt:dev" which then can be matched to a tag.
523
524 For more information on possible properties look at [Awful Rules](http://awesome.naquadah.org/wiki/Understanding_Rules) or [API](http://awesome.naquadah.org/doc/api/modules/client.html)
525
526 #### What is Tyrannical license?
527
528 Tyrannical is licensed under the [2 clause BSD](http://opensource.org/licenses/BSD-2-Clause)