Debian Codegraph @

tyrannical/example.rc.lua

raw symbols SCIP
1
2 -- Standard awesome library
3 local gears = require("gears")
4 local awful = require("awful")
5 awful.rules = require("awful.rules")
6 local tyrannical = require("tyrannical")
7 require("awful.autofocus")
8 -- Widget and layout library
9 local wibox = require("wibox")
10 -- Theme handling library
11 local beautiful = require("beautiful")
12 -- Notification library
13 local naughty = require("naughty")
14 local menubar = require("menubar")
15 local hotkeys_popup = require("awful.hotkeys_popup").widget
16
17 -- {{{ Error handling
18 -- Check if awesome encountered an error during startup and fell back to
19 -- another config (This code will only ever execute for the fallback config)
20 if awesome.startup_errors then
21 naughty.notify({ preset = naughty.config.presets.critical,
22 title = "Oops, there were errors during startup!",
23 text = awesome.startup_errors })
24 end
25
26 -- Handle runtime errors after startup
27 do
28 local in_error = false
29 awesome.connect_signal("debug::error", function (err)
30 -- Make sure we don't go into an endless error loop
31 if in_error then return end
32 in_error = true
33
34 naughty.notify({ preset = naughty.config.presets.critical,
35 title = "Oops, an error happened!",
36 text = err })
37 in_error = false
38 end)
39 end
40 -- }}}
41
42 -- {{{ Variable definitions
43 -- Themes define colours, icons, and wallpapers
44 beautiful.init(awful.util.get_themes_dir() .. "default/theme.lua")
45
46 -- This is used later as the default terminal and editor to run.
47 terminal = "xterm"
48 editor = os.getenv("EDITOR") or "nano"
49 editor_cmd = terminal .. " -e " .. editor
50
51 -- Default modkey.
52 -- Usually, Mod4 is the key with a logo between Control and Alt.
53 -- If you do not like this or do not have such a key,
54 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
55 -- However, you can use another modifier like Mod1, but it may interact with others.
56 modkey = "Mod4"
57
58 -- Table of layouts to cover with awful.layout.inc, order matters.
59 awful.layout.layouts = {
60 awful.layout.suit.floating,
61 awful.layout.suit.tile,
62 awful.layout.suit.tile.left,
63 awful.layout.suit.tile.bottom,
64 awful.layout.suit.tile.top,
65 awful.layout.suit.fair,
66 awful.layout.suit.fair.horizontal,
67 awful.layout.suit.spiral,
68 awful.layout.suit.spiral.dwindle,
69 awful.layout.suit.max,
70 awful.layout.suit.max.fullscreen,
71 awful.layout.suit.magnifier,
72 awful.layout.suit.corner.nw,
73 -- awful.layout.suit.corner.ne,
74 -- awful.layout.suit.corner.sw,
75 -- awful.layout.suit.corner.se,
76 }
77 -- }}}
78
79 -- {{{ Helper functions
80 local function client_menu_toggle_fn()
81 local instance = nil
82
83 return function ()
84 if instance and instance.wibox.visible then
85 instance:hide()
86 instance = nil
87 else
88 instance = awful.menu.clients({ theme = { width = 250 } })
89 end
90 end
91 end
92 -- }}}
93
94 -- First, set some settings
95 tyrannical.settings.default_layout = awful.layout.suit.tile.left
96 tyrannical.settings.master_width_factor = 0.66
97
98 -- Setup some tags
99 tyrannical.tags = {
100 {
101 name = "Term", -- Call the tag "Term"
102 init = true, -- Load the tag on startup
103 exclusive = true, -- Refuse any other type of clients (by classes)
104 screen = {1,2}, -- Create this tag on screen 1 and screen 2
105 layout = awful.layout.suit.tile, -- Use the tile layout
106 selected = true,
107 class = { --Accept the following classes, refuse everything else (because of "exclusive=true")
108 "xterm" , "urxvt" , "aterm","URxvt","XTerm","konsole","terminator","gnome-terminal"
109 }
110 } ,
111 {
112 name = "Internet",
113 init = true,
114 exclusive = true,
115 --icon = "~net.png", -- Use this icon for the tag (uncomment with a real path)
116 screen = screen.count()>1 and 2 or 1,-- Setup on screen 2 if there is more than 1 screen, else on screen 1
117 layout = awful.layout.suit.max, -- Use the max layout
118 class = {
119 "Opera" , "Firefox" , "Rekonq" , "Dillo" , "Arora",
120 "Chromium" , "nightly" , "minefield" }
121 } ,
122 {
123 name = "Files",
124 init = true,
125 exclusive = true,
126 screen = 1,
127 layout = awful.layout.suit.tile,
128 exec_once = {"dolphin"}, --When the tag is accessed for the first time, execute this command
129 class = {
130 "Thunar", "Konqueror", "Dolphin", "ark", "Nautilus","emelfm"
131 }
132 } ,
133 {
134 name = "Develop",
135 init = true,
136 exclusive = true,
137 screen = 1,
138 clone_on = 2, -- Create a single instance of this tag on screen 1, but also show it on screen 2
139 -- The tag can be used on both screen, but only one at once
140 layout = awful.layout.suit.max ,
141 class ={
142 "Kate", "KDevelop", "Codeblocks", "Code::Blocks" , "DDD", "kate4"}
143 } ,
144 {
145 name = "Doc",
146 init = false, -- This tag wont be created at startup, but will be when one of the
147 -- client in the "class" section will start. It will be created on
148 -- the client startup screen
149 exclusive = true,
150 layout = awful.layout.suit.max,
151 class = {
152 "Assistant" , "Okular" , "Evince" , "EPDFviewer" , "xpdf",
153 "Xpdf" , }
154 } ,
155 }
156
157 -- Ignore the tag "exclusive" property for the following clients (matched by classes)
158 tyrannical.properties.intrusive = {
159 "ksnapshot" , "pinentry" , "gtksu" , "kcalc" , "xcalc" ,
160 "feh" , "Gradient editor", "About KDE" , "Paste Special", "Background color" ,
161 "kcolorchooser" , "plasmoidviewer" , "Xephyr" , "kruler" , "plasmaengineexplorer",
162 }
163
164 -- Ignore the tiled layout for the matching clients
165 tyrannical.properties.floating = {
166 "MPlayer" , "pinentry" , "ksnapshot" , "pinentry" , "gtksu" ,
167 "xine" , "feh" , "kmix" , "kcalc" , "xcalc" ,
168 "yakuake" , "Select Color$" , "kruler" , "kcolorchooser", "Paste Special" ,
169 "New Form" , "Insert Picture" , "kcharselect", "mythfrontend" , "plasmoidviewer"
170 }
171
172 -- Make the matching clients (by classes) on top of the default layout
173 tyrannical.properties.ontop = {
174 "Xephyr" , "ksnapshot" , "kruler"
175 }
176
177 -- Force the matching clients (by classes) to be centered on the screen on init
178 tyrannical.properties.centered = {
179 "kcalc"
180 }
181
182 -- Do not honor size hints request for those classes
183 tyrannical.properties.size_hints_honor = { xterm = false, URxvt = false, aterm = false, sauer_client = false, mythfrontend = false}
184
185 -- }}}
186
187 -- {{{ Menu
188 -- Create a laucher widget and a main menu
189 myawesomemenu = {
190 { "manual", terminal .. " -e man awesome" },
191 { "edit config", editor_cmd .. " " .. awesome.conffile },
192 { "restart", awesome.restart },
193 { "quit", function() awesome.quit() end },
194 }
195
196 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
197 { "open terminal", terminal }
198 }
199 })
200
201 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
202 menu = mymainmenu })
203
204 -- Menubar configuration
205 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
206 -- }}}
207
208 -- {{{ Wibox
209 -- Create a textclock widget
210 mytextclock = awful.widget.textclock()
211
212 -- Create a wibox for each screen and add it
213 -- @TAGLIST_BUTTON@
214 local taglist_buttons = awful.util.table.join(
215 awful.button({ }, 1, function(t) t:view_only() end),
216 awful.button({ modkey }, 1, function(t)
217 if client.focus then
218 client.focus:move_to_tag(t)
219 end
220 end),
221 awful.button({ }, 3, awful.tag.viewtoggle),
222 awful.button({ modkey }, 3, function(t)
223 if client.focus then
224 client.focus:toggle_tag(t)
225 end
226 end),
227 awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
228 awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
229 )
230
231 -- @TASKLIST_BUTTON@
232 local tasklist_buttons = awful.util.table.join(
233 awful.button({ }, 1, function (c)
234 if c == client.focus then
235 c.minimized = true
236 else
237 -- Without this, the following
238 -- :isvisible() makes no sense
239 c.minimized = false
240 if not c:isvisible() and c.first_tag then
241 c.first_tag:view_only()
242 end
243 -- This will also un-minimize
244 -- the client, if needed
245 client.focus = c
246 c:raise()
247 end
248 end),
249 awful.button({ }, 3, client_menu_toggle_fn()),
250 awful.button({ }, 4, function ()
251 awful.client.focus.byidx(1)
252 end),
253 awful.button({ }, 5, function ()
254 awful.client.focus.byidx(-1)
255 end))
256
257 -- @DOC_WALLPAPER@
258 local function set_wallpaper(s)
259 -- Wallpaper
260 if beautiful.wallpaper then
261 local wallpaper = beautiful.wallpaper
262 -- If wallpaper is a function, call it with the screen
263 if type(wallpaper) == "function" then
264 wallpaper = wallpaper(s)
265 end
266 gears.wallpaper.maximized(wallpaper, s, true)
267 end
268 end
269
270 -- Re-set wallpaper when a screen's geometry changes (e.g. different resolution)
271 screen.connect_signal("property::geometry", set_wallpaper)
272
273 -- @DOC_FOR_EACH_SCREEN@
274 awful.screen.connect_for_each_screen(function(s)
275 -- Wallpaper
276 set_wallpaper(s)
277
278 -- Create a promptbox for each screen
279 s.mypromptbox = awful.widget.prompt()
280 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
281 -- We need one layoutbox per screen.
282 s.mylayoutbox = awful.widget.layoutbox(s)
283 s.mylayoutbox:buttons(awful.util.table.join(
284 awful.button({ }, 1, function () awful.layout.inc(awful.layout.layouts, 1) end),
285 awful.button({ }, 3, function () awful.layout.inc(awful.layout.layouts, -1) end),
286 awful.button({ }, 4, function () awful.layout.inc(awful.layout.layouts, 1) end),
287 awful.button({ }, 5, function () awful.layout.inc(awful.layout.layouts, -1) end)))
288 -- Create a taglist widget
289 s.mytaglist = awful.widget.taglist(s, awful.widget.taglist.filter.all, taglist_buttons)
290
291 -- Create a tasklist widget
292 s.mytasklist = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, tasklist_buttons)
293
294 -- @DOC_WIBAR@
295 -- Create the wibox
296 s.mywibox = awful.wibar({ position = "top", screen = s })
297
298 -- @DOC_SETUP_WIDGETS@
299 -- Add widgets to the wibox
300 s.mywibox:setup {
301 layout = wibox.layout.align.horizontal,
302 { -- Left widgets
303 layout = wibox.layout.fixed.horizontal,
304 mylauncher,
305 s.mytaglist,
306 s.mypromptbox,
307 },
308 s.mytasklist, -- Middle widget
309 { -- Right widgets
310 layout = wibox.layout.fixed.horizontal,
311 mykeyboardlayout,
312 wibox.widget.systray(),
313 mytextclock,
314 s.mylayoutbox,
315 },
316 }
317 end)
318 -- }}}
319
320 -- {{{ Mouse bindings
321 -- @DOC_ROOT_BUTTONS@
322 root.buttons(awful.util.table.join(
323 awful.button({ }, 3, function () mymainmenu:toggle() end),
324 awful.button({ }, 4, awful.tag.viewnext),
325 awful.button({ }, 5, awful.tag.viewprev)
326 ))
327 -- }}}
328
329 -- {{{ Key bindings
330 -- @DOC_GLOBAL_KEYBINDINGS@
331 globalkeys = awful.util.table.join(
332 awful.key({ modkey, }, "s", hotkeys_popup.show_help,
333 {description="show help", group="awesome"}),
334 awful.key({ modkey, }, "Left", awful.tag.viewprev,
335 {description = "view previous", group = "tag"}),
336 awful.key({ modkey, }, "Right", awful.tag.viewnext,
337 {description = "view next", group = "tag"}),
338 awful.key({ modkey, }, "Escape", awful.tag.history.restore,
339 {description = "go back", group = "tag"}),
340
341 awful.key({ modkey, }, "j",
342 function ()
343 awful.client.focus.byidx( 1)
344 end,
345 {description = "focus next by index", group = "client"}
346 ),
347 awful.key({ modkey, }, "k",
348 function ()
349 awful.client.focus.byidx(-1)
350 end,
351 {description = "focus previous by index", group = "client"}
352 ),
353 awful.key({ modkey, }, "w", function () mymainmenu:show() end,
354 {description = "show main menu", group = "awesome"}),
355
356 -- Layout manipulation
357 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end,
358 {description = "swap with next client by index", group = "client"}),
359 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end,
360 {description = "swap with previous client by index", group = "client"}),
361 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end,
362 {description = "focus the next screen", group = "screen"}),
363 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end,
364 {description = "focus the previous screen", group = "screen"}),
365 awful.key({ modkey, }, "u", awful.client.urgent.jumpto,
366 {description = "jump to urgent client", group = "client"}),
367 awful.key({ modkey, }, "Tab",
368 function ()
369 awful.client.focus.history.previous()
370 if client.focus then
371 client.focus:raise()
372 end
373 end,
374 {description = "go back", group = "client"}),
375
376 -- Standard program
377 awful.key({ modkey, }, "Return", function () awful.spawn(terminal) end,
378 {description = "open a terminal", group = "launcher"}),
379 awful.key({ modkey, "Control" }, "r", awesome.restart,
380 {description = "reload awesome", group = "awesome"}),
381 awful.key({ modkey, "Shift" }, "q", awesome.quit,
382 {description = "quit awesome", group = "awesome"}),
383
384 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end,
385 {description = "increase master width factor", group = "layout"}),
386 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end,
387 {description = "decrease master width factor", group = "layout"}),
388 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1, nil, true) end,
389 {description = "increase the number of master clients", group = "layout"}),
390 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1, nil, true) end,
391 {description = "decrease the number of master clients", group = "layout"}),
392 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1, nil, true) end,
393 {description = "increase the number of columns", group = "layout"}),
394 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1, nil, true) end,
395 {description = "decrease the number of columns", group = "layout"}),
396 awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
397 {description = "select next", group = "layout"}),
398 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(-1) end,
399 {description = "select previous", group = "layout"}),
400
401 awful.key({ modkey, "Control" }, "n",
402 function ()
403 local c = awful.client.restore()
404 -- Focus restored client
405 if c then
406 client.focus = c
407 c:raise()
408 end
409 end,
410 {description = "restore minimized", group = "client"}),
411
412 -- Prompt
413 awful.key({ modkey }, "r", function () awful.screen.focused().mypromptbox:run() end,
414 {description = "run prompt", group = "launcher"}),
415
416 awful.key({ modkey }, "x",
417 function ()
418 awful.prompt.run {
419 prompt = "Run Lua code: ",
420 textbox = awful.screen.focused().mypromptbox.widget,
421 exe_callback = awful.util.eval,
422 history_path = awful.util.get_cache_dir() .. "/history_eval"
423 }
424 end,
425 {description = "lua execute prompt", group = "awesome"}),
426 -- Menubar
427 awful.key({ modkey }, "p", function() menubar.show() end,
428 {description = "show the menubar", group = "launcher"})
429 )
430
431 -- @DOC_CLIENT_KEYBINDINGS@
432 clientkeys = awful.util.table.join(
433 awful.key({ modkey, }, "f",
434 function (c)
435 c.fullscreen = not c.fullscreen
436 c:raise()
437 end,
438 {description = "toggle fullscreen", group = "client"}),
439 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end,
440 {description = "close", group = "client"}),
441 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ,
442 {description = "toggle floating", group = "client"}),
443 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end,
444 {description = "move to master", group = "client"}),
445 awful.key({ modkey, }, "o", function (c) c:move_to_screen() end,
446 {description = "move to screen", group = "client"}),
447 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end,
448 {description = "toggle keep on top", group = "client"}),
449 awful.key({ modkey, }, "n",
450 function (c)
451 -- The client currently has the input focus, so it cannot be
452 -- minimized, since minimized clients can't have the focus.
453 c.minimized = true
454 end ,
455 {description = "minimize", group = "client"}),
456 awful.key({ modkey, }, "m",
457 function (c)
458 c.maximized = not c.maximized
459 c:raise()
460 end ,
461 {description = "maximize", group = "client"})
462 )
463
464 -- @DOC_NUMBER_KEYBINDINGS@
465 -- Bind all key numbers to tags.
466 -- Be careful: we use keycodes to make it work on any keyboard layout.
467 -- This should map on the top row of your keyboard, usually 1 to 9.
468 for i = 1, 9 do
469 globalkeys = awful.util.table.join(globalkeys,
470 -- View tag only.
471 awful.key({ modkey }, "#" .. i + 9,
472 function ()
473 local screen = awful.screen.focused()
474 local tag = screen.tags[i]
475 if tag then
476 tag:view_only()
477 end
478 end,
479 {description = "view tag #"..i, group = "tag"}),
480 -- Toggle tag display.
481 awful.key({ modkey, "Control" }, "#" .. i + 9,
482 function ()
483 local screen = awful.screen.focused()
484 local tag = screen.tags[i]
485 if tag then
486 awful.tag.viewtoggle(tag)
487 end
488 end,
489 {description = "toggle tag #" .. i, group = "tag"}),
490 -- Move client to tag.
491 awful.key({ modkey, "Shift" }, "#" .. i + 9,
492 function ()
493 if client.focus then
494 local tag = client.focus.screen.tags[i]
495 if tag then
496 client.focus:move_to_tag(tag)
497 end
498 end
499 end,
500 {description = "move focused client to tag #"..i, group = "tag"}),
501 -- Toggle tag on focused client.
502 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
503 function ()
504 if client.focus then
505 local tag = client.focus.screen.tags[i]
506 if tag then
507 client.focus:toggle_tag(tag)
508 end
509 end
510 end,
511 {description = "toggle focused client on tag #" .. i, group = "tag"})
512 )
513 end
514
515 -- @DOC_CLIENT_BUTTONS@
516 clientbuttons = awful.util.table.join(
517 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
518 awful.button({ modkey }, 1, awful.mouse.client.move),
519 awful.button({ modkey }, 3, awful.mouse.client.resize))
520
521 -- Set keys
522 root.keys(globalkeys)
523 -- }}}
524
525 -- {{{ Rules
526 -- Rules to apply to new clients (through the "manage" signal).
527 -- @DOC_RULES@
528 awful.rules.rules = {
529 -- @DOC_GLOBAL_RULE@
530 -- All clients will match this rule.
531 { rule = { },
532 properties = { border_width = beautiful.border_width,
533 border_color = beautiful.border_normal,
534 focus = awful.client.focus.filter,
535 raise = true,
536 keys = clientkeys,
537 buttons = clientbuttons,
538 screen = awful.screen.preferred,
539 placement = awful.placement.no_overlap+awful.placement.no_offscreen
540 }
541 },
542
543 -- @DOC_FLOATING_RULE@
544 -- Floating clients.
545 { rule_any = {
546 instance = {
547 "DTA", -- Firefox addon DownThemAll.
548 "copyq", -- Includes session name in class.
549 },
550 class = {
551 "Arandr",
552 "Gpick",
553 "Kruler",
554 "MessageWin", -- kalarm.
555 "Sxiv",
556 "Wpa_gui",
557 "pinentry",
558 "veromix",
559 "xtightvncviewer"},
560
561 name = {
562 "Event Tester", -- xev.
563 },
564 role = {
565 "AlarmWindow", -- Thunderbird's calendar.
566 "pop-up", -- e.g. Google Chrome's (detached) Developer Tools.
567 }
568 }, properties = { floating = true }},
569
570 -- @DOC_DIALOG_RULE@
571 -- Add titlebars to normal clients and dialogs
572 { rule_any = {type = { "normal", "dialog" }
573 }, properties = { titlebars_enabled = true }
574 },
575
576 -- Set Firefox to always map on the tag named "2" on screen 1.
577 -- { rule = { class = "Firefox" },
578 -- properties = { screen = 1, tag = "2" } },
579 }
580 -- }}}
581
582 -- {{{ Signals
583 -- Signal function to execute when a new client appears.
584 -- @DOC_MANAGE_HOOK@
585 client.connect_signal("manage", function (c)
586 -- Set the windows at the slave,
587 -- i.e. put it at the end of others instead of setting it master.
588 -- if not awesome.startup then awful.client.setslave(c) end
589
590 if awesome.startup and
591 not c.size_hints.user_position
592 and not c.size_hints.program_position then
593 -- Prevent clients from being unreachable after screen count changes.
594 awful.placement.no_offscreen(c)
595 end
596 end)
597
598 -- @DOC_TITLEBARS@
599 -- Add a titlebar if titlebars_enabled is set to true in the rules.
600 client.connect_signal("request::titlebars", function(c)
601 -- buttons for the titlebar
602 local buttons = awful.util.table.join(
603 awful.button({ }, 1, function()
604 client.focus = c
605 c:raise()
606 awful.mouse.client.move(c)
607 end),
608 awful.button({ }, 3, function()
609 client.focus = c
610 c:raise()
611 awful.mouse.client.resize(c)
612 end)
613 )
614
615 awful.titlebar(c) : setup {
616 { -- Left
617 awful.titlebar.widget.iconwidget(c),
618 buttons = buttons,
619 layout = wibox.layout.fixed.horizontal
620 },
621 { -- Middle
622 { -- Title
623 align = "center",
624 widget = awful.titlebar.widget.titlewidget(c)
625 },
626 buttons = buttons,
627 layout = wibox.layout.flex.horizontal
628 },
629 { -- Right
630 awful.titlebar.widget.floatingbutton (c),
631 awful.titlebar.widget.maximizedbutton(c),
632 awful.titlebar.widget.stickybutton (c),
633 awful.titlebar.widget.ontopbutton (c),
634 awful.titlebar.widget.closebutton (c),
635 layout = wibox.layout.fixed.horizontal()
636 },
637 layout = wibox.layout.align.horizontal
638 }
639 end)
640
641 -- Enable sloppy focus, so that focus follows mouse.
642 client.connect_signal("mouse::enter", function(c)
643 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
644 and awful.client.focus.filter(c) then
645 client.focus = c
646 end
647 end)
648
649 -- @DOC_BORDER@
650 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
651 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
652 -- }}}