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/?.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 8"
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 tags[s][tagnumber]:mwfact_set(0.618033988769)
68 tags[s][tagnumber]:add(s)
70 -- I'm sure you want to see at least one tag.
76 -- Create a taglist widget
77 mytaglist = widget.new({ type = "taglist", name = "mytaglist" })
78 mytaglist:mouse_add(mouse.new({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
79 mytaglist:mouse_add(mouse.new({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
80 mytaglist:mouse_add(mouse.new({}, 3, function (object, tag) tag:view(not tag:isselected()) end))
81 mytaglist:mouse_add(mouse.new({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
82 mytaglist:mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
83 mytaglist:mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
84 mytaglist:set("text_focus", "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> ")
86 -- Create a tasklist widget
87 mytasklist = widget.new({ type = "tasklist", name = "mytasklist" })
88 mytasklist:mouse_add(mouse.new({ }, 1, function (object, c) c:focus_set(); c:raise() end))
89 mytasklist:mouse_add(mouse.new({ }, 4, function () awful.client.focus(1) end))
90 mytasklist:mouse_add(mouse.new({ }, 5, function () awful.client.focus(-1) end))
91 mytasklist:set("text_focus", "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> ")
93 -- Create a textbox widget
94 mytextbox = widget.new({ type = "textbox", name = "mytextbox", align = "right" })
95 -- Set the default text in textbox
96 mytextbox:set("text", "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>")
97 mymenubox = widget.new({ type = "textbox", name = "mytextbox", align = "left" })
99 -- Create an iconbox widget
100 myiconbox = widget.new({ type = "iconbox", name = "myiconbox", align = "left" })
101 myiconbox:set("image", AWESOME_DATADIR .. "/awesome/icons/awesome16.png")
104 mysystray = widget.new({ type = "systray", name = "mysystray", align = "right" })
106 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
107 -- We need one layoutbox per screen.
109 for s = 1, screen.count() do
110 mylayoutbox[s] = widget.new({ type = "iconbox", name = "myiconbox", align = "right" })
111 mylayoutbox[s]:mouse_add(mouse.new({ }, 1, function () awful.layout.inc(layouts, 1) end))
112 mylayoutbox[s]:mouse_add(mouse.new({ }, 3, function () awful.layout.inc(layouts, -1) end))
113 mylayoutbox[s]:mouse_add(mouse.new({ }, 4, function () awful.layout.inc(layouts, 1) end))
114 mylayoutbox[s]:mouse_add(mouse.new({ }, 5, function () awful.layout.inc(layouts, -1) end))
115 mylayoutbox[s]:set("image", AWESOME_DATADIR .. "/awesome/icons/layouts/tilew.png")
118 -- Create a statusbar for each screen and add it
120 for s = 1, screen.count() do
121 mystatusbar[s] = statusbar.new({ position = "top", name = "mystatusbar" .. s,
122 fg = fg_normal, bg = bg_normal })
123 -- Add widgets to the statusbar - order matters
124 mystatusbar[s]:widget_add(mytaglist)
125 mystatusbar[s]:widget_add(myiconbox)
126 mystatusbar[s]:widget_add(mytasklist)
127 mystatusbar[s]:widget_add(mymenubox)
128 mystatusbar[s]:widget_add(mytextbox)
129 mystatusbar[s]:widget_add(mylayoutbox[s])
130 mystatusbar[s]:add(s)
132 mystatusbar[screen.count()]:widget_add(mysystray)
135 -- {{{ Mouse bindings
136 awesome.mouse_add(mouse.new({ }, 3, function () awful.spawn(terminal) end))
137 awesome.mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
138 awesome.mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
143 -- Bind keyboard digits
144 -- Compute the maximum number of digit we need, limited to 9
146 for s = 1, screen.count() do
147 keynumber = math.min(9, math.max(#tags[s], keynumber));
150 for i = 1, keynumber do
151 keybinding.new({ modkey }, i,
153 local screen = mouse.screen_get()
154 if tags[screen][i] then
155 awful.tag.viewonly(tags[screen][i])
158 keybinding.new({ modkey, "Control" }, i,
160 local screen = mouse.screen_get()
161 if tags[screen][i] then
162 tags[i]:view(not tags[screen][i]:isselected())
165 keybinding.new({ modkey, "Shift" }, i,
167 local screen = mouse.screen_get()
168 if tags[screen][i] then
169 awful.client.movetotag(tags[screen][i])
172 keybinding.new({ modkey, "Control", "Shift" }, i,
174 local screen = mouse.screen_get()
175 if tags[screen][i] then
176 awful.client.toggletag(tags[screen][i])
181 keybinding.new({ modkey }, "Left", awful.tag.viewprev):add()
182 keybinding.new({ modkey }, "Right", awful.tag.viewnext):add()
185 keybinding.new({ modkey }, "Return", function () awful.spawn(terminal) end):add()
187 keybinding.new({ modkey, "Control" }, "r", awesome.restart):add()
188 keybinding.new({ modkey, "Shift" }, "q", awesome.quit):add()
190 -- Client manipulation
191 keybinding.new({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
192 keybinding.new({ modkey }, "j", function () awful.client.focus(1); client.focus_get():raise() end):add()
193 keybinding.new({ modkey }, "k", function () awful.client.focus(-1); client.focus_get():raise() end):add()
194 keybinding.new({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
195 keybinding.new({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
196 keybinding.new({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
197 keybinding.new({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
198 keybinding.new({ modkey, "Control" }, "space", awful.client.togglefloating):add()
199 keybinding.new({ modkey }, "o", awful.client.movetoscreen):add()
201 -- Layout manipulation
202 keybinding.new({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
203 keybinding.new({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
204 keybinding.new({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
205 keybinding.new({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
206 keybinding.new({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
207 keybinding.new({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
208 keybinding.new({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
209 keybinding.new({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
212 keybinding.new({ modkey }, "F1", function () awful.menu("Run: ", mymenubox, awful.spawn) end):add()
213 keybinding.new({ modkey }, "F4", function () awful.menu("Run Lua code: ", mymenubox, awful.eval) end):add()
215 --- Tabulous, tab manipulation
216 keybinding.new({ modkey, "Control" }, "y", function ()
217 local tabbedview = tabulous.tabindex_get()
218 local nextclient = awful.client.next(1)
220 if tabbedview == nil then
221 tabbedview = tabulous.tabindex_get(nextclient)
223 if tabbedview == nil then
224 tabbedview = tabulous.tab_create()
225 tabulous.tab(tabbedview, nextclient)
227 tabulous.tab(tabbedview, client.focus_get())
230 tabulous.tab(tabbedview, nextclient)
234 keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add()
236 keybinding.new({ modkey }, "y", function ()
237 local tabbedview = tabulous.tabindex_get()
239 if tabbedview ~= nil then
240 local n = tabulous.next(tabbedview)
241 tabulous.display(tabbedview, n)
245 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
246 keybinding.new({ modkey }, "t", awful.client.togglemarked):add()
247 keybinding.new({ modkey, 'Shift' }, "t", function ()
248 local tabbedview = tabulous.tabindex_get()
249 local clients = awful.client.getmarked()
251 if tabbedview == nil then
252 tabbedview = tabulous.tab_create(clients[1])
253 table.remove(clients, 1)
256 for k,c in pairs(clients) do
257 tabulous.tab(tabbedview, c)
262 for i = 1, keynumber do
263 keybinding.new({ modkey, "Shift" }, "F" .. i,
265 local screen = mouse.screen_get()
266 if tags[screen][i] then
267 for k, c in pairs(awful.client.getmarked()) do
268 awful.client.movetotag(tags[screen][i], c)
276 -- Hook function to execute when focusing a client.
277 function hook_focus(c)
278 if not awful.client.ismarked(c) then
279 c:border_set({ width = border_width, color = border_focus })
283 -- Hook function to execute when unfocusing a client.
284 function hook_unfocus(c)
285 if not awful.client.ismarked(c) then
286 c:border_set({ width = border_width, color = border_normal })
290 -- Hook function to execute when marking a client
291 function hook_marked(c)
292 c:border_set({ width = border_width, color = border_marked })
295 -- Hook function to execute when unmarking a client
296 function hook_unmarked(c)
297 c:border_set({ width = border_width, color = border_focus })
300 -- Hook function to exeucte when the mouse is over a client.
301 function hook_mouseover(c)
302 -- Sloppy focus, but disabled for magnifier layout
303 if awful.layout.get(c:screen_get()) ~= "magnifier" then
308 -- Hook function to execute when a new client appears.
309 function hook_manage(c)
310 -- Add mouse bindings
311 c:mouse_add(mouse.new({ }, 1, function (c) c:focus_set(); c:raise() end))
312 c:mouse_add(mouse.new({ modkey }, 1, function (c) c:mouse_move() end))
313 c:mouse_add(mouse.new({ modkey }, 3, function (c) c:mouse_resize() end))
314 -- New client may not receive focus
315 -- if they're not focusable, so set border anyway.
316 c:border_set({ width = border_width, color = border_normal })
318 if c:name_get():lower():find("mplayer") then
323 -- Hook function to execute when arranging the screen
324 -- (tag switch, new client, etc)
325 function hook_arrange(screen)
326 local layout = awful.layout.get(screen)
327 mylayoutbox[screen]:set("image", AWESOME_DATADIR .. "/awesome/icons/layouts/" .. layout .. "w.png")
330 -- Hook called every second
331 function hook_timer ()
332 -- For unix time_t lovers
333 -- mytextbox:set("text", " " .. os.time() .. " time_t ")
335 mytextbox:set("text", " " .. os.date() .. " ")
339 awful.hooks.focus(hook_focus)
340 awful.hooks.unfocus(hook_unfocus)
341 awful.hooks.marked(hook_marked)
342 awful.hooks.unmarked(hook_unmarked)
343 awful.hooks.manage(hook_manage)
344 awful.hooks.mouseover(hook_mouseover)
345 awful.hooks.arrange(hook_arrange)
346 awful.hooks.timer(1, hook_timer)