awful.client: do not export documentation of local functions
[awesome.git] / awesomerc.lua.in
blob6b85b5441e36c69ad11a570000b006655e9cbb5b
1 -- Standard awesome library
2 require("awful")
3 -- Theme handling library
4 require("beautiful")
5 -- Notification library
6 require("naughty")
8 -- {{{ Variable definitions
9 -- Themes define colours, icons, and wallpapers
10 -- The default is a dark theme
11 theme_path = "@AWESOME_THEMES_PATH@/default/theme"
12 -- Uncommment this for a lighter theme
13 -- theme_path = "@AWESOME_THEMES_PATH@/sky/theme"
15 -- Actually load theme
16 beautiful.init(theme_path)
18 -- This is used later as the default terminal and editor to run.
19 terminal = "xterm"
20 editor = os.getenv("EDITOR") or "nano"
21 editor_cmd = terminal .. " -e " .. editor
23 -- Default modkey.
24 -- Usually, Mod4 is the key with a logo between Control and Alt.
25 -- If you do not like this or do not have such a key,
26 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
27 -- However, you can use another modifier like Mod1, but it may interact with others.
28 modkey = "Mod4"
30 -- Table of layouts to cover with awful.layout.inc, order matters.
31 layouts =
33 awful.layout.suit.tile,
34 awful.layout.suit.tile.left,
35 awful.layout.suit.tile.bottom,
36 awful.layout.suit.tile.top,
37 awful.layout.suit.fair,
38 awful.layout.suit.fair.horizontal,
39 awful.layout.suit.max,
40 awful.layout.suit.max.fullscreen,
41 awful.layout.suit.magnifier,
42 awful.layout.suit.floating
45 -- Table of clients that should be set floating. The index may be either
46 -- the application class or instance. The instance is useful when running
47 -- a console app in a terminal like (Music on Console)
48 -- xterm -name mocp -e mocp
49 floatapps =
51 -- by class
52 ["MPlayer"] = true,
53 ["pinentry"] = true,
54 ["gimp"] = true,
55 -- by instance
56 ["mocp"] = true
59 -- Applications to be moved to a pre-defined tag by class or instance.
60 -- Use the screen and tags indices.
61 apptags =
63 -- ["Firefox"] = { screen = 1, tag = 2 },
64 -- ["mocp"] = { screen = 2, tag = 4 },
67 -- Define if we want to use titlebar on all applications.
68 use_titlebar = false
69 -- }}}
71 -- {{{ Tags
72 -- Define tags table.
73 tags = {}
74 for s = 1, screen.count() do
75 -- Each screen has its own tag table.
76 tags[s] = {}
77 -- Create 9 tags per screen.
78 for tagnumber = 1, 9 do
79 tags[s][tagnumber] = tag(tagnumber)
80 -- Add tags to screen one by one
81 tags[s][tagnumber].screen = s
82 end
83 -- I'm sure you want to see at least one tag.
84 tags[s][1].selected = true
85 end
86 -- }}}
88 -- {{{ Wibox
89 -- Create a textbox widget
90 mytextbox = widget({ type = "textbox", align = "right" })
91 -- Set the default text in textbox
92 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
94 -- Create a laucher widget and a main menu
95 myawesomemenu = {
96 { "manual", terminal .. " -e man awesome" },
97 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
98 { "restart", awesome.restart },
99 { "quit", awesome.quit }
102 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
103 { "open terminal", terminal }
107 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
108 menu = mymainmenu })
110 -- Create a systray
111 mysystray = widget({ type = "systray", align = "right" })
113 -- Create a wibox for each screen and add it
114 mywibox = {}
115 mypromptbox = {}
116 mylayoutbox = {}
117 mytaglist = {}
118 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
119 button({ modkey }, 1, awful.client.movetotag),
120 button({ }, 3, function (tag) tag.selected = not tag.selected end),
121 button({ modkey }, 3, awful.client.toggletag),
122 button({ }, 4, awful.tag.viewnext),
123 button({ }, 5, awful.tag.viewprev) }
124 mytasklist = {}
125 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
126 button({ }, 3, function () awful.menu.clients({ width=250 }) end),
127 button({ }, 4, function () awful.client.focus.byidx(1) end),
128 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
130 for s = 1, screen.count() do
131 -- Create a promptbox for each screen
132 mypromptbox[s] = widget({ type = "textbox", align = "left" })
133 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
134 -- We need one layoutbox per screen.
135 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
136 mylayoutbox[s]:buttons({ 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) })
140 -- Create a taglist widget
141 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
143 -- Create a tasklist widget
144 mytasklist[s] = awful.widget.tasklist.new(function(c)
145 return awful.widget.tasklist.label.currenttags(c, s)
146 end, mytasklist.buttons)
148 -- Create the wibox
149 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
150 -- Add widgets to the wibox - order matters
151 mywibox[s].widgets = { mylauncher,
152 mytaglist[s],
153 mytasklist[s],
154 mypromptbox[s],
155 mytextbox,
156 mylayoutbox[s],
157 s == 1 and mysystray or nil }
158 mywibox[s].screen = s
160 -- }}}
162 -- {{{ Mouse bindings
163 root.buttons({
164 button({ }, 3, function () mymainmenu:toggle() end),
165 button({ }, 4, awful.tag.viewnext),
166 button({ }, 5, awful.tag.viewprev)
168 -- }}}
170 -- {{{ Key bindings
171 -- Bind keyboard digits
172 -- Compute the maximum number of digit we need, limited to 9
173 keynumber = 0
174 for s = 1, screen.count() do
175 keynumber = math.min(9, math.max(#tags[s], keynumber));
178 globalkeys = {}
179 clientkeys = {}
181 for i = 1, keynumber do
182 table.insert(globalkeys,
183 key({ modkey }, i,
184 function ()
185 local screen = mouse.screen
186 if tags[screen][i] then
187 awful.tag.viewonly(tags[screen][i])
189 end))
190 table.insert(globalkeys,
191 key({ modkey, "Control" }, i,
192 function ()
193 local screen = mouse.screen
194 if tags[screen][i] then
195 tags[screen][i].selected = not tags[screen][i].selected
197 end))
198 table.insert(globalkeys,
199 key({ modkey, "Shift" }, i,
200 function ()
201 if client.focus and tags[client.focus.screen][i] then
202 awful.client.movetotag(tags[client.focus.screen][i])
204 end))
205 table.insert(globalkeys,
206 key({ modkey, "Control", "Shift" }, i,
207 function ()
208 if client.focus and tags[client.focus.screen][i] then
209 awful.client.toggletag(tags[client.focus.screen][i])
211 end))
214 table.insert(globalkeys, key({ modkey }, "Left", awful.tag.viewprev))
215 table.insert(globalkeys, key({ modkey }, "Right", awful.tag.viewnext))
216 table.insert(globalkeys, key({ modkey }, "Escape", awful.tag.history.restore))
218 table.insert(globalkeys, key({ modkey }, "j", function () awful.client.focus.byidx(1); if client.focus then client.focus:raise() end end))
219 table.insert(globalkeys, key({ modkey }, "k", function () awful.client.focus.byidx(-1); if client.focus then client.focus:raise() end end))
220 table.insert(globalkeys, key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(1) end))
221 table.insert(globalkeys, key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx(-1) end))
223 table.insert(globalkeys, key({ modkey, "Control" }, "j", function () awful.screen.focus(1) end))
224 table.insert(globalkeys, key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end))
226 table.insert(globalkeys, key({ modkey }, "Tab", function () awful.client.focus.history.previous(); if client.focus then client.focus:raise() end end))
228 table.insert(globalkeys, key({ modkey }, "u", awful.client.urgent.jumpto))
230 -- Standard program
231 table.insert(globalkeys, key({ modkey }, "Return", function () awful.util.spawn(terminal) end))
233 table.insert(globalkeys, key({ modkey, "Control" }, "r", function ()
234 mypromptbox[mouse.screen].text =
235 awful.util.escape(awful.util.restart())
236 end))
237 table.insert(globalkeys, key({ modkey, "Shift" }, "q", awesome.quit))
239 -- Client manipulation
240 table.insert(clientkeys, key({ modkey }, "m", function (c) c.maximized_horizontal = not c.maximized_horizontal
241 c.maximized_vertical = not c.maximized_vertical end))
242 table.insert(clientkeys, key({ modkey }, "f", function (c) c.fullscreen = not c.fullscreen end))
243 table.insert(clientkeys, key({ modkey, "Shift" }, "c", function (c) c:kill() end))
244 table.insert(clientkeys, key({ modkey, "Control" }, "space", awful.client.floating.toggle))
245 table.insert(clientkeys, key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end))
246 table.insert(clientkeys, key({ modkey }, "o", awful.client.movetoscreen))
247 table.insert(clientkeys, key({ modkey, "Shift" }, "r", function (c) c:redraw() end))
248 table.insert(clientkeys, key({ modkey, "Ctrl" }, "i", function (c)
249 local s = c.screen
250 if mypromptbox[s].text then
251 mypromptbox[s].text = nil
252 else
253 mypromptbox[s].text = nil
254 if c.class then
255 mypromptbox[s].text = "Class: " .. c.class .. " "
257 if c.instance then
258 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. c.instance .. " "
260 if c.role then
261 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. crole
264 end))
266 -- Layout manipulation
267 table.insert(globalkeys, key({ modkey }, "l", function () awful.tag.incmwfact(0.05) end))
268 table.insert(globalkeys, key({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end))
269 table.insert(globalkeys, key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end))
270 table.insert(globalkeys, key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end))
271 table.insert(globalkeys, key({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end))
272 table.insert(globalkeys, key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end))
273 table.insert(globalkeys, key({ modkey }, "space", function () awful.layout.inc(layouts, 1) end))
274 table.insert(globalkeys, key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end))
276 -- Prompt
277 table.insert(globalkeys, key({ modkey }, "F1", function ()
278 awful.prompt.run({ prompt = "Run: " },
279 mypromptbox[mouse.screen],
280 awful.util.spawn, awful.completion.bash,
281 awful.util.getdir("cache") .. "/history")
282 end))
283 table.insert(globalkeys, key({ modkey }, "F4", function ()
284 awful.prompt.run({ prompt = "Run Lua code: " },
285 mypromptbox[mouse.screen],
286 awful.util.eval, awful.prompt.bash,
287 awful.util.getdir("cache") .. "/history_eval")
288 end))
290 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
291 table.insert(clientkeys, key({ modkey }, "t", awful.client.togglemarked))
293 for i = 1, keynumber do
294 table.insert(globalkeys, key({ modkey, "Shift" }, "F" .. i,
295 function ()
296 local screen = mouse.screen
297 if tags[screen][i] then
298 for k, c in pairs(awful.client.getmarked()) do
299 awful.client.movetotag(tags[screen][i], c)
302 end))
305 -- Set keys
306 root.keys(globalkeys)
307 -- }}}
309 -- {{{ Hooks
310 -- Hook function to execute when focusing a client.
311 awful.hooks.focus.register(function (c)
312 if not awful.client.ismarked(c) then
313 c.border_color = beautiful.border_focus
315 end)
317 -- Hook function to execute when unfocusing a client.
318 awful.hooks.unfocus.register(function (c)
319 if not awful.client.ismarked(c) then
320 c.border_color = beautiful.border_normal
322 end)
324 -- Hook function to execute when marking a client
325 awful.hooks.marked.register(function (c)
326 c.border_color = beautiful.border_marked
327 end)
329 -- Hook function to execute when unmarking a client.
330 awful.hooks.unmarked.register(function (c)
331 c.border_color = beautiful.border_focus
332 end)
334 -- Hook function to execute when the mouse enters a client.
335 awful.hooks.mouse_enter.register(function (c)
336 -- Sloppy focus, but disabled for magnifier layout
337 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
338 and awful.client.focus.filter(c) then
339 client.focus = c
341 end)
343 -- Hook function to execute when a new client appears.
344 awful.hooks.manage.register(function (c, startup)
345 -- If we are not managing this application at startup,
346 -- move it to the screen where the mouse is.
347 -- We only do it for filtered windows (i.e. no dock, etc).
348 if not startup and awful.client.focus.filter(c) then
349 c.screen = mouse.screen
352 if use_titlebar then
353 -- Add a titlebar
354 awful.titlebar.add(c, { modkey = modkey })
356 -- Add mouse bindings
357 c:buttons({
358 button({ }, 1, function (c) client.focus = c; c:raise() end),
359 button({ modkey }, 1, awful.mouse.client.move),
360 button({ modkey }, 3, awful.mouse.client.resize)
362 -- New client may not receive focus
363 -- if they're not focusable, so set border anyway.
364 c.border_width = beautiful.border_width
365 c.border_color = beautiful.border_normal
367 -- Check if the application should be floating.
368 local cls = c.class
369 local inst = c.instance
370 if floatapps[cls] then
371 awful.client.floating.set(c, floatapps[cls])
372 elseif floatapps[inst] then
373 awful.client.floating.set(c, floatapps[inst])
376 -- Check application->screen/tag mappings.
377 local target
378 if apptags[cls] then
379 target = apptags[cls]
380 elseif apptags[inst] then
381 target = apptags[inst]
383 if target then
384 c.screen = target.screen
385 awful.client.movetotag(tags[target.screen][target.tag], c)
388 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
389 client.focus = c
391 -- Set key bindings
392 c:keys(clientkeys)
394 -- Set the windows at the slave,
395 -- i.e. put it at the end of others instead of setting it master.
396 -- awful.client.setslave(c)
398 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
399 -- c.size_hints_honor = false
400 end)
402 -- Hook function to execute when arranging the screen.
403 -- (tag switch, new client, etc)
404 awful.hooks.arrange.register(function (screen)
405 local layout = awful.layout.getname(awful.layout.get(screen))
406 if layout and beautiful["layout_" ..layout] then
407 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
408 else
409 mylayoutbox[screen].image = nil
412 -- Give focus to the latest client in history if no window has focus
413 -- or if the current window is a desktop or a dock one.
414 if not client.focus then
415 local c = awful.client.focus.history.get(screen, 0)
416 if c then client.focus = c end
419 -- Uncomment if you want mouse warping
420 --[[
421 if client.focus then
422 local c_c = client.focus:geometry()
423 local m_c = mouse.coords()
425 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
426 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
427 if table.maxn(m_c.buttons) == 0 then
428 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
433 end)
435 -- Hook called every second
436 awful.hooks.timer.register(1, function ()
437 -- For unix time_t lovers
438 mytextbox.text = " " .. os.time() .. " time_t "
439 -- Otherwise use:
440 -- mytextbox.text = " " .. os.date() .. " "
441 end)
442 -- }}}