systray: ignore XEMBED_MAPPED, everyone is not XEMBED aware
[awesome.git] / awesomerc.lua.in
blob9ae833a83c8ba517b51164c7b8f73cb8023732b7
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 workspace 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 -- Uncomment this to activate autotabbing
71 -- tabulous.autotab_start()
72 -- }}}
74 -- {{{ Tags
75 -- Define tags table.
76 tags = {}
77 for s = 1, screen.count() do
78 -- Each screen has its own tag table.
79 tags[s] = {}
80 -- Create 9 tags per screen.
81 for tagnumber = 1, 9 do
82 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
83 -- Add tags to screen one by one
84 tags[s][tagnumber].mwfact = 0.618033988769
85 tags[s][tagnumber].screen = s
86 end
87 -- I'm sure you want to see at least one tag.
88 tags[s][1].selected = true
89 end
90 -- }}}
92 -- {{{ Statusbar
93 -- Create a taglist widget
94 mytaglist = widget({ type = "taglist", name = "mytaglist" })
95 mytaglist:mouse_add(mouse({}, 1, function (object, tag) awful.tag.viewonly(tag) end))
96 mytaglist:mouse_add(mouse({ modkey }, 1, function (object, tag) awful.client.movetotag(tag) end))
97 mytaglist:mouse_add(mouse({}, 3, function (object, tag) tag.selected = not tag.selected end))
98 mytaglist:mouse_add(mouse({ modkey }, 3, function (object, tag) awful.client.toggletag(tag) end))
99 mytaglist:mouse_add(mouse({ }, 4, awful.tag.viewnext))
100 mytaglist:mouse_add(mouse({ }, 5, awful.tag.viewprev))
101 mytaglist.label = awful.widget.taglist.label.all
103 -- Create a tasklist widget
104 mytasklist = widget({ type = "tasklist", name = "mytasklist" })
105 mytasklist:mouse_add(mouse({ }, 1, function (object, c) c:focus_set(); c:raise() end))
106 mytasklist:mouse_add(mouse({ }, 4, function () awful.client.focusbyidx(1) end))
107 mytasklist:mouse_add(mouse({ }, 5, function () awful.client.focusbyidx(-1) end))
108 mytasklist.label = awful.widget.tasklist.label.currenttags
110 -- Create a textbox widget
111 mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
112 -- Set the default text in textbox
113 mytextbox.text = "<b><small> awesome " .. AWESOME_VERSION .. " </small></b>"
114 mypromptbox = widget({ type = "textbox", name = "mypromptbox", align = "left" })
116 -- Create an iconbox widget
117 myiconbox = widget({ type = "textbox", name = "myiconbox", align = "left" })
118 myiconbox.text = "<bg image=\"@AWESOME_ICON_PATH@/awesome16.png\" resize=\"true\"/>"
120 -- Create a systray
121 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
123 -- Create an iconbox widget which will contains an icon indicating which layout we're using.
124 -- We need one layoutbox per screen.
125 mylayoutbox = {}
126 for s = 1, screen.count() do
127 mylayoutbox[s] = widget({ type = "textbox", name = "mylayoutbox", align = "right" })
128 mylayoutbox[s]:mouse_add(mouse({ }, 1, function () awful.layout.inc(layouts, 1) end))
129 mylayoutbox[s]:mouse_add(mouse({ }, 3, function () awful.layout.inc(layouts, -1) end))
130 mylayoutbox[s]:mouse_add(mouse({ }, 4, function () awful.layout.inc(layouts, 1) end))
131 mylayoutbox[s]:mouse_add(mouse({ }, 5, function () awful.layout.inc(layouts, -1) end))
132 mylayoutbox[s].text = "<bg image=\"@AWESOME_ICON_PATH@/layouts/tilew.png\" resize=\"true\"/>"
135 -- Create a statusbar for each screen and add it
136 mystatusbar = {}
137 for s = 1, screen.count() do
138 mystatusbar[s] = statusbar({ position = "top", name = "mystatusbar" .. s,
139 fg = beautiful.fg_normal, bg = beautiful.bg_normal })
140 -- Add widgets to the statusbar - order matters
141 mystatusbar[s].widgets =
143 mytaglist,
144 mytasklist,
145 mypromptbox,
146 mytextbox,
147 mylayoutbox[s],
148 s == screen.count() and mysystray or nil
150 mystatusbar[s].screen = s
152 -- }}}
154 -- {{{ Mouse bindings
155 awesome.mouse_add(mouse({ }, 3, function () awful.spawn(terminal) end))
156 awesome.mouse_add(mouse({ }, 4, awful.tag.viewnext))
157 awesome.mouse_add(mouse({ }, 5, awful.tag.viewprev))
158 -- }}}
160 -- {{{ Key bindings
162 -- Bind keyboard digits
163 -- Compute the maximum number of digit we need, limited to 9
164 keynumber = 0
165 for s = 1, screen.count() do
166 keynumber = math.min(9, math.max(#tags[s], keynumber));
169 for i = 1, keynumber do
170 keybinding({ modkey }, i,
171 function ()
172 local screen = mouse.screen
173 if tags[screen][i] then
174 awful.tag.viewonly(tags[screen][i])
176 end):add()
177 keybinding({ modkey, "Control" }, i,
178 function ()
179 local screen = mouse.screen
180 if tags[screen][i] then
181 tags[screen][i].selected = not tags[screen][i].selected
183 end):add()
184 keybinding({ modkey, "Shift" }, i,
185 function ()
186 local sel = client.focus_get()
187 if sel then
188 if tags[sel.screen][i] then
189 awful.client.movetotag(tags[sel.screen][i])
192 end):add()
193 keybinding({ modkey, "Control", "Shift" }, i,
194 function ()
195 local sel = client.focus_get()
196 if sel then
197 if tags[sel.screen][i] then
198 awful.client.toggletag(tags[sel.screen][i])
201 end):add()
204 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
205 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
206 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
208 -- Standard program
209 keybinding({ modkey }, "Return", function () awful.spawn(terminal) end):add()
211 keybinding({ modkey, "Control" }, "r", awesome.restart):add()
212 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
214 -- Client manipulation
215 keybinding({ modkey }, "m", awful.client.maximize):add()
216 keybinding({ modkey, "Shift" }, "c", function () client.focus_get():kill() end):add()
217 keybinding({ modkey }, "j", function () awful.client.focusbyidx(1); client.focus_get():raise() end):add()
218 keybinding({ modkey }, "k", function () awful.client.focusbyidx(-1); client.focus_get():raise() end):add()
219 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
220 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
221 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
222 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
223 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
224 keybinding({ modkey, "Control" }, "Return", function () client.focus_get():swap(awful.client.master()) end):add()
225 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
226 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
228 -- Layout manipulation
229 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
230 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
231 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
232 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
233 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
234 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
235 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
236 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
238 -- Prompt
239 keybinding({ modkey }, "F1", function ()
240 awful.prompt({ prompt = "Run: " }, mypromptbox, awful.spawn, awful.completion.bash)
241 end):add()
242 keybinding({ modkey }, "F4", function ()
243 awful.prompt({ prompt = "Run Lua code: " }, mypromptbox, awful.eval)
244 end):add()
246 --- Tabulous, tab manipulation
247 keybinding({ modkey, "Control" }, "y", function ()
248 local tabbedview = tabulous.tabindex_get()
249 local nextclient = awful.client.next(1)
251 if not tabbedview then
252 tabbedview = tabulous.tabindex_get(nextclient)
254 if not tabbedview then
255 tabbedview = tabulous.tab_create()
256 tabulous.tab(tabbedview, nextclient)
257 else
258 tabulous.tab(tabbedview, client.focus_get())
260 else
261 tabulous.tab(tabbedview, nextclient)
263 end):add()
265 keybinding({ modkey, "Shift" }, "y", tabulous.untab):add()
267 keybinding({ modkey }, "y", function ()
268 local tabbedview = tabulous.tabindex_get()
270 if tabbedview then
271 local n = tabulous.next(tabbedview)
272 tabulous.display(tabbedview, n)
274 end):add()
276 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
277 keybinding({ modkey }, "t", awful.client.togglemarked):add()
278 keybinding({ modkey, 'Shift' }, "t", function ()
279 local tabbedview = tabulous.tabindex_get()
280 local clients = awful.client.getmarked()
282 if not tabbedview then
283 tabbedview = tabulous.tab_create(clients[1])
284 table.remove(clients, 1)
287 for k,c in pairs(clients) do
288 tabulous.tab(tabbedview, c)
291 end):add()
293 for i = 1, keynumber do
294 keybinding({ modkey, "Shift" }, "F" .. i,
295 function ()
296 local screen = mouse.screen
297 if tags[screen][i] then
298 for k, c in pairs(awful.client.getmarked()) do
299 awful.client.movetotag(tags[screen][i], c)
302 end):add()
304 -- }}}
306 -- {{{ Hooks
307 -- Hook function to execute when focusing a client.
308 function hook_focus(c)
309 if not awful.client.ismarked(c) then
310 c.border_color = beautiful.border_focus
314 -- Hook function to execute when unfocusing a client.
315 function hook_unfocus(c)
316 if not awful.client.ismarked(c) then
317 c.border_color = beautiful.border_normal
321 -- Hook function to execute when marking a client
322 function hook_marked(c)
323 c.border_color = beautiful.border_marked
326 -- Hook function to execute when unmarking a client
327 function hook_unmarked(c)
328 c.border_color = beautiful.border_focus
331 -- Hook function to execute when the mouse is over a client.
332 function hook_mouseover(c)
333 -- Sloppy focus, but disabled for magnifier layout
334 if awful.layout.get(c.screen) ~= "magnifier" then
335 c:focus_set()
339 -- Hook function to execute when a new client appears.
340 function hook_manage(c)
341 -- Set floating placement to be smart!
342 c.floating_placement = "smart"
343 if use_titlebar then
344 -- Add a titlebar
345 awful.titlebar.add(c, { modkey = modkey })
347 -- Add mouse bindings
348 c:mouse_add(mouse({ }, 1, function (c) c:focus_set(); c:raise() end))
349 c:mouse_add(mouse({ modkey }, 1, function (c) c:mouse_move() end))
350 c:mouse_add(mouse({ modkey }, 3, function (c) c:mouse_resize() end))
351 -- New client may not receive focus
352 -- if they're not focusable, so set border anyway.
353 c.border_width = beautiful.border_width
354 c.border_color = beautiful.border_normal
355 c:focus_set()
357 -- Check if the application should be floating.
358 local cls = c.class
359 local inst = c.instance
360 if floatapps[cls] then
361 c.floating = floatapps[cls]
362 elseif floatapps[inst] then
363 c.floating = floatapps[inst]
366 -- Check application->screen/tag mappings.
367 local target
368 if apptags[cls] then
369 target = apptags[cls]
370 elseif apptags[inst] then
371 target = apptags[inst]
373 if target then
374 c.screen = target.screen
375 awful.client.movetotag(tags[target.screen][target.tag], c)
378 -- Honor size hints
379 c.honorsizehints = true
382 -- Hook function to execute when arranging the screen
383 -- (tag switch, new client, etc)
384 function hook_arrange(screen)
385 mylayoutbox[screen].text =
386 "<bg image=\"@AWESOME_ICON_PATH@/layouts/" .. awful.layout.get(screen) .. "w.png\" resize=\"true\"/>"
388 -- If no window has focus, give focus to the latest in history
389 if not client.focus_get() then
390 local c = awful.client.focus.history.get(screen, 0)
391 if c then c:focus_set() end
394 -- Uncomment if you want mouse warping
395 --[[
396 local sel = client.focus_get()
397 if sel then
398 local c_c = sel.coords
399 local m_c = mouse.coords
401 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
402 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
403 if table.maxn(m_c.buttons) == 0 then
404 mouse.coords = { x = c_c.x + 5, y = c_c.y + 5}
411 -- Hook called every second
412 function hook_timer ()
413 -- For unix time_t lovers
414 mytextbox.text = " " .. os.time() .. " time_t "
415 -- Otherwise use:
416 -- mytextbox.text = " " .. os.date() .. " "
419 -- Set up some hooks
420 awful.hooks.focus.register(hook_focus)
421 awful.hooks.unfocus.register(hook_unfocus)
422 awful.hooks.marked.register(hook_marked)
423 awful.hooks.unmarked.register(hook_unmarked)
424 awful.hooks.manage.register(hook_manage)
425 awful.hooks.mouseover.register(hook_mouseover)
426 awful.hooks.arrange.register(hook_arrange)
427 awful.hooks.timer.register(1, hook_timer)
428 -- }}}