1 -- Standard awesome library
3 require("awful.autofocus")
5 -- Theme handling library
7 -- Notification library
10 -- require vicious widgets
13 -- Load Debian menu entries
14 require("debian.menu")
17 -- Check if awesome encountered an error during startup and fell back to
18 -- another config (This code will only ever execute for the fallback config)
19 if awesome.startup_errors then
20 naughty.notify({ preset = naughty.config.presets.critical,
21 title = "Oops, there were errors during startup!",
22 text = awesome.startup_errors })
25 -- Handle runtime errors after startup
27 local in_error = false
28 awesome.add_signal("debug::error", function (err)
29 -- Make sure we don't go into an endless error loop
30 if in_error then return end
33 naughty.notify({ preset = naughty.config.presets.critical,
34 title = "Oops, an error happened!",
42 -- {{{ Variable definitions
43 -- Themes define colours, icons, and wallpapers
44 -- beautiful.init("/usr/share/awesome/themes/default/theme.lua")
45 beautiful.init("/usr/share/awesome/themes/sky/theme.lua")
46 -- beautiful.init(os.getenv("HOME") .. "/.config/awesome/theme.lua")
48 -- This is used later as the default terminal and editor to run.
49 terminal = "x-terminal-emulator"
50 editor = os.getenv("EDITOR") or "editor"
51 editor_cmd = terminal .. " -e " .. editor
54 -- Usually, Mod4 is the key with a logo between Control and Alt.
55 -- If you do not like this or do not have such a key,
56 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
57 -- However, you can use another modifier like Mod1, but it may interact with others.
60 -- Table of layouts to cover with awful.layout.inc, order matters.
63 awful.layout.suit.tile,
64 -- awful.layout.suit.tile.left,
65 -- awful.layout.suit.tile.bottom,
66 -- awful.layout.suit.tile.top,
67 -- awful.layout.suit.fair,
68 -- awful.layout.suit.fair.horizontal,
69 -- awful.layout.suit.spiral,
70 -- awful.layout.suit.spiral.dwindle,
71 awful.layout.suit.max,
72 -- awful.layout.suit.max.fullscreen,
73 -- awful.layout.suit.magnifier,
74 awful.layout.suit.floating,
79 -- Define a tag table which hold all screen tags.
81 for s = 1, screen.count() do
82 -- Each screen has its own tag table.
83 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
88 -- Create a laucher widget and a main menu
90 { "manual", terminal .. " -e man awesome" },
91 { "edit config", editor_cmd .. " " .. awesome.conffile },
92 { "restart", awesome.restart },
93 { "quit", awesome.quit }
96 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
97 { "Debian", debian.menu.Debian_menu.Debian },
98 { "open terminal", terminal }
102 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
107 -- Create a textclock widget
108 mytextclock = awful.widget.textclock({ align = "right" })
111 mysystray = widget({ type = "systray" })
114 mycpuwidget = widget({ type = "textbox" })
116 vicious.register(mycpuwidget, vicious.widgets.cpu, "CPU:$1%")
118 mynetwidget = widget({ type = "textbox" })
119 vicious.register(mynetwidget, vicious.widgets.net, "${wlan23 up_kb}(OUT) ${wlan23 down_kb}(IN)", 1)
120 -- vicious.register(mynetwidget, vicious.widgets.net, "${wlan26 up_kb}(OUT) ${wlan26 down_kb}(IN)", 1)
122 spacer = widget({ type = "textbox"})
125 sep = widget({ type = "textbox"})
128 -- Create a wibox for each screen and add it
133 mytaglist.buttons = awful.util.table.join(
134 awful.button({ }, 1, awful.tag.viewonly),
135 awful.button({ modkey }, 1, awful.client.movetotag),
136 awful.button({ }, 3, awful.tag.viewtoggle),
137 awful.button({ modkey }, 3, awful.client.toggletag),
138 awful.button({ }, 4, awful.tag.viewnext),
139 awful.button({ }, 5, awful.tag.viewprev)
142 mytasklist.buttons = awful.util.table.join(
143 awful.button({ }, 1, function (c)
144 if c == client.focus then
147 if not c:isvisible() then
148 awful.tag.viewonly(c:tags()[1])
150 -- This will also un-minimize
151 -- the client, if needed
156 awful.button({ }, 3, function ()
161 instance = awful.menu.clients({ width=250 })
164 awful.button({ }, 4, function ()
165 awful.client.focus.byidx(1)
166 if client.focus then client.focus:raise() end
168 awful.button({ }, 5, function ()
169 awful.client.focus.byidx(-1)
170 if client.focus then client.focus:raise() end
173 for s = 1, screen.count() do
174 -- Create a promptbox for each screen
175 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
176 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
177 -- We need one layoutbox per screen.
178 mylayoutbox[s] = awful.widget.layoutbox(s)
179 mylayoutbox[s]:buttons(awful.util.table.join(
180 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
181 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
182 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
183 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
184 -- Create a taglist widget
185 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
187 -- Create a tasklist widget
188 mytasklist[s] = awful.widget.tasklist(function(c)
189 return awful.widget.tasklist.label.currenttags(c, s)
190 end, mytasklist.buttons)
193 mywibox[s] = awful.wibox({ position = "top", screen = s })
194 -- Add widgets to the wibox - order matters
195 mywibox[s].widgets = {
200 layout = awful.widget.layout.horizontal.leftright
204 s == 1 and mysystray or nil,
208 layout = awful.widget.layout.horizontal.rightleft
213 -- {{{ Mouse bindings
214 root.buttons(awful.util.table.join(
215 awful.button({ }, 3, function () mymainmenu:toggle() end),
216 awful.button({ }, 4, awful.tag.viewnext),
217 awful.button({ }, 5, awful.tag.viewprev)
222 globalkeys = awful.util.table.join(
223 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
224 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
225 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
227 awful.key({ modkey, }, "j",
229 awful.client.focus.byidx( 1)
230 if client.focus then client.focus:raise() end
232 awful.key({ modkey, }, "k",
234 awful.client.focus.byidx(-1)
235 if client.focus then client.focus:raise() end
237 awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
239 -- Layout manipulation
240 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
241 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
242 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
243 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
244 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
245 awful.key({ modkey, }, "Tab",
247 awful.client.focus.history.previous()
254 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
255 awful.key({ modkey, "Control" }, "r", awesome.restart),
256 awful.key({ modkey, "Shift" }, "q", awesome.quit),
258 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
259 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
260 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
261 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
262 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
263 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
264 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
265 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
267 awful.key({ modkey, "Control" }, "n", awful.client.restore),
270 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
272 awful.key({ modkey }, "x",
274 awful.prompt.run({ prompt = "Run in Terminal: " },
275 mypromptbox[mouse.screen].widget,
276 function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end) end),
278 awful.key({ modkey, "Shift"}, "x",
280 awful.prompt.run({ prompt = "Run Lua code: " },
281 mypromptbox[mouse.screen].widget,
282 awful.util.eval, nil,
283 awful.util.getdir("cache") .. "/history_eval")
286 -- key to make the 4 column setup for the big screen
287 awful.key({ modkey }, "q",
289 awful.tag.incnmaster(-1)
295 clientkeys = awful.util.table.join(
296 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
297 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
298 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
299 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
300 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
301 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
302 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
303 awful.key({ modkey, }, "n",
305 -- The client currently has the input focus, so it cannot be
306 -- minimized, since minimized clients can't have the focus.
309 awful.key({ modkey, }, "m",
311 c.maximized_horizontal = not c.maximized_horizontal
312 c.maximized_vertical = not c.maximized_vertical
316 -- Compute the maximum number of digit we need, limited to 9
318 for s = 1, screen.count() do
319 keynumber = math.min(9, math.max(#tags[s], keynumber));
322 -- Bind all key numbers to tags.
323 -- Be careful: we use keycodes to make it works on any keyboard layout.
324 -- This should map on the top row of your keyboard, usually 1 to 9.
325 for i = 1, keynumber do
326 globalkeys = awful.util.table.join(globalkeys,
327 awful.key({ modkey }, "#" .. i + 9,
329 local screen = mouse.screen
330 if tags[screen][i] then
331 awful.tag.viewonly(tags[screen][i])
334 awful.key({ modkey, "Control" }, "#" .. i + 9,
336 local screen = mouse.screen
337 if tags[screen][i] then
338 awful.tag.viewtoggle(tags[screen][i])
341 awful.key({ modkey, "Shift" }, "#" .. i + 9,
343 if client.focus and tags[client.focus.screen][i] then
344 awful.client.movetotag(tags[client.focus.screen][i])
347 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
349 if client.focus and tags[client.focus.screen][i] then
350 awful.client.toggletag(tags[client.focus.screen][i])
355 clientbuttons = awful.util.table.join(
356 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
357 awful.button({ modkey }, 1, awful.mouse.client.move),
358 awful.button({ modkey }, 3, awful.mouse.client.resize))
361 root.keys(globalkeys)
365 awful.rules.rules = {
366 -- All clients will match this rule.
368 properties = { border_width = beautiful.border_width,
369 border_color = beautiful.border_normal,
372 buttons = clientbuttons } },
373 { rule = { class = "MPlayer" },
374 properties = { floating = true } },
375 { rule = { class = "pinentry" },
376 properties = { floating = true } },
377 { rule = { class = "gimp" },
378 properties = { floating = true } },
379 -- Set Firefox to always map on tags number 2 of screen 1.
380 -- { rule = { class = "Iceweasel" },
381 -- properties = { tag = tags[1][3] } },
382 { rule = { name = "oli" },
383 properties = { tag = tags[1][9] } },
384 -- { rule = { name = "emacs" },
385 -- properties = { tag = tags[1][2] } },
386 { rule = { name = "tunnel" },
387 properties = { tag = tags[1][9] } },
392 -- Signal function to execute when a new client appears.
393 client.add_signal("manage", function (c, startup)
395 -- awful.titlebar.add(c, { modkey = modkey })
397 -- Enable sloppy focus
398 c:add_signal("mouse::enter", function(c)
399 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
400 and awful.client.focus.filter(c) then
406 -- Set the windows at the slave,
407 -- i.e. put it at the end of others instead of setting it master.
408 -- awful.client.setslave(c)
410 -- Put windows in a smart way, only if they does not set an initial position.
411 if not c.size_hints.user_position and not c.size_hints.program_position then
412 awful.placement.no_overlap(c)
413 awful.placement.no_offscreen(c)
418 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
419 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)