]> git.madduck.net Git - etc/awesome.git/blob - .awesomerc.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

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.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

37317f4a1d9afa3749b41b9b459addef6c03e92b
[etc/awesome.git] / .awesomerc.lua
1 -- awesome 3 configuration file
2
3 AWESOME_DATADIR = "/home/madduck/code/awesome"
4 package.path = AWESOME_DATADIR .. "/lib/?.lua;" .. package.path
5
6 -- Include awesome library, with lots of useful function!
7 require("awful")
8 require("tabulous")
9
10 -- Uncomment this to activate autotabbing
11 -- tabulous.autotab_start()
12
13 -- {{{ Variable definitions
14 -- This is used later as the default terminal to run.
15 terminal = "x-terminal-emulator"
16
17 -- Default modkey.
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.
22 modkey = "Mod4"
23
24 -- Table of layouts to cover with awful.layout.inc, order matters.
25 layouts =
26 {
27     "tile",
28     "tileleft",
29     "tilebottom",
30     "tiletop",
31     "magnifier",
32     "max",
33     "spiral",
34     "dwindle",
35     "floating"
36 }
37
38 -- Table of clients that should be set floating
39 floatings =
40 {
41     ["mplayer"] = true,
42     ["pinentry"] = true,
43     ["GIMP"] = true,
44     ["twinkle"] = true,
45     ["Add-ons"] = true,
46     ["Play stream"] = true
47 }
48
49 -- Color & Appearance definitions, we use these later to display things
50 font = "RotisSansSerif 10"
51 border_width = 1
52
53 bg_normal = "#222222"
54 fg_normal = "#aaaaaa"
55 border_normal = "#000000"
56
57 bg_focus = "#535d6c"
58 fg_focus = "#ffffff"
59 border_focus = bg_focus
60 border_marked = "#91231C"
61
62 awesome.font_set(font)
63 awesome.colors_set({ fg = fg_normal, bg = bg_normal })
64
65 -- }}}
66
67 -- {{{ Tags
68 -- Define tags table
69 tags = {}
70 for s = 1, screen.count() do
71     -- Each screen has its own tag table
72     tags[s] = {}
73     -- Create 9 tags per screen
74     for tagnumber = 1, 9 do
75         tags[s][tagnumber] = tag({ 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 = 0.5
79         tags[s][tagnumber]:add(s)
80     end
81     -- I'm sure you want to see at least one tag.
82     tags[s][1].selected = true
83 end
84 -- }}}
85
86 -- {{{ Statusbar
87 -- Create a taglist widget
88 mytaglist = widget({ type = "taglist", name = "mytaglist" })
89 mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
90 mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
91 mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
92 mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
93 mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
94 mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
95 mytaglist.text_focus = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> "
96
97 -- Create a tasklist widget
98 mytasklist = widget({ type = "tasklist", name = "mytasklist" })
99 mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
100 mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focus(1) end))
101 mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focus(-1) end))
102 mytasklist.text_focus = "<bg color='"..bg_focus.."'/> <span color='"..fg_focus.."'><title/></span> "
103
104 -- Create a textbox widget
105 mytextbox = widget({ 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({ type = "textbox", name = "mypromptbox", align = "left" })
109
110 -- Create an iconbox widget
111 myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
112 myiconbox.text = "<bg image=\"/usr/local/share/awesome/icons/awesome16.png\" resize=\"true\"/>"
113
114 -- Create a systray
115 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
116
117 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
118 -- We need one layoutbox per screen.
119 mylayoutbox = {}
120 for s = 1, screen.count() do
121     mylayoutbox[s] = widget({ type = "textbox", name = "mylayoutbox", align = "right" })
122     mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
123     mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
124     mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
125     mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
126     mylayoutbox[s].text = "<bg image=\"/usr/local/share/awesome/icons/layouts/tilew.png\" resize=\"true\"/>"
127 end
128
129 -- Create a statusbar for each screen and add it
130 mystatusbar = {}
131 for s = 1, screen.count() do
132     mystatusbar[s] = statusbar({ position = "top", name = "mystatusbar" .. s,
133                                    fg = fg_normal, bg = bg_normal })
134     -- Add widgets to the statusbar - order matters
135     mystatusbar[s]:widget_add(mytaglist)
136     mystatusbar[s]:widget_add(mytasklist)
137     mystatusbar[s]:widget_add(mypromptbox)
138     mystatusbar[s]:widget_add(mytextbox)
139     mystatusbar[s]:widget_add(mylayoutbox[s])
140     mystatusbar[s]:add(s)
141 end
142 mystatusbar[screen.count()]:widget_add(mysystray)
143 -- }}}
144
145 -- {{{ Mouse bindings
146 awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
147 awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
148 awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
149 -- }}}
150
151 -- {{{ Key bindings
152
153 -- Bind keyboard digits
154 -- Compute the maximum number of digit we need, limited to 9
155 keynumber = 0
156 for s = 1, screen.count() do
157    keynumber = math.min(9, math.max(#tags[s], keynumber));
158 end
159
160 for i = 1, keynumber do
161     keybinding({ modkey }, i,
162                    function ()
163                        local screen = mouse.screen_get()
164                        if tags[screen][i] then
165                            awful.tag.viewonly(tags[screen][i])
166                        end
167                    end):add()
168     keybinding({ modkey, "Control" }, i,
169                    function ()
170                        local screen = mouse.screen_get()
171                        if tags[screen][i] then
172                            tags[screen][i].selected = not tags[screen][i].selected
173                        end
174                    end):add()
175     keybinding({ modkey, "Shift" }, i,
176                    function ()
177                        local screen = mouse.screen_get()
178                        if tags[screen][i] then
179                            awful.client.movetotag(tags[screen][i])
180                        end
181                    end):add()
182     keybinding({ modkey, "Control", "Shift" }, i,
183                    function ()
184                        local screen = mouse.screen_get()
185                        if tags[screen][i] then
186                            awful.client.toggletag(tags[screen][i])
187                        end
188                    end):add()
189 end
190
191 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
192 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
193
194 -- Standard program
195 keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
196
197 keybinding({ modkey, "Control" }, "r", awesome.restart):add()
198 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
199
200 -- Client manipulation
201 keybinding({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
202 keybinding({ modkey }, "j", function () awful.client.focus(1); client.focus_get():raise() end):add()
203 keybinding({ modkey }, "k", function () awful.client.focus(-1);  client.focus_get():raise() end):add()
204 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
205 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
206 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
207 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
208 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
209 keybinding({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
210 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
211
212 -- Layout manipulation
213 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
214 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
215 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
216 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
217 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
218 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
219 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
220 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
221
222 -- Prompt
223 keybinding({ modkey }, "F1", function ()
224                                      awful.prompt({ prompt = "Run: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.spawn, awful.completion.bash)
225                                  end):add()
226 keybinding({ modkey }, "F4", function ()
227                                      awful.prompt({ prompt = "Run Lua code: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.eval, awful.prompt.bash)
228                                  end):add()
229
230 --- Tabulous, tab manipulation
231 keybinding({ modkey, "Control" }, "y", function ()
232     local tabbedview = tabulous.tabindex_get()
233     local nextclient = awful.client.next(1)
234
235     if tabbedview == nil then
236         tabbedview = tabulous.tabindex_get(nextclient)
237
238         if tabbedview == nil then
239             tabbedview = tabulous.tab_create()
240             tabulous.tab(tabbedview, nextclient)
241         else
242             tabulous.tab(tabbedview, client.focus_get())
243         end
244     else
245         tabulous.tab(tabbedview, nextclient)
246     end
247 end):add()
248
249 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
250
251 keybinding({ modkey }, "y", function ()
252    local tabbedview = tabulous.tabindex_get()
253
254    if tabbedview ~= nil then
255        local n = tabulous.next(tabbedview)
256        tabulous.display(tabbedview, n)
257    end
258 end):add()
259
260 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
261 keybinding({ modkey }, "t", awful.client.togglemarked):add()
262 keybinding({ modkey, 'Shift' }, "t", function ()
263     local tabbedview = tabulous.tabindex_get()
264     local clients = awful.client.getmarked()
265
266     if tabbedview == nil then
267         tabbedview = tabulous.tab_create(clients[1])
268         table.remove(clients, 1)
269     end
270
271     for k,c in pairs(clients) do
272         tabulous.tab(tabbedview, c)
273     end
274
275 end):add()
276
277 for i = 1, keynumber do
278     keybinding({ modkey, "Shift" }, "F" .. i,
279                    function ()
280                        local screen = mouse.screen_get()
281                        if tags[screen][i] then
282                            for k, c in pairs(awful.client.getmarked()) do
283                                awful.client.movetotag(tags[screen][i], c)
284                            end
285                        end
286                    end):add()
287 end
288 -- }}}
289
290 -- {{{ Hooks
291 -- Hook function to execute when focusing a client.
292 function hook_focus(c)
293     if not awful.client.ismarked(c) then
294         c:border_set({ width = border_width, color = border_focus })
295     end
296 end
297
298 -- Hook function to execute when unfocusing a client.
299 function hook_unfocus(c)
300     if not awful.client.ismarked(c) then
301         c:border_set({ width = border_width, color = border_normal })
302     end
303 end
304
305 -- Hook function to execute when marking a client
306 function hook_marked(c)
307     c:border_set({ width = border_width, color = border_marked })
308 end
309
310 -- Hook function to execute when unmarking a client
311 function hook_unmarked(c)
312     c:border_set({ width = border_width, color = border_focus })
313 end
314
315 -- Hook function to execute when the mouse is over a client.
316 function hook_mouseover(c)
317     -- Sloppy focus, but disabled for magnifier layout
318     if awful.layout.get(c:screen_get()) ~= "magnifier" then
319         c:focus_set()
320     end
321 end
322
323 -- Hook function to execute when a new client appears.
324 function hook_manage(c)
325     -- Add mouse bindings
326     c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
327     c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
328     c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
329     -- New client may not receive focus
330     -- if they're not focusable, so set border anyway.
331     c:border_set({ width = border_width, color = border_normal })
332     c:focus_set()
333     if floatings[c:name_get():lower()] then
334         c:floating_set(true)
335     end
336     -- Honor size hints
337     c:honorsizehints_set(true)
338 end
339
340 -- Hook function to execute when arranging the screen
341 -- (tag switch, new client, etc)
342 function hook_arrange(screen)
343     local layout = awful.layout.get(screen)
344     mylayoutbox[screen].text = "<bg image=\"" .. AWESOME_DATADIR .. "/icons/layouts/" .. layout .. "w.png\" resize=\"true\"/>"
345
346     -- Uncomment if you want mouse warping
347     --[[
348     local sel = client.focus_get()
349     if sel then
350         local c_c = sel:coords_get()
351         local m_c = mouse.coords_get()
352
353         if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
354             m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
355             if table.maxn(m_c.buttons) == 0 then
356                 mouse.coords_set({ x = c_c.x + 5, y = c_c.y + 5})
357             end
358         end
359     end
360     ]]
361 end
362
363
364 -- Hook called every second
365 function hook_timer ()
366     -- For unix time_t lovers
367     -- mytextbox.text = " " .. os.time() .. " time_t "
368     -- Otherwise use:
369     mytextbox.text = " " .. os.date() .. " "
370 end
371
372 -- Set up some hooks
373 awful.hooks.focus(hook_focus)
374 awful.hooks.unfocus(hook_unfocus)
375 awful.hooks.marked(hook_marked)
376 awful.hooks.unmarked(hook_unmarked)
377 awful.hooks.manage(hook_manage)
378 awful.hooks.mouseover(hook_mouseover)
379 awful.hooks.arrange(hook_arrange)
380 awful.hooks.timer(1, hook_timer)
381 -- }}}
382
383 cmdmodkey = "Mod3"
384
385 -- xmms2 & sound
386 keybinding({ cmdmodkey }, "Prior", function () awful.spawn("amixer set Master 2+") end):add()
387 keybinding({ cmdmodkey }, "Next", function () awful.spawn("amixer set Master 2-") end):add()
388 keybinding({ cmdmodkey }, "Up", function () awful.spawn("amixer set PCM 2+") end):add()
389 keybinding({ cmdmodkey }, "Down", function () awful.spawn("amixer set PCM 2-") end):add()
390 keybinding({ cmdmodkey }, "Home", function () awful.spawn("amixer set Mic toggle") end):add()
391 keybinding({ cmdmodkey }, "End", function () awful.spawn("amixer set Master toggle") end):add()
392 keybinding({ cmdmodkey }, "Left", function () awful.spawn("xmms2 prev") end):add()
393 keybinding({ cmdmodkey }, "Right", function () awful.spawn("xmms2 next") end):add()
394 keybinding({ cmdmodkey }, "space", function () awful.spawn("xmms2 toggle") end):add()
395 keybinding({ cmdmodkey }, "backslash", function () awful.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
396 keybinding({ cmdmodkey, "Shift" }, "backslash", function () awful.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
397
398 -- misc apps
399 keybinding({ cmdmodkey }, "n", function () awful.spawn("sensible-browser") end):add()
400 keybinding({ cmdmodkey }, "m", function () awful.spawn(terminal .. " -e mutt -f =store") end):add()
401 keybinding({ cmdmodkey }, "t", function () awful.spawn(terminal) end):add()
402 keybinding({ cmdmodkey }, "c", function () awful.spawn(terminal .. " -e python") end):add()
403 keybinding({ cmdmodkey }, "r", function () awful.spawn("gmrun") end):add()
404 keybinding({ cmdmodkey }, "j", function () awful.spawn("jpilot") end):add()
405 keybinding({ cmdmodkey }, "x", function () awful.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
406 keybinding({ cmdmodkey, "Shift" }, "x", function () awful.spawn("xscreensaver-command -exit") end):add()