ewmh: add missing window types
[awesome.git] / awesomerc.lua.in
blobcc43e9ff36d27d6960dfaaab8d76605f920d11b9
1 -- Standard awesome library
2 require("awful")
3 -- Theme handling library
4 require("beautiful")
5 -- Notification library
6 require("naughty")
8 -- {{{ Variable definitions
9 -- Themes define colours, icons, and wallpapers
10 -- The default is a dark theme
11 theme_path = "@AWESOME_THEMES_PATH@/default/theme"
12 -- Uncommment this for a lighter theme
13 -- theme_path = "@AWESOME_THEMES_PATH@/sky/theme"
15 -- Actually load theme
16 beautiful.init(theme_path)
18 -- This is used later as the default terminal and editor to run.
19 terminal = "xterm"
20 editor = os.getenv("EDITOR") or "nano"
21 editor_cmd = terminal .. " -e " .. editor
23 -- Default modkey.
24 -- Usually, Mod4 is the key with a logo between Control and Alt.
25 -- If you do not like this or do not have such a key,
26 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
27 -- However, you can use another modifier like Mod1, but it may interact with others.
28 modkey = "Mod4"
30 -- Table of layouts to cover with awful.layout.inc, order matters.
31 layouts =
33 awful.layout.suit.tile,
34 awful.layout.suit.tile.left,
35 awful.layout.suit.tile.bottom,
36 awful.layout.suit.tile.top,
37 awful.layout.suit.fair,
38 awful.layout.suit.fair.horizontal,
39 awful.layout.suit.max,
40 awful.layout.suit.max.fullscreen,
41 awful.layout.suit.magnifier,
42 awful.layout.suit.floating
45 -- Table of clients that should be set floating. The index may be either
46 -- the application class or instance. The instance is useful when running
47 -- a console app in a terminal like (Music on Console)
48 -- xterm -name mocp -e mocp
49 floatapps =
51 -- by class
52 ["MPlayer"] = true,
53 ["pinentry"] = true,
54 ["gimp"] = true,
55 -- by instance
56 ["mocp"] = true
59 -- Applications to be moved to a pre-defined tag by class or instance.
60 -- Use the screen and tags indices.
61 apptags =
63 -- ["Firefox"] = { screen = 1, tag = 2 },
64 -- ["mocp"] = { screen = 2, tag = 4 },
67 -- Define if we want to use titlebar on all applications.
68 use_titlebar = false
69 -- }}}
71 -- {{{ Tags
72 -- Define tags table.
73 tags = {}
74 for s = 1, screen.count() do
75 -- Each screen has its own tag table.
76 tags[s] = {}
77 -- Create 9 tags per screen.
78 for tagnumber = 1, 9 do
79 tags[s][tagnumber] = tag(tagnumber)
80 -- Add tags to screen one by one
81 tags[s][tagnumber].screen = s
82 awful.layout.set(layouts[1], tags[s][tagnumber])
83 end
84 -- I'm sure you want to see at least one tag.
85 tags[s][1].selected = true
86 end
87 -- }}}
89 -- {{{ Wibox
90 -- Create a textbox widget
91 mytextbox = widget({ type = "textbox", align = "right" })
92 -- Set the default text in textbox
93 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
95 -- Create a laucher widget and a main menu
96 myawesomemenu = {
97 { "manual", terminal .. " -e man awesome" },
98 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
99 { "restart", awesome.restart },
100 { "quit", awesome.quit }
103 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
104 { "open terminal", terminal }
108 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
109 menu = mymainmenu })
111 -- Create a systray
112 mysystray = widget({ type = "systray", align = "right" })
114 -- Create a wibox for each screen and add it
115 mywibox = {}
116 mypromptbox = {}
117 mylayoutbox = {}
118 mytaglist = {}
119 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
120 button({ modkey }, 1, awful.client.movetotag),
121 button({ }, 3, function (tag) tag.selected = not tag.selected end),
122 button({ modkey }, 3, awful.client.toggletag),
123 button({ }, 4, awful.tag.viewnext),
124 button({ }, 5, awful.tag.viewprev) }
125 mytasklist = {}
126 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
127 button({ }, 3, function () if instance then instance:hide() end instance = awful.menu.clients({ width=250 }) end),
128 button({ }, 4, function () awful.client.focus.byidx(1) end),
129 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
131 for s = 1, screen.count() do
132 -- Create a promptbox for each screen
133 mypromptbox[s] = widget({ type = "textbox", align = "left" })
134 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
135 -- We need one layoutbox per screen.
136 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
137 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
138 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
139 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
140 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
141 -- Create a taglist widget
142 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
144 -- Create a tasklist widget
145 mytasklist[s] = awful.widget.tasklist.new(function(c)
146 return awful.widget.tasklist.label.currenttags(c, s)
147 end, mytasklist.buttons)
149 -- Create the wibox
150 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
151 -- Add widgets to the wibox - order matters
152 mywibox[s].widgets = { mylauncher,
153 mytaglist[s],
154 mytasklist[s],
155 mypromptbox[s],
156 mytextbox,
157 mylayoutbox[s],
158 s == 1 and mysystray or nil }
159 mywibox[s].screen = s
161 -- }}}
163 -- {{{ Mouse bindings
164 root.buttons({
165 button({ }, 3, function () mymainmenu:toggle() end),
166 button({ }, 4, awful.tag.viewnext),
167 button({ }, 5, awful.tag.viewprev)
169 -- }}}
171 -- {{{ Key bindings
172 -- Bind keyboard digits
173 -- Compute the maximum number of digit we need, limited to 9
174 keynumber = 0
175 for s = 1, screen.count() do
176 keynumber = math.min(9, math.max(#tags[s], keynumber));
179 globalkeys = {}
180 clientkeys = {}
182 for i = 1, keynumber do
183 table.insert(globalkeys,
184 key({ modkey }, i,
185 function ()
186 local screen = mouse.screen
187 if tags[screen][i] then
188 awful.tag.viewonly(tags[screen][i])
190 end))
191 table.insert(globalkeys,
192 key({ modkey, "Control" }, i,
193 function ()
194 local screen = mouse.screen
195 if tags[screen][i] then
196 tags[screen][i].selected = not tags[screen][i].selected
198 end))
199 table.insert(globalkeys,
200 key({ modkey, "Shift" }, i,
201 function ()
202 if client.focus and tags[client.focus.screen][i] then
203 awful.client.movetotag(tags[client.focus.screen][i])
205 end))
206 table.insert(globalkeys,
207 key({ modkey, "Control", "Shift" }, i,
208 function ()
209 if client.focus and tags[client.focus.screen][i] then
210 awful.client.toggletag(tags[client.focus.screen][i])
212 end))
215 table.insert(globalkeys, key({ modkey }, "Left", awful.tag.viewprev))
216 table.insert(globalkeys, key({ modkey }, "Right", awful.tag.viewnext))
217 table.insert(globalkeys, key({ modkey }, "Escape", awful.tag.history.restore))
219 table.insert(globalkeys, key({ modkey }, "j", function () awful.client.focus.byidx(1); if client.focus then client.focus:raise() end end))
220 table.insert(globalkeys, key({ modkey }, "k", function () awful.client.focus.byidx(-1); if client.focus then client.focus:raise() end end))
221 table.insert(globalkeys, key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(1) end))
222 table.insert(globalkeys, key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx(-1) end))
224 table.insert(globalkeys, key({ modkey, "Control" }, "j", function () awful.screen.focus(1) end))
225 table.insert(globalkeys, key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end))
227 table.insert(globalkeys, key({ modkey }, "Tab", function () awful.client.focus.history.previous(); if client.focus then client.focus:raise() end end))
229 table.insert(globalkeys, key({ modkey }, "u", awful.client.urgent.jumpto))
231 -- Standard program
232 table.insert(globalkeys, key({ modkey }, "Return", function () awful.util.spawn(terminal) end))
234 table.insert(globalkeys, key({ modkey, "Control" }, "r", function ()
235 mypromptbox[mouse.screen].text =
236 awful.util.escape(awful.util.restart())
237 end))
238 table.insert(globalkeys, key({ modkey, "Shift" }, "q", awesome.quit))
240 -- Client manipulation
241 table.insert(clientkeys, key({ modkey }, "m", function (c) c.maximized_horizontal = not c.maximized_horizontal
242 c.maximized_vertical = not c.maximized_vertical end))
243 table.insert(clientkeys, key({ modkey }, "f", function (c) c.fullscreen = not c.fullscreen end))
244 table.insert(clientkeys, key({ modkey, "Shift" }, "c", function (c) c:kill() end))
245 table.insert(clientkeys, key({ modkey, "Control" }, "space", awful.client.floating.toggle))
246 table.insert(clientkeys, key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end))
247 table.insert(clientkeys, key({ modkey }, "o", awful.client.movetoscreen))
248 table.insert(clientkeys, key({ modkey, "Shift" }, "r", function (c) c:redraw() end))
250 -- Layout manipulation
251 table.insert(globalkeys, key({ modkey }, "l", function () awful.tag.incmwfact(0.05) end))
252 table.insert(globalkeys, key({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end))
253 table.insert(globalkeys, key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end))
254 table.insert(globalkeys, key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end))
255 table.insert(globalkeys, key({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end))
256 table.insert(globalkeys, key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end))
257 table.insert(globalkeys, key({ modkey }, "space", function () awful.layout.inc(layouts, 1) end))
258 table.insert(globalkeys, key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end))
260 -- Prompt
261 table.insert(globalkeys, key({ modkey }, "F1", function ()
262 awful.prompt.run({ prompt = "Run: " },
263 mypromptbox[mouse.screen],
264 awful.util.spawn, awful.completion.bash,
265 awful.util.getdir("cache") .. "/history")
266 end))
267 table.insert(globalkeys, key({ modkey }, "F4", function ()
268 awful.prompt.run({ prompt = "Run Lua code: " },
269 mypromptbox[mouse.screen],
270 awful.util.eval, awful.prompt.bash,
271 awful.util.getdir("cache") .. "/history_eval")
272 end))
274 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
275 table.insert(clientkeys, key({ modkey }, "t", awful.client.togglemarked))
277 for i = 1, keynumber do
278 table.insert(globalkeys, key({ modkey, "Shift" }, "F" .. i,
279 function ()
280 local screen = mouse.screen
281 if tags[screen][i] then
282 for k, c in pairs(awful.client.getmarked()) do
283 awful.client.movetotag(tags[screen][i], c)
286 end))
289 -- Set keys
290 root.keys(globalkeys)
291 -- }}}
293 -- {{{ Hooks
294 -- Hook function to execute when focusing a client.
295 awful.hooks.focus.register(function (c)
296 if not awful.client.ismarked(c) then
297 c.border_color = beautiful.border_focus
299 end)
301 -- Hook function to execute when unfocusing a client.
302 awful.hooks.unfocus.register(function (c)
303 if not awful.client.ismarked(c) then
304 c.border_color = beautiful.border_normal
306 end)
308 -- Hook function to execute when marking a client
309 awful.hooks.marked.register(function (c)
310 c.border_color = beautiful.border_marked
311 end)
313 -- Hook function to execute when unmarking a client.
314 awful.hooks.unmarked.register(function (c)
315 c.border_color = beautiful.border_focus
316 end)
318 -- Hook function to execute when the mouse enters a client.
319 awful.hooks.mouse_enter.register(function (c)
320 -- Sloppy focus, but disabled for magnifier layout
321 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
322 and awful.client.focus.filter(c) then
323 client.focus = c
325 end)
327 -- Hook function to execute when a new client appears.
328 awful.hooks.manage.register(function (c, startup)
329 -- If we are not managing this application at startup,
330 -- move it to the screen where the mouse is.
331 -- We only do it for filtered windows (i.e. no dock, etc).
332 if not startup and awful.client.focus.filter(c) then
333 c.screen = mouse.screen
336 if use_titlebar then
337 -- Add a titlebar
338 awful.titlebar.add(c, { modkey = modkey })
340 -- Add mouse bindings
341 c:buttons({
342 button({ }, 1, function (c) client.focus = c; c:raise() end),
343 button({ modkey }, 1, awful.mouse.client.move),
344 button({ modkey }, 3, awful.mouse.client.resize)
346 -- New client may not receive focus
347 -- if they're not focusable, so set border anyway.
348 c.border_width = beautiful.border_width
349 c.border_color = beautiful.border_normal
351 -- Check if the application should be floating.
352 local cls = c.class
353 local inst = c.instance
354 if floatapps[cls] then
355 awful.client.floating.set(c, floatapps[cls])
356 elseif floatapps[inst] then
357 awful.client.floating.set(c, floatapps[inst])
360 -- Check application->screen/tag mappings.
361 local target
362 if apptags[cls] then
363 target = apptags[cls]
364 elseif apptags[inst] then
365 target = apptags[inst]
367 if target then
368 c.screen = target.screen
369 awful.client.movetotag(tags[target.screen][target.tag], c)
372 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
373 client.focus = c
375 -- Set key bindings
376 c:keys(clientkeys)
378 -- Set the windows at the slave,
379 -- i.e. put it at the end of others instead of setting it master.
380 -- awful.client.setslave(c)
382 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
383 -- c.size_hints_honor = false
384 end)
386 -- Hook function to execute when arranging the screen.
387 -- (tag switch, new client, etc)
388 awful.hooks.arrange.register(function (screen)
389 local layout = awful.layout.getname(awful.layout.get(screen))
390 if layout and beautiful["layout_" ..layout] then
391 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
392 else
393 mylayoutbox[screen].image = nil
396 -- Give focus to the latest client in history if no window has focus
397 -- or if the current window is a desktop or a dock one.
398 if not client.focus then
399 local c = awful.client.focus.history.get(screen, 0)
400 if c then client.focus = c end
402 end)
404 -- Hook called every second
405 awful.hooks.timer.register(1, function ()
406 -- For unix time_t lovers
407 mytextbox.text = " " .. os.time() .. " time_t "
408 -- Otherwise use:
409 -- mytextbox.text = " " .. os.date() .. " "
410 end)
411 -- }}}