cnode: move struct to cnode header
[awesome.git] / awesomerc.lua.in
blobfdce4e740cce24b7805c35ef22f49359df5505e8
1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
4 require("awful")
5 require("tabulous")
6 require("beautiful")
8 -- {{{ Variable definitions
9 -- This is a file path to a theme file which will defines colors.
10 theme_path = "@AWESOME_THEMES_PATH@/default"
12 -- This is used later as the default terminal and editor to run.
13 terminal = "xterm"
14 editor = os.getenv("EDITOR") or "nano"
15 editor_cmd = terminal .. " -e " .. editor
17 -- Default modkey.
18 -- Usually, Mod4 is the key with a logo between Control and Alt.
19 -- If you do not like this or do not have such a key,
20 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
21 -- However, you can use another modifier like Mod1, but it may interact with others.
22 modkey = "Mod4"
24 -- Table of layouts to cover with awful.layout.inc, order matters.
25 layouts =
27 "tile",
28 "tileleft",
29 "tilebottom",
30 "tiletop",
31 "fairh",
32 "fairv",
33 "magnifier",
34 "max",
35 "fullscreen",
36 "spiral",
37 "dwindle",
38 "floating"
41 -- Table of clients that should be set floating. The index may be either
42 -- the application class or instance. The instance is useful when running
43 -- a console app in a terminal like (Music on Console)
44 -- xterm -name mocp -e mocp
45 floatapps =
47 -- by class
48 ["MPlayer"] = true,
49 ["pinentry"] = true,
50 ["gimp"] = true,
51 -- by instance
52 ["mocp"] = true
55 -- Applications to be moved to a pre-defined tag by class or instance.
56 -- Use the screen and tags indices.
57 apptags =
59 -- ["Firefox"] = { screen = 1, tag = 2 },
60 -- ["mocp"] = { screen = 2, tag = 4 },
63 -- Define if we want to use titlebar on all applications.
64 use_titlebar = false
65 -- }}}
67 -- {{{ Initialization
68 -- Initialize theme (colors).
69 beautiful.init(theme_path)
71 -- Register theme in awful.
72 -- This allows to not pass plenty of arguments to each function
73 -- to inform it about colors we want it to draw.
74 awful.beautiful.register(beautiful)
76 -- Uncomment this to activate autotabbing
77 -- tabulous.autotab_start()
78 -- }}}
80 -- {{{ Tags
81 -- Define tags table.
82 tags = {}
83 for s = 1, screen.count() do
84 -- Each screen has its own tag table.
85 tags[s] = {}
86 -- Create 9 tags per screen.
87 for tagnumber = 1, 9 do
88 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
89 -- Add tags to screen one by one
90 tags[s][tagnumber].screen = s
91 end
92 -- I'm sure you want to see at least one tag.
93 tags[s][1].selected = true
94 end
95 -- }}}
97 -- {{{ Wibox
98 -- Create a textbox widget
99 mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
100 -- Set the default text in textbox
101 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
103 -- Create a laucher widget and a main menu
104 myawesomemenu = {
105 {"manual", terminal .. " -e man awesome" },
106 {"edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
107 {"restart", awesome.restart },
108 {"quit", awesome.quit }
111 mymainmenu = {
112 {"awesome", myawesomemenu, "@AWESOME_ICON_PATH@/awesome16.png" },
113 {"open terminal", terminal }
116 mylauncher = awful.widget.launcher({ name = "mylauncher",
117 image = "@AWESOME_ICON_PATH@/awesome16.png",
118 menu = { id="mymainmenu", items=mymainmenu } })
120 -- Create a systray
121 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
124 -- Create a wibox for each screen and add it
125 mywibox = {}
126 mypromptbox = {}
127 mylayoutbox = {}
128 mytaglist = {}
129 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
130 button({ modkey }, 1, awful.client.movetotag),
131 button({ }, 3, function (tag) tag.selected = not tag.selected end),
132 button({ modkey }, 3, awful.client.toggletag),
133 button({ }, 4, awful.tag.viewnext),
134 button({ }, 5, awful.tag.viewprev) }
135 mytasklist = {}
136 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
137 button({ }, 4, function () awful.client.focus.byidx(1) end),
138 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
140 for s = 1, screen.count() do
141 -- Create a promptbox for each screen
142 mypromptbox[s] = widget({ type = "textbox", name = "mypromptbox" .. s, align = "left" })
143 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
144 -- We need one layoutbox per screen.
145 mylayoutbox[s] = widget({ type = "imagebox", name = "mylayoutbox", align = "right" })
146 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
147 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
148 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
149 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
150 -- Create a taglist widget
151 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
153 -- Create a tasklist widget
154 mytasklist[s] = awful.widget.tasklist.new(function(c)
155 return awful.widget.tasklist.label.currenttags(c, s)
156 end, mytasklist.buttons)
158 -- Create the wibox
159 mywibox[s] = wibox({ position = "top", name = "mywibox" .. s,
160 fg = beautiful.fg_normal, bg = beautiful.bg_normal })
161 -- Add widgets to the wibox - order matters
162 mywibox[s].widgets = { mytaglist[s],
163 mylauncher,
164 mytasklist[s],
165 mypromptbox[s],
166 mytextbox,
167 mylayoutbox[s],
168 s == 1 and mysystray or nil }
169 mywibox[s].screen = s
171 -- }}}
173 -- {{{ Mouse bindings
174 awesome.buttons({
175 button({ }, 3, function () awful.menu.new({ id="mymainmenu", items=mymainmenu }) end),
176 button({ }, 4, awful.tag.viewnext),
177 button({ }, 5, awful.tag.viewprev)
179 -- }}}
181 -- {{{ Key bindings
183 -- Bind keyboard digits
184 -- Compute the maximum number of digit we need, limited to 9
185 keynumber = 0
186 for s = 1, screen.count() do
187 keynumber = math.min(9, math.max(#tags[s], keynumber));
190 for i = 1, keynumber do
191 keybinding({ modkey }, i,
192 function ()
193 local screen = mouse.screen
194 if tags[screen][i] then
195 awful.tag.viewonly(tags[screen][i])
197 end):add()
198 keybinding({ modkey, "Control" }, i,
199 function ()
200 local screen = mouse.screen
201 if tags[screen][i] then
202 tags[screen][i].selected = not tags[screen][i].selected
204 end):add()
205 keybinding({ modkey, "Shift" }, i,
206 function ()
207 if client.focus then
208 if tags[client.focus.screen][i] then
209 awful.client.movetotag(tags[client.focus.screen][i])
212 end):add()
213 keybinding({ modkey, "Control", "Shift" }, i,
214 function ()
215 if client.focus then
216 if tags[client.focus.screen][i] then
217 awful.client.toggletag(tags[client.focus.screen][i])
220 end):add()
223 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
224 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
225 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
227 -- Standard program
228 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
230 keybinding({ modkey, "Control" }, "r", function ()
231 mypromptbox[mouse.screen].text =
232 awful.util.escape(awful.util.restart())
233 end):add()
234 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
236 -- Client manipulation
237 keybinding({ modkey }, "m", awful.client.maximize):add()
238 keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
239 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
240 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
241 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
242 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
243 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
244 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
245 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
246 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
247 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
248 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
249 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
250 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
251 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
253 -- Layout manipulation
254 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
255 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
256 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
257 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
258 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
259 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
260 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
261 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
263 -- Prompt
264 keybinding({ modkey }, "F1", function ()
265 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
266 awful.util.getdir("cache") .. "/history") end):add()
267 keybinding({ modkey }, "F4", function ()
268 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
269 awful.util.getdir("cache") .. "/history_eval") end):add()
270 keybinding({ modkey, "Ctrl" }, "i", function ()
271 local s = mouse.screen
272 if mypromptbox[s].text then
273 mypromptbox[s].text = nil
274 else
275 mypromptbox[s].text = nil
276 if client.focus.class then
277 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
279 if client.focus.instance then
280 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
282 if client.focus.role then
283 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
286 end):add()
288 --- Tabulous, tab manipulation
289 keybinding({ modkey, "Control" }, "y", function ()
290 local tabbedview = tabulous.tabindex_get()
291 local nextclient = awful.client.next(1)
293 if not tabbedview then
294 tabbedview = tabulous.tabindex_get(nextclient)
296 if not tabbedview then
297 tabbedview = tabulous.tab_create()
298 tabulous.tab(tabbedview, nextclient)
299 else
300 tabulous.tab(tabbedview, client.focus)
302 else
303 tabulous.tab(tabbedview, nextclient)
305 end):add()
307 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
309 keybinding({ modkey }, "y", function ()
310 local tabbedview = tabulous.tabindex_get()
312 if tabbedview then
313 local n = tabulous.next(tabbedview)
314 tabulous.display(tabbedview, n)
316 end):add()
318 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
319 keybinding({ modkey }, "t", awful.client.togglemarked):add()
320 keybinding({ modkey, 'Shift' }, "t", function ()
321 local tabbedview = tabulous.tabindex_get()
322 local clients = awful.client.getmarked()
324 if not tabbedview then
325 tabbedview = tabulous.tab_create(clients[1])
326 table.remove(clients, 1)
329 for k,c in pairs(clients) do
330 tabulous.tab(tabbedview, c)
333 end):add()
335 for i = 1, keynumber do
336 keybinding({ modkey, "Shift" }, "F" .. i,
337 function ()
338 local screen = mouse.screen
339 if tags[screen][i] then
340 for k, c in pairs(awful.client.getmarked()) do
341 awful.client.movetotag(tags[screen][i], c)
344 end):add()
346 -- }}}
348 -- {{{ Hooks
349 -- Hook function to execute when focusing a client.
350 awful.hooks.focus.register(function (c)
351 if not awful.client.ismarked(c) then
352 c.border_color = beautiful.border_focus
354 end)
356 -- Hook function to execute when unfocusing a client.
357 awful.hooks.unfocus.register(function (c)
358 if not awful.client.ismarked(c) then
359 c.border_color = beautiful.border_normal
361 end)
363 -- Hook function to execute when marking a client
364 awful.hooks.marked.register(function (c)
365 c.border_color = beautiful.border_marked
366 end)
368 -- Hook function to execute when unmarking a client
369 awful.hooks.unmarked.register(function (c)
370 c.border_color = beautiful.border_focus
371 end)
373 -- Hook function to execute when the mouse is over a client.
374 awful.hooks.mouse_enter.register(function (c)
375 -- Sloppy focus, but disabled for magnifier layout
376 if awful.layout.get(c.screen) ~= "magnifier"
377 and awful.client.focus.filter(c) then
378 client.focus = c
380 end)
382 -- Hook function to execute when a new client appears.
383 awful.hooks.manage.register(function (c)
384 if use_titlebar then
385 -- Add a titlebar
386 awful.titlebar.add(c, { modkey = modkey })
388 -- Add mouse bindings
389 c:buttons({
390 button({ }, 1, function (c) client.focus = c; c:raise() end),
391 button({ modkey }, 1, function (c) c:mouse_move() end),
392 button({ modkey }, 3, function (c) c:mouse_resize() end)
394 -- New client may not receive focus
395 -- if they're not focusable, so set border anyway.
396 c.border_width = beautiful.border_width
397 c.border_color = beautiful.border_normal
398 client.focus = c
400 -- Check if the application should be floating.
401 local cls = c.class
402 local inst = c.instance
403 if floatapps[cls] then
404 c.floating = floatapps[cls]
405 elseif floatapps[inst] then
406 c.floating = floatapps[inst]
409 -- Check application->screen/tag mappings.
410 local target
411 if apptags[cls] then
412 target = apptags[cls]
413 elseif apptags[inst] then
414 target = apptags[inst]
416 if target then
417 c.screen = target.screen
418 awful.client.movetotag(tags[target.screen][target.tag], c)
421 -- Set the windows at the slave,
422 -- i.e. put it at the end of others instead of setting it master.
423 -- awful.client.setslave(c)
425 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
426 -- c.honorsizehints = false
427 end)
429 -- Hook function to execute when arranging the screen
430 -- (tag switch, new client, etc)
431 awful.hooks.arrange.register(function (screen)
432 local layout = awful.layout.get(screen)
433 if layout then
434 mylayoutbox[screen].image = image("@AWESOME_ICON_PATH@/layouts/" .. layout .. "w.png")
435 else
436 mylayoutbox[screen].image = nil
439 -- Give focus to the latest client in history if no window has focus
440 -- or if the current window is a desktop or a dock one.
441 if not client.focus then
442 local c = awful.client.focus.history.get(screen, 0)
443 if c then client.focus = c end
446 -- Uncomment if you want mouse warping
447 --[[
448 if client.focus then
449 local c_c = client.focus:geometry()
450 local m_c = mouse.coords()
452 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
453 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
454 if table.maxn(m_c.buttons) == 0 then
455 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
460 end)
462 -- Hook called every second
463 awful.hooks.timer.register(1, function ()
464 -- For unix time_t lovers
465 mytextbox.text = " " .. os.time() .. " time_t "
466 -- Otherwise use:
467 -- mytextbox.text = " " .. os.date() .. " "
468 end)
469 -- }}}