naughty: config.icon_size works now (FS#359)
[awesome.git] / awesomerc.lua.in
blobb5f927d03be92b773b63e710be417c1a384e4539
1 -- awesome 3 configuration file
3 -- Include awesome library, with lots of useful function!
4 require("awful")
5 require("beautiful")
7 -- {{{ Variable definitions
8 -- This is a file path to a theme file which will defines colors.
9 theme_path = "@AWESOME_THEMES_PATH@/default"
11 -- This is used later as the default terminal and editor to run.
12 terminal = "xterm"
13 editor = os.getenv("EDITOR") or "nano"
14 editor_cmd = terminal .. " -e " .. editor
16 -- Default modkey.
17 -- Usually, Mod4 is the key with a logo between Control and Alt.
18 -- If you do not like this or do not have such a key,
19 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
20 -- However, you can use another modifier like Mod1, but it may interact with others.
21 modkey = "Mod4"
23 -- Table of layouts to cover with awful.layout.inc, order matters.
24 layouts =
26 "tile",
27 "tileleft",
28 "tilebottom",
29 "tiletop",
30 "fairh",
31 "fairv",
32 "magnifier",
33 "max",
34 "fullscreen",
35 "spiral",
36 "dwindle",
37 "floating"
40 -- Table of clients that should be set floating. The index may be either
41 -- the application class or instance. The instance is useful when running
42 -- a console app in a terminal like (Music on Console)
43 -- xterm -name mocp -e mocp
44 floatapps =
46 -- by class
47 ["MPlayer"] = true,
48 ["pinentry"] = true,
49 ["gimp"] = true,
50 -- by instance
51 ["mocp"] = true
54 -- Applications to be moved to a pre-defined tag by class or instance.
55 -- Use the screen and tags indices.
56 apptags =
58 -- ["Firefox"] = { screen = 1, tag = 2 },
59 -- ["mocp"] = { screen = 2, tag = 4 },
62 -- Define if we want to use titlebar on all applications.
63 use_titlebar = false
64 -- }}}
66 -- {{{ Initialization
67 -- Initialize theme (colors).
68 beautiful.init(theme_path)
70 -- Register theme in awful.
71 -- This allows to not pass plenty of arguments to each function
72 -- to inform it about colors we want it to draw.
73 awful.beautiful.register(beautiful)
74 -- }}}
76 -- {{{ Tags
77 -- Define tags table.
78 tags = {}
79 for s = 1, screen.count() do
80 -- Each screen has its own tag table.
81 tags[s] = {}
82 -- Create 9 tags per screen.
83 for tagnumber = 1, 9 do
84 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
85 -- Add tags to screen one by one
86 tags[s][tagnumber].screen = s
87 end
88 -- I'm sure you want to see at least one tag.
89 tags[s][1].selected = true
90 end
91 -- }}}
93 -- {{{ Wibox
94 -- Create a textbox widget
95 mytextbox = widget({ type = "textbox", name = "mytextbox", align = "right" })
96 -- Set the default text in textbox
97 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
99 -- Create a laucher widget and a main menu
100 myawesomemenu = {
101 {"manual", terminal .. " -e man awesome" },
102 {"edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
103 {"restart", awesome.restart },
104 {"quit", awesome.quit }
107 mymainmenu = {
108 {"awesome", myawesomemenu, "@AWESOME_ICON_PATH@/awesome16.png" },
109 {"open terminal", terminal }
112 mylauncher = awful.widget.launcher({ name = "mylauncher",
113 image = "@AWESOME_ICON_PATH@/awesome16.png",
114 menu = { id="mymainmenu", items=mymainmenu, menu_toggle=true } })
116 -- Create a systray
117 mysystray = widget({ type = "systray", name = "mysystray", align = "right" })
119 -- Create a wibox for each screen and add it
120 mywibox = {}
121 mypromptbox = {}
122 mylayoutbox = {}
123 mytaglist = {}
124 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
125 button({ modkey }, 1, awful.client.movetotag),
126 button({ }, 3, function (tag) tag.selected = not tag.selected end),
127 button({ modkey }, 3, awful.client.toggletag),
128 button({ }, 4, awful.tag.viewnext),
129 button({ }, 5, awful.tag.viewprev) }
130 mytasklist = {}
131 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
132 button({ }, 3, function () awful.menu.clients({ width=250 }) end),
133 button({ }, 4, function () awful.client.focus.byidx(1) end),
134 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
136 for s = 1, screen.count() do
137 -- Create a promptbox for each screen
138 mypromptbox[s] = widget({ type = "textbox", name = "mypromptbox" .. s, align = "left" })
139 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
140 -- We need one layoutbox per screen.
141 mylayoutbox[s] = widget({ type = "imagebox", name = "mylayoutbox", align = "right" })
142 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
143 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
144 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
145 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
146 -- Create a taglist widget
147 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
149 -- Create a tasklist widget
150 mytasklist[s] = awful.widget.tasklist.new(function(c)
151 return awful.widget.tasklist.label.currenttags(c, s)
152 end, mytasklist.buttons)
154 -- Create the wibox
155 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
156 -- Add widgets to the wibox - order matters
157 mywibox[s].widgets = { mytaglist[s],
158 mylauncher,
159 mytasklist[s],
160 mypromptbox[s],
161 mytextbox,
162 mylayoutbox[s],
163 s == 1 and mysystray or nil }
164 mywibox[s].screen = s
166 -- }}}
168 -- {{{ Mouse bindings
169 awesome.buttons({
170 button({ }, 3, function () awful.menu.new({ id="mymainmenu", items=mymainmenu }) end),
171 button({ }, 4, awful.tag.viewnext),
172 button({ }, 5, awful.tag.viewprev)
174 -- }}}
176 -- {{{ Key bindings
178 -- Bind keyboard digits
179 -- Compute the maximum number of digit we need, limited to 9
180 keynumber = 0
181 for s = 1, screen.count() do
182 keynumber = math.min(9, math.max(#tags[s], keynumber));
185 for i = 1, keynumber do
186 keybinding({ modkey }, i,
187 function ()
188 local screen = mouse.screen
189 if tags[screen][i] then
190 awful.tag.viewonly(tags[screen][i])
192 end):add()
193 keybinding({ modkey, "Control" }, i,
194 function ()
195 local screen = mouse.screen
196 if tags[screen][i] then
197 tags[screen][i].selected = not tags[screen][i].selected
199 end):add()
200 keybinding({ modkey, "Shift" }, i,
201 function ()
202 if client.focus then
203 if tags[client.focus.screen][i] then
204 awful.client.movetotag(tags[client.focus.screen][i])
207 end):add()
208 keybinding({ modkey, "Control", "Shift" }, i,
209 function ()
210 if client.focus then
211 if tags[client.focus.screen][i] then
212 awful.client.toggletag(tags[client.focus.screen][i])
215 end):add()
218 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
219 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
220 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
222 -- Standard program
223 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
225 keybinding({ modkey, "Control" }, "r", function ()
226 mypromptbox[mouse.screen].text =
227 awful.util.escape(awful.util.restart())
228 end):add()
229 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
231 -- Client manipulation
232 keybinding({ modkey }, "m", awful.client.maximize):add()
233 keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
234 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
235 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
236 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
237 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap(1) end):add()
238 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
239 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
240 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
241 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
242 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.master()) end):add()
243 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
244 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
245 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
246 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
248 -- Layout manipulation
249 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
250 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
251 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
252 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
253 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
254 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
255 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
256 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
258 -- Prompt
259 keybinding({ modkey }, "F1", function ()
260 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
261 awful.util.getdir("cache") .. "/history")
262 end):add()
263 keybinding({ modkey }, "F4", function ()
264 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
265 awful.util.getdir("cache") .. "/history_eval")
266 end):add()
268 keybinding({ modkey, "Ctrl" }, "i", function ()
269 local s = mouse.screen
270 if mypromptbox[s].text then
271 mypromptbox[s].text = nil
272 else
273 mypromptbox[s].text = nil
274 if client.focus.class then
275 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
277 if client.focus.instance then
278 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
280 if client.focus.role then
281 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
284 end):add()
286 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
287 keybinding({ modkey }, "t", awful.client.togglemarked):add()
289 for i = 1, keynumber do
290 keybinding({ modkey, "Shift" }, "F" .. i,
291 function ()
292 local screen = mouse.screen
293 if tags[screen][i] then
294 for k, c in pairs(awful.client.getmarked()) do
295 awful.client.movetotag(tags[screen][i], c)
298 end):add()
300 -- }}}
302 -- {{{ Hooks
303 -- Hook function to execute when focusing a client.
304 awful.hooks.focus.register(function (c)
305 if not awful.client.ismarked(c) then
306 c.border_color = beautiful.border_focus
308 end)
310 -- Hook function to execute when unfocusing a client.
311 awful.hooks.unfocus.register(function (c)
312 if not awful.client.ismarked(c) then
313 c.border_color = beautiful.border_normal
315 end)
317 -- Hook function to execute when marking a client
318 awful.hooks.marked.register(function (c)
319 c.border_color = beautiful.border_marked
320 end)
322 -- Hook function to execute when unmarking a client.
323 awful.hooks.unmarked.register(function (c)
324 c.border_color = beautiful.border_focus
325 end)
327 -- Hook function to execute when the mouse enters a client.
328 awful.hooks.mouse_enter.register(function (c)
329 -- Sloppy focus, but disabled for magnifier layout
330 if awful.layout.get(c.screen) ~= "magnifier"
331 and awful.client.focus.filter(c) then
332 client.focus = c
334 end)
336 -- Hook function to execute when a new client appears.
337 awful.hooks.manage.register(function (c)
338 if use_titlebar then
339 -- Add a titlebar
340 awful.titlebar.add(c, { modkey = modkey })
342 -- Add mouse bindings
343 c:buttons({
344 button({ }, 1, function (c) client.focus = c; c:raise() end),
345 button({ modkey }, 1, function (c) c:mouse_move() end),
346 button({ modkey }, 3, function (c) c:mouse_resize() end)
348 -- New client may not receive focus
349 -- if they're not focusable, so set border anyway.
350 c.border_width = beautiful.border_width
351 c.border_color = beautiful.border_normal
352 client.focus = c
354 -- Check if the application should be floating.
355 local cls = c.class
356 local inst = c.instance
357 if floatapps[cls] then
358 c.floating = floatapps[cls]
359 elseif floatapps[inst] then
360 c.floating = floatapps[inst]
363 -- Check application->screen/tag mappings.
364 local target
365 if apptags[cls] then
366 target = apptags[cls]
367 elseif apptags[inst] then
368 target = apptags[inst]
370 if target then
371 c.screen = target.screen
372 awful.client.movetotag(tags[target.screen][target.tag], c)
375 -- Set the windows at the slave,
376 -- i.e. put it at the end of others instead of setting it master.
377 -- awful.client.setslave(c)
379 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
380 -- c.honorsizehints = false
381 end)
383 -- Hook function to execute when arranging the screen.
384 -- (tag switch, new client, etc)
385 awful.hooks.arrange.register(function (screen)
386 local layout = awful.layout.get(screen)
387 if layout then
388 mylayoutbox[screen].image = image("@AWESOME_ICON_PATH@/layouts/" .. layout .. "w.png")
389 else
390 mylayoutbox[screen].image = nil
393 -- Give focus to the latest client in history if no window has focus
394 -- or if the current window is a desktop or a dock one.
395 if not client.focus then
396 local c = awful.client.focus.history.get(screen, 0)
397 if c then client.focus = c end
400 -- Uncomment if you want mouse warping
401 --[[
402 if client.focus then
403 local c_c = client.focus:fullgeometry()
404 local m_c = mouse.coords()
406 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
407 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
408 if table.maxn(m_c.buttons) == 0 then
409 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
414 end)
416 -- Hook called every second
417 awful.hooks.timer.register(1, function ()
418 -- For unix time_t lovers
419 mytextbox.text = " " .. os.time() .. " time_t "
420 -- Otherwise use:
421 -- mytextbox.text = " " .. os.date() .. " "
422 end)
423 -- }}}