]> 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:

more xmms2 stuff
[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.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)
80     end
81     -- I'm sure you want to see at least one tag.
82     tags[s][1]:view(true)
83 end
84 -- }}}
85
86 -- {{{ Statusbar
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> "
96
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> "
103
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" })
109
110 -- Create an iconbox widget
111 myiconbox = widget.new({ type = "textbox", name = "myiconbox", align = "left" })
112 myiconbox.text = "<bg image=\"" .. AWESOME_DATADIR .. "/icons/awesome16.png\" resize=\"true\"/>"
113
114 -- Create a systray
115 mysystray = widget.new({ 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.new({ type = "textbox", name = "mylayoutbox", align = "right" })
122     mylayoutbox[s]:mouse_add(mouse.new({ }, 1, function () awful.layout.inc(layouts, 1) end))
123     mylayoutbox[s]:mouse_add(mouse.new({ }, 3, function () awful.layout.inc(layouts, -1) end))
124     mylayoutbox[s]:mouse_add(mouse.new({ }, 4, function () awful.layout.inc(layouts, 1) end))
125     mylayoutbox[s]:mouse_add(mouse.new({ }, 5, function () awful.layout.inc(layouts, -1) end))
126     mylayoutbox[s].text = "<bg image=\"" .. AWESOME_DATADIR .. "/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.new({ 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(myiconbox)
137     mystatusbar[s]:widget_add(mytasklist)
138     mystatusbar[s]:widget_add(mypromptbox)
139     mystatusbar[s]:widget_add(mytextbox)
140     mystatusbar[s]:widget_add(mylayoutbox[s])
141     mystatusbar[s]:add(s)
142 end
143 mystatusbar[screen.count()]:widget_add(mysystray)
144 -- }}}
145
146 -- {{{ Mouse bindings
147 awesome.mouse_add(mouse.new({ }, 3, function () awful.spawn(terminal) end))
148 awesome.mouse_add(mouse.new({ }, 4, awful.tag.viewnext))
149 awesome.mouse_add(mouse.new({ }, 5, awful.tag.viewprev))
150 -- }}}
151
152 -- {{{ Key bindings
153
154 -- Bind keyboard digits
155 -- Compute the maximum number of digit we need, limited to 9
156 keynumber = 0
157 for s = 1, screen.count() do
158    keynumber = math.min(9, math.max(#tags[s], keynumber));
159 end
160
161 for i = 1, keynumber do
162     keybinding.new({ modkey }, i,
163                    function ()
164                        local screen = mouse.screen_get()
165                        if tags[screen][i] then
166                            awful.tag.viewonly(tags[screen][i])
167                        end
168                    end):add()
169     keybinding.new({ modkey, "Control" }, i,
170                    function ()
171                        local screen = mouse.screen_get()
172                        if tags[screen][i] then
173                            tags[i]:view(not tags[screen][i]:isselected())
174                        end
175                    end):add()
176     keybinding.new({ modkey, "Shift" }, i,
177                    function ()
178                        local screen = mouse.screen_get()
179                        if tags[screen][i] then
180                            awful.client.movetotag(tags[screen][i])
181                        end
182                    end):add()
183     keybinding.new({ modkey, "Control", "Shift" }, i,
184                    function ()
185                        local screen = mouse.screen_get()
186                        if tags[screen][i] then
187                            awful.client.toggletag(tags[screen][i])
188                        end
189                    end):add()
190 end
191
192 keybinding.new({ modkey }, "Left", awful.tag.viewprev):add()
193 keybinding.new({ modkey }, "Right", awful.tag.viewnext):add()
194
195 -- Standard program
196 keybinding.new({ modkey }, "Return", function () awful.spawn(terminal) end):add()
197
198 keybinding.new({ modkey, "Control" }, "r", awesome.restart):add()
199 keybinding.new({ modkey, "Shift" }, "q", awesome.quit):add()
200
201 -- Client manipulation
202 keybinding.new({ modkey, "Shift" }, "Escape", function () client.focus_get():kill() end):add()
203 keybinding.new({ modkey }, "k", function () awful.client.focus(1); client.focus_get():raise() end):add()
204 keybinding.new({ modkey }, "j", function () awful.client.focus(-1);  client.focus_get():raise() end):add()
205 keybinding.new({ modkey, "Shift" }, "k", function () awful.client.swap(1) end):add()
206 keybinding.new({ modkey, "Shift" }, "j", function () awful.client.swap(-1) end):add()
207 keybinding.new({ modkey, "Control" }, "k", function () awful.screen.focus(1) end):add()
208 keybinding.new({ modkey, "Control" }, "j", function () awful.screen.focus(-1) end):add()
209 keybinding.new({ modkey, "Control" }, "space", awful.client.togglefloating):add()
210 keybinding.new({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
211 keybinding.new({ modkey }, "o", awful.client.movetoscreen):add()
212
213 -- Layout manipulation
214 keybinding.new({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
215 keybinding.new({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
216 keybinding.new({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
217 keybinding.new({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
218 keybinding.new({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
219 keybinding.new({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
220 keybinding.new({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
221 keybinding.new({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
222
223 -- Prompt
224 keybinding.new({ modkey }, "F1", function ()
225                                      awful.prompt({ prompt = "Run: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.spawn, awful.completion.bash)
226                                  end):add()
227 keybinding.new({ modkey }, "F4", function ()
228                                      awful.prompt({ prompt = "Run Lua code: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mypromptbox, awful.eval, awful.prompt.bash)
229                                  end):add()
230
231 --- Tabulous, tab manipulation
232 keybinding.new({ modkey, "Control" }, "y", function ()
233     local tabbedview = tabulous.tabindex_get()
234     local nextclient = awful.client.next(1)
235
236     if tabbedview == nil then
237         tabbedview = tabulous.tabindex_get(nextclient)
238
239         if tabbedview == nil then
240             tabbedview = tabulous.tab_create()
241             tabulous.tab(tabbedview, nextclient)
242         else
243             tabulous.tab(tabbedview, client.focus_get())
244         end
245     else
246         tabulous.tab(tabbedview, nextclient)
247     end
248 end):add()
249
250 keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add()
251
252 keybinding.new({ modkey }, "y", function ()
253    local tabbedview = tabulous.tabindex_get()
254
255    if tabbedview ~= nil then
256        local n = tabulous.next(tabbedview)
257        tabulous.display(tabbedview, n)
258    end
259 end):add()
260
261 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
262 keybinding.new({ modkey }, "t", awful.client.togglemarked):add()
263 keybinding.new({ modkey, 'Shift' }, "t", function ()
264     local tabbedview = tabulous.tabindex_get()
265     local clients = awful.client.getmarked()
266
267     if tabbedview == nil then
268         tabbedview = tabulous.tab_create(clients[1])
269         table.remove(clients, 1)
270     end
271
272     for k,c in pairs(clients) do
273         tabulous.tab(tabbedview, c)
274     end
275
276 end):add()
277
278 for i = 1, keynumber do
279     keybinding.new({ modkey, "Shift" }, "F" .. i,
280                    function ()
281                        local screen = mouse.screen_get()
282                        if tags[screen][i] then
283                            for k, c in pairs(awful.client.getmarked()) do
284                                awful.client.movetotag(tags[screen][i], c)
285                            end
286                        end
287                    end):add()
288 end
289 -- }}}
290
291 -- {{{ Hooks
292 -- Hook function to execute when focusing a client.
293 function hook_focus(c)
294     if not awful.client.ismarked(c) then
295         c:border_set({ width = border_width, color = border_focus })
296     end
297 end
298
299 -- Hook function to execute when unfocusing a client.
300 function hook_unfocus(c)
301     if not awful.client.ismarked(c) then
302         c:border_set({ width = border_width, color = border_normal })
303     end
304 end
305
306 -- Hook function to execute when marking a client
307 function hook_marked(c)
308     c:border_set({ width = border_width, color = border_marked })
309 end
310
311 -- Hook function to execute when unmarking a client
312 function hook_unmarked(c)
313     c:border_set({ width = border_width, color = border_focus })
314 end
315
316 -- Hook function to execute when the mouse is over a client.
317 function hook_mouseover(c)
318     -- Sloppy focus, but disabled for magnifier layout
319     if awful.layout.get(c:screen_get()) ~= "magnifier" then
320         c:focus_set()
321     end
322 end
323
324 -- Hook function to execute when a new client appears.
325 function hook_manage(c)
326     -- Add mouse bindings
327     c:mouse_add(mouse.new({ }, 1, function (c) c:focus_set(); c:raise() end))
328     c:mouse_add(mouse.new({ modkey }, 1, function (c) c:mouse_move() end))
329     c:mouse_add(mouse.new({ modkey }, 3, function (c) c:mouse_resize() end))
330     -- New client may not receive focus
331     -- if they're not focusable, so set border anyway.
332     c:border_set({ width = border_width, color = border_normal })
333     c:focus_set()
334     if floatings[c:name_get():lower()] then
335         c:floating_set(true)
336     end
337     -- Honor size hints
338     c:honorsizehints_set(true)
339 end
340
341 -- Hook function to execute when arranging the screen
342 -- (tag switch, new client, etc)
343 function hook_arrange(screen)
344     local layout = awful.layout.get(screen)
345     mylayoutbox[screen].text = "<bg image=\"" .. AWESOME_DATADIR .. "/icons/layouts/" .. layout .. "w.png\" resize=\"true\"/>"
346
347     -- Uncomment if you want mouse warping
348     --[[
349     local sel = client.focus_get()
350     if sel then
351         local c_c = sel:coords_get()
352         local m_c = mouse.coords_get()
353
354         if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
355             m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
356             if table.maxn(m_c.buttons) == 0 then
357                 mouse.coords_set(c_c.x + 5, c_c.y + 5)
358             end
359         end
360     end
361     ]]
362 end
363
364
365 -- Hook called every second
366 function hook_timer ()
367     -- For unix time_t lovers
368     -- mytextbox.text = " " .. os.time() .. " time_t "
369     -- Otherwise use:
370     mytextbox.text = " " .. os.date() .. " "
371 end
372
373 -- Set up some hooks
374 awful.hooks.focus(hook_focus)
375 awful.hooks.unfocus(hook_unfocus)
376 awful.hooks.marked(hook_marked)
377 awful.hooks.unmarked(hook_unmarked)
378 awful.hooks.manage(hook_manage)
379 awful.hooks.mouseover(hook_mouseover)
380 awful.hooks.arrange(hook_arrange)
381 awful.hooks.timer(1, hook_timer)
382 -- }}}
383
384 cmdmodkey = "Mod3"
385
386 -- xmms2 & sound
387 keybinding.new({ cmdmodkey }, "Prior", function () awful.spawn("amixer set Master 2+") end):add()
388 keybinding.new({ cmdmodkey }, "Next", function () awful.spawn("amixer set Master 2-") end):add()
389 keybinding.new({ cmdmodkey }, "Up", function () awful.spawn("amixer set PCM 2+") end):add()
390 keybinding.new({ cmdmodkey }, "Down", function () awful.spawn("amixer set PCM 2-") end):add()
391 keybinding.new({ cmdmodkey }, "Home", function () awful.spawn("amixer set Mic toggle") end):add()
392 keybinding.new({ cmdmodkey }, "End", function () awful.spawn("amixer set Master toggle") end):add()
393 keybinding.new({ cmdmodkey }, "Left", function () awful.spawn("xmms2 prev") end):add()
394 keybinding.new({ cmdmodkey }, "Right", function () awful.spawn("xmms2 next") end):add()
395 keybinding.new({ cmdmodkey }, "space", function () awful.spawn("xmms2 toggle") end):add()
396 keybinding.new({ cmdmodkey }, "backslash", function () awful.spawn("xmms2 current | head -1 | xmessage -nearmouse -timeout 5 -file -") end):add()
397 keybinding.new({ cmdmodkey, "Shift" }, "backslash", function () awful.spawn("xmms2 list | xmessage -nearmouse -timeout 5 -file -") end):add()
398
399 -- misc apps
400 keybinding.new({ cmdmodkey }, "n", function () awful.spawn("sensible-browser") end):add()
401 keybinding.new({ cmdmodkey }, "m", function () awful.spawn(terminal .. " -e mutt -f =store") end):add()
402 keybinding.new({ cmdmodkey }, "t", function () awful.spawn(terminal) end):add()
403 keybinding.new({ cmdmodkey }, "c", function () awful.spawn(terminal .. " -e python") end):add()
404 keybinding.new({ cmdmodkey }, "r", function () awful.spawn("gmrun") end):add()
405 keybinding.new({ cmdmodkey }, "j", function () awful.spawn("jpilot") end):add()
406 keybinding.new({ cmdmodkey }, "x", function () awful.spawn("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end):add()
407 keybinding.new({ cmdmodkey, "Shift" }, "x", function () awful.spawn("xscreensaver-command -exit") end):add()