All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 -- awesome 3 configuration file
3 AWESOME_DATADIR = "/home/madduck/code/awesome"
4 package.path = AWESOME_DATADIR .. "/lib/?.lua;" .. package.path
6 -- Include awesome library, with lots of useful function!
10 -- Uncomment this to activate autotabbing
11 -- tabulous.autotab_start()
13 -- {{{ Variable definitions
14 -- This is used later as the default terminal to run.
15 terminal = "x-terminal-emulator"
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.
24 -- Table of layouts to cover with awful.layout.inc, order matters.
38 -- Table of clients that should be set floating
46 ["Play stream"] = true
49 -- Color & Appearance definitions, we use these later to display things
50 font = "RotisSansSerif 10"
55 border_normal = "#000000"
59 border_focus = bg_focus
60 border_marked = "#91231C"
62 awesome.font_set(font)
63 awesome.colors_set({ fg = fg_normal, bg = bg_normal })
70 for s = 1, screen.count() do
71 -- Each screen has its own tag table
73 -- Create 9 tags per screen
74 for tagnumber = 1, 9 do
75 tags[s][tagnumber] = tag.new({ name = tagnumber, layout = layouts[1] })
76 -- Add tags to screen one by one
77 -- split at 0.5/50% exactly
78 tags[s][tagnumber]:mwfact_set(0.5)
79 tags[s][tagnumber]:add(s)
81 -- I'm sure you want to see at least one tag.
87 -- Create a taglist widget
88 mytaglist = widget.new({ type = "taglist", name = "mytaglist" })
89 mytaglist:mouse_add(mouse.new({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
90 mytaglist:mouse_add(mouse.new({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
91 mytaglist:mouse_add(mouse.new({}, 3, function (object, tag) tag:view(not tag:isselected()) end))
92 mytaglist:mouse_add(mouse.new({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
93 mytaglist:mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
94 mytaglist:mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
95 mytaglist.text_focus = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> "
97 -- Create a tasklist widget
98 mytasklist = widget.new({ type = "tasklist", name = "mytasklist" })
99 mytasklist:mouse_add(mouse.new({ }, 1, function (object, c) c:focus_set(); c:raise() end))
100 mytasklist:mouse_add(mouse.new({ }, 4, function () awful.client.focus(1) end))
101 mytasklist:mouse_add(mouse.new({ }, 5, function () awful.client.focus(-1) end))
102 mytasklist.text_focus = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> "
104 -- Create a textbox widget
105 mytextbox = widget.new({ type = "textbox", name = "mytextbox", align = "right" })
106 -- Set the default text in textbox
107 mytextbox.text = "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>"
108 mypromptbox = widget.new({ type = "textbox", name = "mypromptbox", align = "left" })
111 mysystray = widget.new({ type = "systray", name = "mysystray", align = "right" })
113 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
114 -- We need one layoutbox per screen.
116 for s = 1, screen.count() do
117 mylayoutbox[s] = widget.new({ type = "textbox", name = "mylayoutbox", align = "right" })
118 mylayoutbox[s]:mouse_add(mouse.new({ }, 1, function () awful.layout.inc(layouts, 1) end))
119 mylayoutbox[s]:mouse_add(mouse.new({ }, 3, function () awful.layout.inc(layouts, -1) end))
120 mylayoutbox[s]:mouse_add(mouse.new({ }, 4, function () awful.layout.inc(layouts, 1) end))
121 mylayoutbox[s]:mouse_add(mouse.new({ }, 5, function () awful.layout.inc(layouts, -1) end))
122 mylayoutbox[s].text = "<bg image=\"" .. AWESOME_DATADIR .. "/icons/layouts/tilew.png\" resize=\"true\"/>"
125 -- Create a statusbar for each screen and add it
127 for s = 1, screen.count() do
128 mystatusbar[s] = statusbar.new({ position = "top", name = "mystatusbar" .. s,
129 fg = fg_normal, bg = bg_normal })
130 -- Add widgets to the statusbar - order matters
131 mystatusbar[s]:widget_add(mytaglist)
132 mystatusbar[s]:widget_add(mytasklist)
133 mystatusbar[s]:widget_add(mypromptbox)
134 mystatusbar[s]:widget_add(mytextbox)
135 mystatusbar[s]:widget_add(mylayoutbox[s])
136 mystatusbar[s]:add(s)
138 mystatusbar[screen.count()]:widget_add(mysystray)
141 -- {{{ Mouse bindings
142 awesome.mouse_add(mouse.new({ }, 3, function () awful.spawn(terminal) end))
143 awesome.mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
144 awesome.mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
149 -- Bind keyboard digits
150 -- Compute the maximum number of digit we need, limited to 9
152 for s = 1, screen.count() do
153 keynumber = math.min(9, math.max(#tags[s], keynumber));
156 for i = 1, keynumber do
157 keybinding.new({ modkey }, i,
159 local screen = mouse.screen_get()
160 if tags[screen][i] then
161 awful.tag.viewonly(tags[screen][i])
164 keybinding.new({ modkey, "Control" }, i,
166 local screen = mouse.screen_get()
167 if tags[screen][i] then
168 tags[i]:view(not tags[screen][i]:isselected())
171 keybinding.new({ modkey, "Shift" }, i,
173 local screen = mouse.screen_get()
174 if tags[screen][i] then
175 awful.client.movetotag(tags[screen][i])
178 keybinding.new({ modkey, "Control", "Shift" }, i,
180 local screen = mouse.screen_get()
181 if tags[screen][i] then
182 awful.client.toggletag(tags[screen][i])
187 keybinding.new({ modkey }, "Left", awful.tag.viewprev):add()
188 keybinding.new({ modkey }, "Right", awful.tag.viewnext):add()
191 keybinding.new({ modkey }, "Return", function () awful.spawn(terminal) end):add()
193 keybinding.new({ modkey, "Control" }, "r", awesome.restart):add()
194 keybinding.new({ modkey, "Shift" }, "q", awesome.quit):add()
196 -- Client manipulation
197 keybinding.new({ modkey, "Shift" }, "Escape", function () client.focus_get():kill() end):add()
198 keybinding.new({ modkey }, "k", function () awful.client.focus(1); client.focus_get():raise() end):add()
199 keybinding.new({ modkey }, "j", function () awful.client.focus(-1); client.focus_get():raise() end):add()
200 keybinding.new({ modkey, "Shift" }, "k", function () awful.client.swap(1) end):add()
201 keybinding.new({ modkey, "Shift" }, "j", function () awful.client.swap(-1) end):add()
202 keybinding.new({ modkey, "Control" }, "k", function () awful.screen.focus(1) end):add()
203 keybinding.new({ modkey, "Control" }, "j", function () awful.screen.focus(-1) end):add()
204 keybinding.new({ modkey, "Control" }, "space", awful.client.togglefloating):add()
205 keybinding.new({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
206 keybinding.new({ modkey }, "o", awful.client.movetoscreen):add()
208 -- Layout manipulation
209 keybinding.new({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
210 keybinding.new({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
211 keybinding.new({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
212 keybinding.new({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
213 keybinding.new({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
214 keybinding.new({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
215 keybinding.new({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
216 keybinding.new({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
219 keybinding.new({ modkey }, "F1", function ()
220 awful.prompt({ prompt = "Run: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.spawn, awful.completion.bash)
222 keybinding.new({ modkey }, "F4", function ()
223 awful.prompt({ prompt = "Run Lua code: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.eval, awful.prompt.bash)
226 --- Tabulous, tab manipulation
227 keybinding.new({ modkey, "Control" }, "y", function ()
228 local tabbedview = tabulous.tabindex_get()
229 local nextclient = awful.client.next(1)
231 if tabbedview == nil then
232 tabbedview = tabulous.tabindex_get(nextclient)
234 if tabbedview == nil then
235 tabbedview = tabulous.tab_create()
236 tabulous.tab(tabbedview, nextclient)
238 tabulous.tab(tabbedview, client.focus_get())
241 tabulous.tab(tabbedview, nextclient)
245 keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add()
247 keybinding.new({ modkey }, "y", function ()
248 local tabbedview = tabulous.tabindex_get()
250 if tabbedview ~= nil then
251 local n = tabulous.next(tabbedview)
252 tabulous.display(tabbedview, n)
256 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
257 keybinding.new({ modkey }, "t", awful.client.togglemarked):add()
258 keybinding.new({ modkey, 'Shift' }, "t", function ()
259 local tabbedview = tabulous.tabindex_get()
260 local clients = awful.client.getmarked()
262 if tabbedview == nil then
263 tabbedview = tabulous.tab_create(clients[1])
264 table.remove(clients, 1)
267 for k,c in pairs(clients) do
268 tabulous.tab(tabbedview, c)
273 for i = 1, keynumber do
274 keybinding.new({ modkey, "Shift" }, "F" .. i,
276 local screen = mouse.screen_get()
277 if tags[screen][i] then
278 for k, c in pairs(awful.client.getmarked()) do
279 awful.client.movetotag(tags[screen][i], c)
287 -- Hook function to execute when focusing a client.
288 function hook_focus(c)
289 if not awful.client.ismarked(c) then
290 c:border_set({ width = border_width, color = border_focus })
294 -- Hook function to execute when unfocusing a client.
295 function hook_unfocus(c)
296 if not awful.client.ismarked(c) then
297 c:border_set({ width = border_width, color = border_normal })
301 -- Hook function to execute when marking a client
302 function hook_marked(c)
303 c:border_set({ width = border_width, color = border_marked })
306 -- Hook function to execute when unmarking a client
307 function hook_unmarked(c)
308 c:border_set({ width = border_width, color = border_focus })
311 -- Hook function to execute when the mouse is over a client.
312 function hook_mouseover(c)
313 -- Sloppy focus, but disabled for magnifier layout
314 if awful.layout.get(c:screen_get()) ~= "magnifier" then
319 -- Hook function to execute when a new client appears.
320 function hook_manage(c)
321 -- Add mouse bindings
322 c:mouse_add(mouse.new({ }, 1, function (c) c:focus_set(); c:raise() end))
323 c:mouse_add(mouse.new({ modkey }, 1, function (c) c:mouse_move() end))
324 c:mouse_add(mouse.new({ modkey }, 3, function (c) c:mouse_resize() end))
325 -- New client may not receive focus
326 -- if they're not focusable, so set border anyway.
327 c:border_set({ width = border_width, color = border_normal })
329 if floatings[c:name_get():lower()] then
333 c:honorsizehints_set(true)
336 -- Hook function to execute when arranging the screen
337 -- (tag switch, new client, etc)
338 function hook_arrange(screen)
339 local layout = awful.layout.get(screen)
340 mylayoutbox[screen].text = "<bg image=\"" .. AWESOME_DATADIR .. "/icons/layouts/" .. layout .. "w.png\" resize=\"true\"/>"
342 -- Uncomment if you want mouse warping
344 local sel = client.focus_get()
346 local c_c = sel:coords_get()
347 local m_c = mouse.coords_get()
349 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
350 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
351 if table.maxn(m_c.buttons) == 0 then
352 mouse.coords_set(c_c.x + 5, c_c.y + 5)
360 -- Hook called every second
361 function hook_timer ()
362 -- For unix time_t lovers
363 -- mytextbox.text = " " .. os.time() .. " time_t "
365 mytextbox.text = " " .. os.date() .. " "
369 awful.hooks.focus(hook_focus)
370 awful.hooks.unfocus(hook_unfocus)
371 awful.hooks.marked(hook_marked)
372 awful.hooks.unmarked(hook_unmarked)
373 awful.hooks.manage(hook_manage)
374 awful.hooks.mouseover(hook_mouseover)
375 awful.hooks.arrange(hook_arrange)
376 awful.hooks.timer(1, hook_timer)
382 keybinding.new({ cmdmodkey }, "Prior", function () awful.spawn("amixer set Master 2+") end):add()
383 keybinding.new({ cmdmodkey }, "Next", function () awful.spawn("amixer set Master 2-") end):add()
384 keybinding.new({ cmdmodkey }, "Up", function () awful.spawn("amixer set PCM 2+") end):add()
385 keybinding.new({ cmdmodkey }, "Down", function () awful.spawn("amixer set PCM 2-") end):add()
386 keybinding.new({ cmdmodkey }, "Home", function () awful.spawn("amixer set Mic toggle") end):add()
387 keybinding.new({ cmdmodkey }, "End", function () awful.spawn("amixer set Master toggle") end):add()
388 keybinding.new({ cmdmodkey }, "Left", function () awful.spawn("xmms2 prev") end):add()
389 keybinding.new({ cmdmodkey }, "Right", function () awful.spawn("xmms2 next") end):add()
390 keybinding.new({ cmdmodkey }, "space", function () awful.spawn("xmms2 toggle") end):add()
391 keybinding.new({ cmdmodkey }, "backslash", function () awful.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
392 keybinding.new({ cmdmodkey, "Shift" }, "backslash", function () awful.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
395 keybinding.new({ cmdmodkey }, "n", function () awful.spawn("sensible-browser") end):add()
396 keybinding.new({ cmdmodkey }, "m", function () awful.spawn(terminal .. " -e mutt -f =store") end):add()
397 keybinding.new({ cmdmodkey }, "t", function () awful.spawn(terminal) end):add()
398 keybinding.new({ cmdmodkey }, "c", function () awful.spawn(terminal .. " -e python") end):add()
399 keybinding.new({ cmdmodkey }, "r", function () awful.spawn("gmrun") end):add()
400 keybinding.new({ cmdmodkey }, "j", function () awful.spawn("jpilot") end):add()
401 keybinding.new({ cmdmodkey }, "x", function () awful.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
402 keybinding.new({ cmdmodkey, "Shift" }, "x", function () awful.spawn("xscreensaver-command -exit") end):add()