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"
4 package.path = AWESOME_DATADIR .. "/awesome/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 -- Color & Appearance definitions, we use these later to display things
39 font = "RotisSansSerif 10"
44 border_normal = "#000000"
48 border_focus = bg_focus
49 border_marked = "#91231C"
51 awesome.font_set(font)
52 awesome.colors_set({ fg = fg_normal, bg = bg_normal })
53 awesome.resizehints_set(true)
60 for s = 1, screen.count() do
61 -- Each screen has its own tag table
63 -- Create 9 tags per screen
64 for tagnumber = 1, 9 do
65 tags[s][tagnumber] = tag.new({ name = tagnumber })
66 -- Add tags to screen one by one
67 -- split at 0.5/50% exactly
68 tags[s][tagnumber]:mwfact_set(0.5)
69 tags[s][tagnumber]:add(s)
71 -- I'm sure you want to see at least one tag.
77 -- Create a taglist widget
78 mytaglist = widget.new({ type = "taglist", name = "mytaglist" })
79 mytaglist:mouse_add(mouse.new({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
80 mytaglist:mouse_add(mouse.new({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
81 mytaglist:mouse_add(mouse.new({}, 3, function (object, tag) tag:view(not tag:isselected()) end))
82 mytaglist:mouse_add(mouse.new({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
83 mytaglist:mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
84 mytaglist:mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
85 mytaglist:set("text_focus", "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> ")
87 -- Create a tasklist widget
88 mytasklist = widget.new({ type = "tasklist", name = "mytasklist" })
89 mytasklist:mouse_add(mouse.new({ }, 1, function (object, c) c:focus_set(); c:raise() end))
90 mytasklist:mouse_add(mouse.new({ }, 4, function () awful.client.focus(1) end))
91 mytasklist:mouse_add(mouse.new({ }, 5, function () awful.client.focus(-1) end))
92 mytasklist:set("text_focus", "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> ")
94 -- Create a textbox widget
95 mytextbox = widget.new({ type = "textbox", name = "mytextbox", align = "right" })
96 -- Set the default text in textbox
97 mytextbox:set("text", "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>")
98 mymenubox = widget.new({ type = "textbox", name = "mymenubox", align = "left" })
101 mysystray = widget.new({ type = "systray", name = "mysystray", align = "right" })
103 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
104 -- We need one layoutbox per screen.
106 for s = 1, screen.count() do
107 mylayoutbox[s] = widget.new({ type = "iconbox", name = "mylayoutbox", align = "right" })
108 mylayoutbox[s]:mouse_add(mouse.new({ }, 1, function () awful.layout.inc(layouts, 1) end))
109 mylayoutbox[s]:mouse_add(mouse.new({ }, 3, function () awful.layout.inc(layouts, -1) end))
110 mylayoutbox[s]:mouse_add(mouse.new({ }, 4, function () awful.layout.inc(layouts, 1) end))
111 mylayoutbox[s]:mouse_add(mouse.new({ }, 5, function () awful.layout.inc(layouts, -1) end))
112 mylayoutbox[s]:set("image", AWESOME_DATADIR .. "/awesome/icons/layouts/tilew.png")
115 -- Create a statusbar for each screen and add it
117 for s = 1, screen.count() do
118 mystatusbar[s] = statusbar.new({ position = "top", name = "mystatusbar" .. s,
119 fg = fg_normal, bg = bg_normal })
120 -- Add widgets to the statusbar - order matters
121 -- #TODO order is not really taken into account
122 mystatusbar[s]:widget_add(mytaglist)
123 mystatusbar[s]:widget_add(mytasklist)
124 mystatusbar[s]:widget_add(mylayoutbox[s])
125 mystatusbar[s]:widget_add(mymenubox)
126 mystatusbar[s]:widget_add(mytextbox)
127 mystatusbar[s]:add(s)
129 mystatusbar[screen.count()]:widget_add(mysystray)
132 -- {{{ Mouse bindings
133 awesome.mouse_add(mouse.new({ }, 3, function () awful.spawn(terminal) end))
134 awesome.mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
135 awesome.mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
140 -- Bind keyboard digits
141 -- Compute the maximum number of digit we need, limited to 9
143 for s = 1, screen.count() do
144 keynumber = math.min(9, math.max(#tags[s], keynumber));
147 for i = 1, keynumber do
148 keybinding.new({ modkey }, i,
150 local screen = mouse.screen_get()
151 if tags[screen][i] then
152 awful.tag.viewonly(tags[screen][i])
155 keybinding.new({ modkey, "Control" }, i,
157 local screen = mouse.screen_get()
158 if tags[screen][i] then
159 tags[i]:view(not tags[screen][i]:isselected())
162 keybinding.new({ modkey, "Shift" }, i,
164 local screen = mouse.screen_get()
165 if tags[screen][i] then
166 awful.client.movetotag(tags[screen][i])
169 keybinding.new({ modkey, "Control", "Shift" }, i,
171 local screen = mouse.screen_get()
172 if tags[screen][i] then
173 awful.client.toggletag(tags[screen][i])
178 keybinding.new({ modkey }, "Left", awful.tag.viewprev):add()
179 keybinding.new({ modkey }, "Right", awful.tag.viewnext):add()
182 keybinding.new({ modkey }, "Return", function () awful.spawn(terminal) end):add()
184 keybinding.new({ modkey, "Control" }, "r", awesome.restart):add()
185 keybinding.new({ modkey, "Shift" }, "q", awesome.quit):add()
187 -- Client manipulation
188 keybinding.new({ modkey }, "Escape", function () client.focus_get():kill() end):add()
189 keybinding.new({ modkey }, "k", function () awful.client.focus(1); client.focus_get():raise() end):add()
190 keybinding.new({ modkey }, "j", function () awful.client.focus(-1); client.focus_get():raise() end):add()
191 keybinding.new({ modkey, "Shift" }, "k", function () awful.client.swap(1) end):add()
192 keybinding.new({ modkey, "Shift" }, "j", function () awful.client.swap(-1) end):add()
193 keybinding.new({ modkey, "Control" }, "k", function () awful.screen.focus(1) end):add()
194 keybinding.new({ modkey, "Control" }, "j", function () awful.screen.focus(-1) end):add()
195 keybinding.new({ modkey, "Control" }, "space", awful.client.togglefloating):add()
196 keybinding.new({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
197 keybinding.new({ modkey }, "o", awful.client.movetoscreen):add()
199 -- Layout manipulation
200 keybinding.new({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
201 keybinding.new({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
202 keybinding.new({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
203 keybinding.new({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
204 keybinding.new({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
205 keybinding.new({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
206 keybinding.new({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
207 keybinding.new({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
210 keybinding.new({ modkey }, "F1", function ()
211 awful.menu({ prompt = "Run: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mymenubox, awful.spawn)
213 keybinding.new({ modkey }, "F4", function ()
214 awful.menu({ prompt = "Run Lua code: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mymenubox, awful.eval)
217 --- Tabulous, tab manipulation
218 keybinding.new({ modkey, "Control" }, "y", function ()
219 local tabbedview = tabulous.tabindex_get()
220 local nextclient = awful.client.next(1)
222 if tabbedview == nil then
223 tabbedview = tabulous.tabindex_get(nextclient)
225 if tabbedview == nil then
226 tabbedview = tabulous.tab_create()
227 tabulous.tab(tabbedview, nextclient)
229 tabulous.tab(tabbedview, client.focus_get())
232 tabulous.tab(tabbedview, nextclient)
236 keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add()
238 keybinding.new({ modkey }, "y", function ()
239 local tabbedview = tabulous.tabindex_get()
241 if tabbedview ~= nil then
242 local n = tabulous.next(tabbedview)
243 tabulous.display(tabbedview, n)
247 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
248 keybinding.new({ modkey }, "t", awful.client.togglemarked):add()
249 keybinding.new({ modkey, 'Shift' }, "t", function ()
250 local tabbedview = tabulous.tabindex_get()
251 local clients = awful.client.getmarked()
253 if tabbedview == nil then
254 tabbedview = tabulous.tab_create(clients[1])
255 table.remove(clients, 1)
258 for k,c in pairs(clients) do
259 tabulous.tab(tabbedview, c)
264 for i = 1, keynumber do
265 keybinding.new({ modkey, "Shift" }, "F" .. i,
267 local screen = mouse.screen_get()
268 if tags[screen][i] then
269 for k, c in pairs(awful.client.getmarked()) do
270 awful.client.movetotag(tags[screen][i], c)
278 -- Hook function to execute when focusing a client.
279 function hook_focus(c)
280 if not awful.client.ismarked(c) then
281 c:border_set({ width = border_width, color = border_focus })
285 -- Hook function to execute when unfocusing a client.
286 function hook_unfocus(c)
287 if not awful.client.ismarked(c) then
288 c:border_set({ width = border_width, color = border_normal })
292 -- Hook function to execute when marking a client
293 function hook_marked(c)
294 c:border_set({ width = border_width, color = border_marked })
297 -- Hook function to execute when unmarking a client
298 function hook_unmarked(c)
299 c:border_set({ width = border_width, color = border_focus })
302 -- Hook function to exeucte when the mouse is over a client.
303 function hook_mouseover(c)
304 -- Sloppy focus, but disabled for magnifier layout
305 if awful.layout.get(c:screen_get()) ~= "magnifier" then
310 -- Hook function to execute when a new client appears.
311 function hook_manage(c)
312 -- Add mouse bindings
313 c:mouse_add(mouse.new({ }, 1, function (c) c:focus_set(); c:raise() end))
314 c:mouse_add(mouse.new({ modkey }, 1, function (c) c:mouse_move() end))
315 c:mouse_add(mouse.new({ modkey }, 3, function (c) c:mouse_resize() end))
316 -- New client may not receive focus
317 -- if they're not focusable, so set border anyway.
318 c:border_set({ width = border_width, color = border_normal })
320 if c:name_get():lower():find("mplayer") then
323 if c:name_get():find("pinentry") then
326 if c:name_get():lower():find("twinkle") then
329 if c:name_get():find("GIMP") then
334 -- Hook function to execute when arranging the screen
335 -- (tag switch, new client, etc)
336 function hook_arrange(screen)
337 local layout = awful.layout.get(screen)
338 mylayoutbox[screen]:set("image", AWESOME_DATADIR .. "/awesome/icons/layouts/" .. layout .. "w.png")
341 -- Hook called every second
342 function hook_timer ()
343 -- For unix time_t lovers
344 -- mytextbox:set("text", " " .. os.time() .. " time_t ")
346 mytextbox:set("text", " " .. os.date() .. " ")
350 awful.hooks.focus(hook_focus)
351 awful.hooks.unfocus(hook_unfocus)
352 awful.hooks.marked(hook_marked)
353 awful.hooks.unmarked(hook_unmarked)
354 awful.hooks.manage(hook_manage)
355 awful.hooks.mouseover(hook_mouseover)
356 awful.hooks.arrange(hook_arrange)
357 awful.hooks.timer(1, hook_timer)