awful: fix empty command adding
[awesome.git] / awesomerc.lua.in
blob8bf9a5d4584cece6ef7ec3996240d86a066df53e
1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
4 require("awful")
5 require("tabulous")
6 require("beautiful")
8 -- {{{ Variable definitions
9 -- This is a file path to a theme file which will defines colors.
10 theme_path = "@AWESOME_THEMES_PATH@/default"
12 -- This is used later as the default terminal to run.
13 terminal = "xterm"
15 -- Default modkey.
16 -- Usually, Mod4 is the key with a logo between Control and Alt.
17 -- If you do not like this or do not have such a key,
18 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
19 -- However, you can use another modifier like Mod1, but it may interact with others.
20 modkey = "Mod4"
22 -- Table of layouts to cover with awful.layout.inc, order matters.
23 layouts =
25 "tile",
26 "tileleft",
27 "tilebottom",
28 "tiletop",
29 "magnifier",
30 "max",
31 "spiral",
32 "dwindle",
33 "floating"
36 -- Table of clients that should be set floating. The index may be either
37 -- the application class or instance. The instance is useful when running
38 -- a console app in a terminal like (Music on Console)
39 -- xterm -name mocp -e mocp
40 floatapps =
42 -- by class
43 ["MPlayer"] = true,
44 ["pinentry"] = true,
45 -- by instance
46 ["mocp"] = true
49 -- Applications to be moved to a pre-defined tag by class or instance.
50 -- Use the screen and tags indices.
51 apptags =
53 -- ["Firefox"] = { screen = 1, tag = 2 },
54 -- ["mocp"] = { screen = 2, tag = 4 },
57 -- Define if we want to use titlebar on all applications.
58 use_titlebar = false
59 -- }}}
61 -- {{{ Initialization
62 -- Initialize theme (colors).
63 beautiful.init(theme_path)
65 -- Register theme in awful.
66 -- This allows to not pass plenty of arguments to each function
67 -- to inform it about colors we want it to draw.
68 awful.beautiful.register(beautiful)
70 -- Enable prompt history
71 awful.prompt.history.set()
73 -- Uncomment this to activate autotabbing
74 -- tabulous.autotab_start()
75 -- }}}
77 -- {{{ Tags
78 -- Define tags table.
79 tags = {}
80 for s = 1, screen.count() do
81 -- Each screen has its own tag table.
82 tags[s] = {}
83 -- Create 9 tags per screen.
84 for tagnumber = 1, 9 do
85 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
86 -- Add tags to screen one by one
87 tags[s][tagnumber].mwfact = 0.618033988769
88 tags[s][tagnumber].screen = s
89 end
90 -- I'm sure you want to see at least one tag.
91 tags[s][1].selected = true
92 end
93 -- }}}
95 -- {{{ Statusbar
96 -- Create a taglist widget
97 mytaglist = widget({ type = "taglist", name = "mytaglist" })
98 mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
99 mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
100 mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
101 mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
102 mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
103 mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
104 mytaglist.label = awful.widget.taglist.label.all
106 -- Create a tasklist widget
107 mytasklist = widget({ type = "tasklist", name = "mytasklist" })
108 mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
109 mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focusbyidx(1) end))
110 mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focusbyidx(-1) end))
111 mytasklist.label = awful.widget.tasklist.label.currenttags
113 -- Create a textbox widget
114 mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
115 -- Set the default text in textbox
116 mytextbox.text = "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>"
117 mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
119 -- Create an iconbox widget
120 myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
121 myiconbox.text = "<bg image=\"@AWESOME_ICON_PATH@/awesome16.png\" resize=\"true\"/>"
123 -- Create a systray
124 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
126 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
127 -- We need one layoutbox per screen.
128 mylayoutbox = {}
129 for s = 1, screen.count() do
130 mylayoutbox[s] = widget({ type = "textbox", name = "mylayoutbox", align = "right" })
131 mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
132 mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
133 mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
134 mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
135 mylayoutbox[s].text = "<bg image=\"@AWESOME_ICON_PATH@/layouts/tilew.png\" resize=\"true\"/>"
138 -- Create a statusbar for each screen and add it
139 mystatusbar = {}
140 for s = 1, screen.count() do
141 mystatusbar[s] = statusbar({ position = "top", name = "mystatusbar" .. s,
142 fg = beautiful.fg_normal, bg = beautiful.bg_normal })
143 -- Add widgets to the statusbar - order matters
144 mystatusbar[s].widgets =
146 mytaglist,
147 mytasklist,
148 mypromptbox,
149 mytextbox,
150 mylayoutbox[s],
151 s == screen.count() and mysystray or nil
153 mystatusbar[s].screen = s
155 -- }}}
157 -- {{{ Mouse bindings
158 awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
159 awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
160 awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
161 -- }}}
163 -- {{{ Key bindings
165 -- Bind keyboard digits
166 -- Compute the maximum number of digit we need, limited to 9
167 keynumber = 0
168 for s = 1, screen.count() do
169 keynumber = math.min(9, math.max(#tags[s], keynumber));
172 for i = 1, keynumber do
173 keybinding({ modkey }, i,
174 function ()
175 local screen = mouse.screen
176 if tags[screen][i] then
177 awful.tag.viewonly(tags[screen][i])
179 end):add()
180 keybinding({ modkey, "Control" }, i,
181 function ()
182 local screen = mouse.screen
183 if tags[screen][i] then
184 tags[screen][i].selected = not tags[screen][i].selected
186 end):add()
187 keybinding({ modkey, "Shift" }, i,
188 function ()
189 local sel = client.focus_get()
190 if sel then
191 if tags[sel.screen][i] then
192 awful.client.movetotag(tags[sel.screen][i])
195 end):add()
196 keybinding({ modkey, "Control", "Shift" }, i,
197 function ()
198 local sel = client.focus_get()
199 if sel then
200 if tags[sel.screen][i] then
201 awful.client.toggletag(tags[sel.screen][i])
204 end):add()
207 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
208 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
209 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
211 -- Standard program
212 keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
214 keybinding({ modkey, "Control" }, "r", awesome.restart):add()
215 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
217 -- Client manipulation
218 keybinding({ modkey }, "m", awful.client.maximize):add()
219 keybinding({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
220 keybinding({ modkey }, "j", function () awful.client.focusbyidx(1); client.focus_get():raise() end):add()
221 keybinding({ modkey }, "k", function () awful.client.focusbyidx(-1); client.focus_get():raise() end):add()
222 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
223 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
224 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
225 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
226 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
227 keybinding({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
228 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
229 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
231 -- Layout manipulation
232 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
233 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
234 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
235 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
236 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
237 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
238 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
239 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
241 -- Prompt
242 keybinding({ modkey }, "F1", function ()
243 awful.prompt.run({ prompt = "Run: " }, mypromptbox, awful.spawn, awful.completion.bash)
244 end):add()
245 keybinding({ modkey }, "F4", function ()
246 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox, awful.eval)
247 end):add()
249 --- Tabulous, tab manipulation
250 keybinding({ modkey, "Control" }, "y", function ()
251 local tabbedview = tabulous.tabindex_get()
252 local nextclient = awful.client.next(1)
254 if not tabbedview then
255 tabbedview = tabulous.tabindex_get(nextclient)
257 if not tabbedview then
258 tabbedview = tabulous.tab_create()
259 tabulous.tab(tabbedview, nextclient)
260 else
261 tabulous.tab(tabbedview, client.focus_get())
263 else
264 tabulous.tab(tabbedview, nextclient)
266 end):add()
268 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
270 keybinding({ modkey }, "y", function ()
271 local tabbedview = tabulous.tabindex_get()
273 if tabbedview then
274 local n = tabulous.next(tabbedview)
275 tabulous.display(tabbedview, n)
277 end):add()
279 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
280 keybinding({ modkey }, "t", awful.client.togglemarked):add()
281 keybinding({ modkey, 'Shift' }, "t", function ()
282 local tabbedview = tabulous.tabindex_get()
283 local clients = awful.client.getmarked()
285 if not tabbedview then
286 tabbedview = tabulous.tab_create(clients[1])
287 table.remove(clients, 1)
290 for k,c in pairs(clients) do
291 tabulous.tab(tabbedview, c)
294 end):add()
296 for i = 1, keynumber do
297 keybinding({ modkey, "Shift" }, "F" .. i,
298 function ()
299 local screen = mouse.screen
300 if tags[screen][i] then
301 for k, c in pairs(awful.client.getmarked()) do
302 awful.client.movetotag(tags[screen][i], c)
305 end):add()
307 -- }}}
309 -- {{{ Hooks
310 -- Hook function to execute when focusing a client.
311 function hook_focus(c)
312 if not awful.client.ismarked(c) then
313 c.border_color = beautiful.border_focus
317 -- Hook function to execute when unfocusing a client.
318 function hook_unfocus(c)
319 if not awful.client.ismarked(c) then
320 c.border_color = beautiful.border_normal
324 -- Hook function to execute when marking a client
325 function hook_marked(c)
326 c.border_color = beautiful.border_marked
329 -- Hook function to execute when unmarking a client
330 function hook_unmarked(c)
331 c.border_color = beautiful.border_focus
334 -- Hook function to execute when the mouse is over a client.
335 function hook_mouseover(c)
336 -- Sloppy focus, but disabled for magnifier layout
337 if awful.layout.get(c.screen) ~= "magnifier" then
338 c:focus_set()
342 -- Hook function to execute when a new client appears.
343 function hook_manage(c)
344 -- Set floating placement to be smart!
345 c.floating_placement = "smart"
346 if use_titlebar then
347 -- Add a titlebar
348 awful.titlebar.add(c, { modkey = modkey })
350 -- Add mouse bindings
351 c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
352 c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
353 c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
354 -- New client may not receive focus
355 -- if they're not focusable, so set border anyway.
356 c.border_width = beautiful.border_width
357 c.border_color = beautiful.border_normal
358 c:focus_set()
360 -- Check if the application should be floating.
361 local cls = c.class
362 local inst = c.instance
363 if floatapps[cls] then
364 c.floating = floatapps[cls]
365 elseif floatapps[inst] then
366 c.floating = floatapps[inst]
369 -- Check application->screen/tag mappings.
370 local target
371 if apptags[cls] then
372 target = apptags[cls]
373 elseif apptags[inst] then
374 target = apptags[inst]
376 if target then
377 c.screen = target.screen
378 awful.client.movetotag(tags[target.screen][target.tag], c)
381 -- Honor size hints
382 c.honorsizehints = true
385 -- Hook function to execute when arranging the screen
386 -- (tag switch, new client, etc)
387 function hook_arrange(screen)
388 local layout = awful.layout.get(screen)
389 if layout then
390 mylayoutbox[screen].text =
391 "<bg image=\"@AWESOME_ICON_PATH@/layouts/" .. awful.layout.get(screen) .. "w.png\" resize=\"true\"/>"
392 else
393 mylayoutbox[screen].text = "No layout."
396 -- If no window has focus, give focus to the latest in history
397 if not client.focus_get() then
398 local c = awful.client.focus.history.get(screen, 0)
399 if c then c:focus_set() end
402 -- Uncomment if you want mouse warping
403 --[[
404 local sel = client.focus_get()
405 if sel then
406 local c_c = sel.coords
407 local m_c = mouse.coords
409 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
410 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
411 if table.maxn(m_c.buttons) == 0 then
412 mouse.coords = { x = c_c.x + 5, y = c_c.y + 5}
419 -- Hook called every second
420 function hook_timer ()
421 -- For unix time_t lovers
422 mytextbox.text = " " .. os.time() .. " time_t "
423 -- Otherwise use:
424 -- mytextbox.text = " " .. os.date() .. " "
427 -- Set up some hooks
428 awful.hooks.focus.register(hook_focus)
429 awful.hooks.unfocus.register(hook_unfocus)
430 awful.hooks.marked.register(hook_marked)
431 awful.hooks.unmarked.register(hook_unmarked)
432 awful.hooks.manage.register(hook_manage)
433 awful.hooks.mouseover.register(hook_mouseover)
434 awful.hooks.arrange.register(hook_arrange)
435 awful.hooks.timer.register(1, hook_timer)
436 -- }}}