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

initial commit
[etc/awesome.git] / .awesomerc.lua
1 -- awesome 3 configuration file
2
3 AWESOME_DATADIR = "/home/madduck/code"
4 package.path = AWESOME_DATADIR .. "/awesome/?.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 8"
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         tags[s][tagnumber]:mwfact_set(0.618033988769)
68         tags[s][tagnumber]:add(s)
69     end
70     -- I'm sure you want to see at least one tag.
71     tags[s][1]:view(true)
72 end
73 -- }}}
74
75 -- {{{ Statusbar
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> ")
85
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> ")
92
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" })
98
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")
102
103 -- Create a systray
104 mysystray = widget.new({ type = "systray", name = "mysystray", align = "right" })
105
106 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
107 -- We need one layoutbox per screen.
108 mylayoutbox = {}
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")
116 end
117
118 -- Create a statusbar for each screen and add it
119 mystatusbar = {}
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)
131 end
132 mystatusbar[screen.count()]:widget_add(mysystray)
133 -- }}}
134
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))
139 -- }}}
140
141 -- {{{ Key bindings
142
143 -- Bind keyboard digits
144 -- Compute the maximum number of digit we need, limited to 9
145 keynumber = 0
146 for s = 1, screen.count() do
147    keynumber = math.min(9, math.max(#tags[s], keynumber));
148 end
149
150 for i = 1, keynumber do
151     keybinding.new({ modkey }, i,
152                    function ()
153                        local screen = mouse.screen_get()
154                        if tags[screen][i] then
155                            awful.tag.viewonly(tags[screen][i])
156                        end
157                    end):add()
158     keybinding.new({ modkey, "Control" }, i,
159                    function ()
160                        local screen = mouse.screen_get()
161                        if tags[screen][i] then
162                            tags[i]:view(not tags[screen][i]:isselected())
163                        end
164                    end):add()
165     keybinding.new({ modkey, "Shift" }, i,
166                    function ()
167                        local screen = mouse.screen_get()
168                        if tags[screen][i] then
169                            awful.client.movetotag(tags[screen][i])
170                        end
171                    end):add()
172     keybinding.new({ modkey, "Control", "Shift" }, i,
173                    function ()
174                        local screen = mouse.screen_get()
175                        if tags[screen][i] then
176                            awful.client.toggletag(tags[screen][i])
177                        end
178                    end):add()
179 end
180
181 keybinding.new({ modkey }, "Left", awful.tag.viewprev):add()
182 keybinding.new({ modkey }, "Right", awful.tag.viewnext):add()
183
184 -- Standard program
185 keybinding.new({ modkey }, "Return", function () awful.spawn(terminal) end):add()
186
187 keybinding.new({ modkey, "Control" }, "r", awesome.restart):add()
188 keybinding.new({ modkey, "Shift" }, "q", awesome.quit):add()
189
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()
200
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()
210
211 -- Menu
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()
214
215 --- Tabulous, tab manipulation
216 keybinding.new({ modkey, "Control" }, "y", function ()
217     local tabbedview = tabulous.tabindex_get()
218     local nextclient = awful.client.next(1)
219
220     if tabbedview == nil then
221         tabbedview = tabulous.tabindex_get(nextclient)
222
223         if tabbedview == nil then
224             tabbedview = tabulous.tab_create()
225             tabulous.tab(tabbedview, nextclient)
226         else
227             tabulous.tab(tabbedview, client.focus_get())
228         end
229     else
230         tabulous.tab(tabbedview, nextclient)
231     end
232 end):add()
233
234 keybinding.new({ modkey, "Shift" }, "y", tabulous.untab):add()
235
236 keybinding.new({ modkey }, "y", function ()
237    local tabbedview = tabulous.tabindex_get()
238
239    if tabbedview ~= nil then
240        local n = tabulous.next(tabbedview)
241        tabulous.display(tabbedview, n)
242    end
243 end):add()
244
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()
250
251     if tabbedview == nil then
252         tabbedview = tabulous.tab_create(clients[1])
253         table.remove(clients, 1)
254     end
255
256     for k,c in pairs(clients) do
257         tabulous.tab(tabbedview, c)
258     end
259
260 end):add()
261
262 for i = 1, keynumber do
263     keybinding.new({ modkey, "Shift" }, "F" .. i,
264                    function ()
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)
269                            end
270                        end
271                    end):add()
272 end
273 -- }}}
274
275 -- {{{ Hooks
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 })
280     end
281 end
282
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 })
287     end
288 end
289
290 -- Hook function to execute when marking a client
291 function hook_marked(c)
292     c:border_set({ width = border_width, color = border_marked })
293 end
294
295 -- Hook function to execute when unmarking a client
296 function hook_unmarked(c)
297     c:border_set({ width = border_width, color = border_focus })
298 end
299
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
304         c:focus_set()
305     end
306 end
307
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 })
317     c:focus_set()
318     if c:name_get():lower():find("mplayer") then
319         c:floating_set(true)
320     end
321 end
322
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")
328 end
329
330 -- Hook called every second
331 function hook_timer ()
332     -- For unix time_t lovers
333     -- mytextbox:set("text", " " .. os.time() .. " time_t ")
334     -- Otherwise use:
335     mytextbox:set("text", " " .. os.date() .. " ")
336 end
337
338 -- Set up some hooks
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)
347 -- }}}