Fix 1800 points bug and finally get beautiful support working
[awesome.git] / awesomerc.lua.in
blobc8c54dc236caa8bca9ff637081b8c35a9ea1146d
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 to run.
13 terminal = "xterm"
15 -- Default modkey.
16 -- Usually, Mod4 is the key with a logo between Control and Alt.
17 -- If you do not like this or do not have such a key,
18 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
19 -- However, you can use another modifier like Mod1, but it may interact with others.
20 modkey = "Mod4"
22 -- Table of layouts to cover with awful.layout.inc, order matters.
23 layouts =
25 "tile",
26 "tileleft",
27 "tilebottom",
28 "tiletop",
29 "fairh",
30 "fairv",
31 "magnifier",
32 "max",
33 "fullscreen",
34 "spiral",
35 "dwindle",
36 "floating"
39 -- Table of clients that should be set floating. The index may be either
40 -- the application class or instance. The instance is useful when running
41 -- a console app in a terminal like (Music on Console)
42 -- xterm -name mocp -e mocp
43 floatapps =
45 -- by class
46 ["MPlayer"] = true,
47 ["pinentry"] = true,
48 ["gimp"] = true,
49 -- by instance
50 ["mocp"] = true
53 -- Applications to be moved to a pre-defined tag by class or instance.
54 -- Use the screen and tags indices.
55 apptags =
57 -- ["Firefox"] = { screen = 1, tag = 2 },
58 -- ["mocp"] = { screen = 2, tag = 4 },
61 -- Define if we want to use titlebar on all applications.
62 use_titlebar = false
63 -- }}}
65 -- {{{ Initialization
66 -- Initialize theme (colors).
67 beautiful.init(theme_path)
69 -- Register theme in awful.
70 -- This allows to not pass plenty of arguments to each function
71 -- to inform it about colors we want it to draw.
72 awful.beautiful.register(beautiful)
74 -- Uncomment this to activate autotabbing
75 -- tabulous.autotab_start()
76 -- }}}
78 -- {{{ Tags
79 -- Define tags table.
80 tags = {}
81 for s = 1, screen.count() do
82 -- Each screen has its own tag table.
83 tags[s] = {}
84 -- Create 9 tags per screen.
85 for tagnumber = 1, 9 do
86 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
87 -- Add tags to screen one by one
88 tags[s][tagnumber].screen = s
89 end
90 -- I'm sure you want to see at least one tag.
91 tags[s][1].selected = true
92 end
93 -- }}}
95 -- {{{ Wibox
96 -- Create a taglist widget
97 mytaglist = widget({ type = "taglist", name = "mytaglist" })
98 mytaglist:buttons({
99 button({ }, 1, function (object, tag) awful.tag.viewonly(tag) end),
100 button({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end),
101 button({ }, 3, function (object, tag) tag.selected = not tag.selected end),
102 button({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end),
103 button({ }, 4, awful.tag.viewnext),
104 button({ }, 5, awful.tag.viewprev)
106 mytaglist.label = awful.widget.taglist.label.all
108 -- Create a tasklist widget
109 mytasklist = widget({ type = "tasklist", name = "mytasklist" })
110 mytasklist:buttons({
111 button({ }, 1, function (object, c) client.focus = c; c:raise() end),
112 button({ }, 4, function () awful.client.focus.byidx(1) end),
113 button({ }, 5, function () awful.client.focus.byidx(-1) end)
115 mytasklist.label = awful.widget.tasklist.label.currenttags
117 -- Create a textbox widget
118 mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
119 -- Set the default text in textbox
120 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
122 -- Create a laucher widget
123 mylauncher = awful.widget.launcher({ name = "mylauncher",
124 image = "@AWESOME_ICON_PATH@/awesome16.png",
125 command = terminal .. " -e man awesome"})
127 -- Create a systray
128 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
130 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
131 -- We need one layoutbox per screen.
132 mylayoutbox = {}
133 for s = 1, screen.count() do
134 mylayoutbox[s] = widget({ type = "imagebox", name = "mylayoutbox", align = "right" })
135 mylayoutbox[s]:buttons({
136 button({ }, 1, function () awful.layout.inc(layouts, 1) end),
137 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
138 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
139 button({ }, 5, function () awful.layout.inc(layouts, -1) end)
141 mylayoutbox[s].image = image("@AWESOME_ICON_PATH@/layouts/tilew.png")
144 -- Create a wibox for each screen and add it
145 mywibox = {}
146 mypromptbox = {}
147 for s = 1, screen.count() do
148 mywibox[s] = wibox({ position = "top", name = "mywibox" .. s,
149 fg = beautiful.fg_normal, bg = beautiful.bg_normal })
150 mypromptbox[s] = widget({ type = "textbox", name = "mypromptbox" .. s, align = "left" })
151 -- Add widgets to the wibox - order matters
152 mywibox[s]:widgets({
153 mytaglist,
154 mytasklist,
155 mylauncher,
156 mypromptbox[s],
157 mytextbox,
158 mylayoutbox[s],
159 s == 1 and mysystray or nil
161 mywibox[s].screen = s
163 -- }}}
165 -- {{{ Mouse bindings
166 awesome.buttons({
167 button({ }, 3, function () awful.util.spawn(terminal) end),
168 button({ }, 4, awful.tag.viewnext),
169 button({ }, 5, awful.tag.viewprev)
171 -- }}}
173 -- {{{ Key bindings
175 -- Bind keyboard digits
176 -- Compute the maximum number of digit we need, limited to 9
177 keynumber = 0
178 for s = 1, screen.count() do
179 keynumber = math.min(9, math.max(#tags[s], keynumber));
182 for i = 1, keynumber do
183 keybinding({ modkey }, i,
184 function ()
185 local screen = mouse.screen
186 if tags[screen][i] then
187 awful.tag.viewonly(tags[screen][i])
189 end):add()
190 keybinding({ modkey, "Control" }, i,
191 function ()
192 local screen = mouse.screen
193 if tags[screen][i] then
194 tags[screen][i].selected = not tags[screen][i].selected
196 end):add()
197 keybinding({ modkey, "Shift" }, i,
198 function ()
199 if client.focus then
200 if tags[client.focus.screen][i] then
201 awful.client.movetotag(tags[client.focus.screen][i])
204 end):add()
205 keybinding({ modkey, "Control", "Shift" }, i,
206 function ()
207 if client.focus then
208 if tags[client.focus.screen][i] then
209 awful.client.toggletag(tags[client.focus.screen][i])
212 end):add()
215 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
216 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
217 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
219 -- Standard program
220 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
222 keybinding({ modkey, "Control" }, "r", function ()
223 mypromptbox[mouse.screen].text =
224 awful.util.escape(awful.util.restart())
225 end):add()
226 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
228 -- Client manipulation
229 keybinding({ modkey }, "m", awful.client.maximize):add()
230 keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
231 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
232 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
233 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
234 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
235 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
236 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
237 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
238 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
239 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
240 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
241 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
242 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
243 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
245 -- Layout manipulation
246 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
247 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
248 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
249 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
250 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
251 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
252 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
253 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
255 -- Prompt
256 keybinding({ modkey }, "F1", function ()
257 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
258 os.getenv("HOME") .. "/.cache/awesome/history") end):add()
259 keybinding({ modkey }, "F4", function ()
260 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
261 os.getenv("HOME") .. "/.cache/awesome/history_eval") end):add()
262 keybinding({ modkey, "Ctrl" }, "i", function ()
263 local s = mouse.screen
264 if mypromptbox[s].text then
265 mypromptbox[s].text = nil
266 else
267 mypromptbox[s].text = nil
268 if client.focus.class then
269 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
271 if client.focus.instance then
272 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
274 if client.focus.role then
275 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
278 end):add()
280 --- Tabulous, tab manipulation
281 keybinding({ modkey, "Control" }, "y", function ()
282 local tabbedview = tabulous.tabindex_get()
283 local nextclient = awful.client.next(1)
285 if not tabbedview then
286 tabbedview = tabulous.tabindex_get(nextclient)
288 if not tabbedview then
289 tabbedview = tabulous.tab_create()
290 tabulous.tab(tabbedview, nextclient)
291 else
292 tabulous.tab(tabbedview, client.focus)
294 else
295 tabulous.tab(tabbedview, nextclient)
297 end):add()
299 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
301 keybinding({ modkey }, "y", function ()
302 local tabbedview = tabulous.tabindex_get()
304 if tabbedview then
305 local n = tabulous.next(tabbedview)
306 tabulous.display(tabbedview, n)
308 end):add()
310 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
311 keybinding({ modkey }, "t", awful.client.togglemarked):add()
312 keybinding({ modkey, 'Shift' }, "t", function ()
313 local tabbedview = tabulous.tabindex_get()
314 local clients = awful.client.getmarked()
316 if not tabbedview then
317 tabbedview = tabulous.tab_create(clients[1])
318 table.remove(clients, 1)
321 for k,c in pairs(clients) do
322 tabulous.tab(tabbedview, c)
325 end):add()
327 for i = 1, keynumber do
328 keybinding({ modkey, "Shift" }, "F" .. i,
329 function ()
330 local screen = mouse.screen
331 if tags[screen][i] then
332 for k, c in pairs(awful.client.getmarked()) do
333 awful.client.movetotag(tags[screen][i], c)
336 end):add()
338 -- }}}
340 -- {{{ Hooks
341 -- Hook function to execute when focusing a client.
342 awful.hooks.focus.register(function (c)
343 if not awful.client.ismarked(c) then
344 c.border_color = beautiful.border_focus
346 end)
348 -- Hook function to execute when unfocusing a client.
349 awful.hooks.unfocus.register(function (c)
350 if not awful.client.ismarked(c) then
351 c.border_color = beautiful.border_normal
353 end)
355 -- Hook function to execute when marking a client
356 awful.hooks.marked.register(function (c)
357 c.border_color = beautiful.border_marked
358 end)
360 -- Hook function to execute when unmarking a client
361 awful.hooks.unmarked.register(function (c)
362 c.border_color = beautiful.border_focus
363 end)
365 -- Hook function to execute when the mouse is over a client.
366 awful.hooks.mouse_enter.register(function (c)
367 -- Sloppy focus, but disabled for magnifier layout
368 if awful.layout.get(c.screen) ~= "magnifier"
369 and awful.client.focus.filter(c) then
370 client.focus = c
372 end)
374 -- Hook function to execute when a new client appears.
375 awful.hooks.manage.register(function (c)
376 if use_titlebar then
377 -- Add a titlebar
378 awful.titlebar.add(c, { modkey = modkey })
380 -- Add mouse bindings
381 c:buttons({
382 button({ }, 1, function (c) client.focus = c; c:raise() end),
383 button({ modkey }, 1, function (c) c:mouse_move() end),
384 button({ modkey }, 3, function (c) c:mouse_resize() end)
386 -- New client may not receive focus
387 -- if they're not focusable, so set border anyway.
388 c.border_width = beautiful.border_width
389 c.border_color = beautiful.border_normal
390 client.focus = c
392 -- Check if the application should be floating.
393 local cls = c.class
394 local inst = c.instance
395 if floatapps[cls] then
396 c.floating = floatapps[cls]
397 elseif floatapps[inst] then
398 c.floating = floatapps[inst]
401 -- Check application->screen/tag mappings.
402 local target
403 if apptags[cls] then
404 target = apptags[cls]
405 elseif apptags[inst] then
406 target = apptags[inst]
408 if target then
409 c.screen = target.screen
410 awful.client.movetotag(tags[target.screen][target.tag], c)
413 -- Set the windows at the slave,
414 -- i.e. put it at the end of others instead of setting it master.
415 -- awful.client.setslave(c)
417 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
418 -- c.honorsizehints = false
419 end)
421 -- Hook function to execute when arranging the screen
422 -- (tag switch, new client, etc)
423 awful.hooks.arrange.register(function (screen)
424 local layout = awful.layout.get(screen)
425 if layout then
426 mylayoutbox[screen].image = image("@AWESOME_ICON_PATH@/layouts/" .. layout .. "w.png")
427 else
428 mylayoutbox[screen].image = nil
431 -- Give focus to the latest client in history if no window has focus
432 -- or if the current window is a desktop or a dock one.
433 if not client.focus then
434 local c = awful.client.focus.history.get(screen, 0)
435 if c then client.focus = c end
438 -- Uncomment if you want mouse warping
439 --[[
440 if client.focus then
441 local c_c = client.focus:coords()
442 local m_c = mouse.coords()
444 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
445 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
446 if table.maxn(m_c.buttons) == 0 then
447 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
452 end)
454 -- Hook called every second
455 awful.hooks.timer.register(1, function ()
456 -- For unix time_t lovers
457 mytextbox.text = " " .. os.time() .. " time_t "
458 -- Otherwise use:
459 -- mytextbox.text = " " .. os.date() .. " "
460 end)
461 -- }}}