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

688d175f6182a0d770c3fb9296ab74e627c7c231
[etc/awesome.git] / .awesomerc.lua
1 -- awesome 3 configuration file
2
3 AWESOME_DATADIR = "/home/madduck/code"
4 package.path = AWESOME_DATADIR .. "/awesome/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 -- Color & Appearance definitions, we use these later to display things
39 font = "RotisSansSerif 10"
40 border_width = 1
41
42 bg_normal = "#222222"
43 fg_normal = "#aaaaaa"
44 border_normal = "#000000"
45
46 bg_focus = "#535d6c"
47 fg_focus = "#ffffff"
48 border_focus = bg_focus
49 border_marked = "#91231C"
50
51 awesome.font_set(font)
52 awesome.colors_set({ fg = fg_normal, bg = bg_normal })
53 awesome.resizehints_set(true)
54
55 -- }}}
56
57 -- {{{ Tags
58 -- Define tags table
59 tags = {}
60 for s = 1, screen.count() do
61     -- Each screen has its own tag table
62     tags[s] = {}
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)
70     end
71     -- I'm sure you want to see at least one tag.
72     tags[s][1]:view(true)
73 end
74 -- }}}
75
76 -- {{{ Statusbar
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> ")
86
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> ")
93
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" })
99
100 -- Create a systray
101 mysystray = widget.new({ type = "systray", name = "mysystray", align = "right" })
102
103 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
104 -- We need one layoutbox per screen.
105 mylayoutbox = {}
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")
113 end
114
115 -- Create a statusbar for each screen and add it
116 mystatusbar = {}
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)
128 end
129 mystatusbar[screen.count()]:widget_add(mysystray)
130 -- }}}
131
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))
136 -- }}}
137
138 -- {{{ Key bindings
139
140 -- Bind keyboard digits
141 -- Compute the maximum number of digit we need, limited to 9
142 keynumber = 0
143 for s = 1, screen.count() do
144    keynumber = math.min(9, math.max(#tags[s], keynumber));
145 end
146
147 for i = 1, keynumber do
148     keybinding.new({ modkey }, i,
149                    function ()
150                        local screen = mouse.screen_get()
151                        if tags[screen][i] then
152                            awful.tag.viewonly(tags[screen][i])
153                        end
154                    end):add()
155     keybinding.new({ modkey, "Control" }, i,
156                    function ()
157                        local screen = mouse.screen_get()
158                        if tags[screen][i] then
159                            tags[i]:view(not tags[screen][i]:isselected())
160                        end
161                    end):add()
162     keybinding.new({ modkey, "Shift" }, i,
163                    function ()
164                        local screen = mouse.screen_get()
165                        if tags[screen][i] then
166                            awful.client.movetotag(tags[screen][i])
167                        end
168                    end):add()
169     keybinding.new({ modkey, "Control", "Shift" }, i,
170                    function ()
171                        local screen = mouse.screen_get()
172                        if tags[screen][i] then
173                            awful.client.toggletag(tags[screen][i])
174                        end
175                    end):add()
176 end
177
178 keybinding.new({ modkey }, "Left", awful.tag.viewprev):add()
179 keybinding.new({ modkey }, "Right", awful.tag.viewnext):add()
180
181 -- Standard program
182 keybinding.new({ modkey }, "Return", function () awful.spawn(terminal) end):add()
183
184 keybinding.new({ modkey, "Control" }, "r", awesome.restart):add()
185 keybinding.new({ modkey, "Shift" }, "q", awesome.quit):add()
186
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()
198
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()
208
209 -- Menu
210 keybinding.new({ modkey }, "F1", function ()
211                                      awful.menu({ prompt = "Run: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mymenubox, awful.spawn)
212                                  end):add()
213 keybinding.new({ modkey }, "F4", function ()
214                                      awful.menu({ prompt = "Run Lua code: ", cursor_fg = fg_focus, cursor_bg = bg_focus }, mymenubox, awful.eval)
215                                  end):add()
216
217 --- Tabulous, tab manipulation
218 keybinding.new({ modkey, "Control" }, "y", function ()
219     local tabbedview = tabulous.tabindex_get()
220     local nextclient = awful.client.next(1)
221
222     if tabbedview == nil then
223         tabbedview = tabulous.tabindex_get(nextclient)
224
225         if tabbedview == nil then
226             tabbedview = tabulous.tab_create()
227             tabulous.tab(tabbedview, nextclient)
228         else
229             tabulous.tab(tabbedview, client.focus_get())
230         end
231     else
232         tabulous.tab(tabbedview, nextclient)
233     end
234 end):add()
235
236 keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add()
237
238 keybinding.new({ modkey }, "y", function ()
239    local tabbedview = tabulous.tabindex_get()
240
241    if tabbedview ~= nil then
242        local n = tabulous.next(tabbedview)
243        tabulous.display(tabbedview, n)
244    end
245 end):add()
246
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()
252
253     if tabbedview == nil then
254         tabbedview = tabulous.tab_create(clients[1])
255         table.remove(clients, 1)
256     end
257
258     for k,c in pairs(clients) do
259         tabulous.tab(tabbedview, c)
260     end
261
262 end):add()
263
264 for i = 1, keynumber do
265     keybinding.new({ modkey, "Shift" }, "F" .. i,
266                    function ()
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)
271                            end
272                        end
273                    end):add()
274 end
275 -- }}}
276
277 -- {{{ Hooks
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 })
282     end
283 end
284
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 })
289     end
290 end
291
292 -- Hook function to execute when marking a client
293 function hook_marked(c)
294     c:border_set({ width = border_width, color = border_marked })
295 end
296
297 -- Hook function to execute when unmarking a client
298 function hook_unmarked(c)
299     c:border_set({ width = border_width, color = border_focus })
300 end
301
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
306         c:focus_set()
307     end
308 end
309
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 })
319     c:focus_set()
320     if c:name_get():lower():find("mplayer") then
321         c:floating_set(true)
322     end
323     if c:name_get():find("pinentry") then
324         c:floating_set(true)
325     end
326     if c:name_get():lower():find("twinkle") then
327         c:floating_set(true)
328     end
329     if c:name_get():find("GIMP") then
330         c:floating_set(true)
331     end
332 end
333
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")
339 end
340
341 -- Hook called every second
342 function hook_timer ()
343     -- For unix time_t lovers
344     -- mytextbox:set("text", " " .. os.time() .. " time_t ")
345     -- Otherwise use:
346     mytextbox:set("text", " " .. os.date() .. " ")
347 end
348
349 -- Set up some hooks
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)
358 -- }}}