1 -- Standard awesome library
3 -- Theme handling library
5 -- Notification library
8 -- require vicious widgets
11 -- Load Debian menu entries
12 require("debian.menu")
14 -- {{{ Variable definitions
15 -- Themes define colours, icons, and wallpapers
16 -- The default is a dark theme
17 theme_path = "/usr/share/awesome/themes/default/theme.lua"
18 -- theme.wallpaper_cmd = { "awsetbg /usr/share/pixmaps/backgrounds/gnome/nature/GreenMeadow.jpg" }
20 -- Uncommment this for a lighter theme
21 -- theme_path = "/usr/share/awesome/themes/sky/theme.lua"
23 -- Actually load theme
24 beautiful.init(theme_path)
26 -- This is used later as the default terminal and editor to run.
27 terminal = "x-terminal-emulator"
28 editor = os.getenv("EDITOR") or "editor"
29 editor_cmd = terminal .. " -e " .. editor
32 -- Usually, Mod4 is the key with a logo between Control and Alt.
33 -- If you do not like this or do not have such a key,
34 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
35 -- However, you can use another modifier like Mod1, but it may interact with others.
38 -- Table of layouts to cover with awful.layout.inc, order matters.
41 awful.layout.suit.tile,
42 awful.layout.suit.tile.left,
43 awful.layout.suit.tile.bottom,
44 awful.layout.suit.tile.top,
45 awful.layout.suit.fair,
46 awful.layout.suit.fair.horizontal,
47 awful.layout.suit.max,
48 awful.layout.suit.max.fullscreen,
49 awful.layout.suit.magnifier,
50 awful.layout.suit.floating
53 -- Table of clients that should be set floating. The index may be either
54 -- the application class or instance. The instance is useful when running
55 -- a console app in a terminal like (Music on Console)
56 -- x-terminal-emulator -name mocp -e mocp
67 -- Applications to be moved to a pre-defined tag by class or instance.
68 -- Use the screen and tags indices.
71 ["Firefox"] = { screen = 1, tag = 3 },
72 ["/home/mako/bin/tunnel"] = { screen = 0, tag = 9 }
73 -- ["mocp"] = { screen = 2, tag = 4 },
76 -- Define if we want to use titlebar on all applications.
83 for s = 1, screen.count() do
84 -- Each screen has its own tag table.
86 -- Create 9 tags per screen.
87 for tagnumber = 1, 9 do
88 tags[s][tagnumber] = tag(tagnumber)
89 -- Add tags to screen one by one
90 tags[s][tagnumber].screen = s
91 awful.layout.set(layouts[1], tags[s][tagnumber])
93 -- I'm sure you want to see at least one tag.
94 tags[s][1].selected = true
99 -- Create a textbox widget
100 mytextbox = widget({ type = "textbox", align = "right" })
101 -- Set the default text in textbox
102 mytextbox.text = "<b><small> " .. awesome.release .. " </small></b>"
104 -- Create a laucher widget and a main menu
106 { "manual", terminal .. " -e man awesome" },
107 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
108 { "restart", awesome.restart },
109 { "quit", awesome.quit }
112 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
113 { "open terminal", terminal },
114 { "Debian", debian.menu.Debian_menu.Debian }
118 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
122 mysystray = widget({ type = "systray", align = "right" })
124 -- Create a wibox for each screen and add it
129 mytaglist.buttons = awful.util.table.join(
130 awful.button({ }, 1, awful.tag.viewonly),
131 awful.button({ modkey }, 1, awful.client.movetotag),
132 awful.button({ }, 3, function (tag) tag.selected = not tag.selected end),
133 awful.button({ modkey }, 3, awful.client.toggletag),
134 awful.button({ }, 4, awful.tag.viewnext),
135 awful.button({ }, 5, awful.tag.viewprev)
138 mytasklist.buttons = awful.util.table.join(
139 awful.button({ }, 1, function (c)
140 if not c:isvisible() then
141 awful.tag.viewonly(c:tags()[1])
146 awful.button({ }, 3, function ()
151 instance = awful.menu.clients({ width=250 })
154 awful.button({ }, 4, function ()
155 awful.client.focus.byidx(1)
156 if client.focus then client.focus:raise() end
158 awful.button({ }, 5, function ()
159 awful.client.focus.byidx(-1)
160 if client.focus then client.focus:raise() end
163 for s = 1, screen.count() do
164 -- Create a promptbox for each screen
165 mypromptbox[s] = awful.widget.prompt({ align = "left" })
166 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
167 -- We need one layoutbox per screen.
168 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
169 mylayoutbox[s]:buttons(awful.util.table.join(
170 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
171 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
172 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
173 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
174 -- Create a taglist widget
175 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
177 -- Create a tasklist widget
178 mytasklist[s] = awful.widget.tasklist(function(c)
179 return awful.widget.tasklist.label.currenttags(c, s)
180 end, mytasklist.buttons)
183 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
184 -- Add widgets to the wibox - order matters
185 mywibox[s].widgets = { mylauncher,
191 s == 1 and mysystray or nil }
192 mywibox[s].screen = s
196 -- {{{ Mouse bindings
197 root.buttons(awful.util.table.join(
198 awful.button({ }, 3, function () mymainmenu:toggle() end),
199 awful.button({ }, 4, awful.tag.viewnext),
200 awful.button({ }, 5, awful.tag.viewprev)
205 globalkeys = awful.util.table.join(
206 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
207 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
208 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
210 awful.key({ modkey, }, "j",
212 awful.client.focus.byidx( 1)
213 if client.focus then client.focus:raise() end
215 awful.key({ modkey, }, "k",
217 awful.client.focus.byidx(-1)
218 if client.focus then client.focus:raise() end
220 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
222 -- Layout manipulation
223 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
224 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
225 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus( 1) end),
226 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end),
227 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
228 awful.key({ modkey, }, "Tab",
230 awful.client.focus.history.previous()
237 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
238 awful.key({ modkey, "Control" }, "r", awesome.restart),
239 awful.key({ modkey, "Shift" }, "q", awesome.quit),
241 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
242 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
243 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
244 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
245 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
246 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
247 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
248 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
251 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
253 awful.key({ modkey }, "x",
255 awful.prompt.run({ prompt = "Run in Terminal: " },
256 mypromptbox[mouse.screen].widget,
257 function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end) end),
260 awful.key({ modkey, "Shift" }, "x",
262 awful.prompt.run({ prompt = "Run Lua code: " },
263 mypromptbox[mouse.screen].widget,
264 awful.util.eval, nil,
265 awful.util.getdir("cache") .. "/history_eval")
270 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
271 clientkeys = awful.util.table.join(
272 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
273 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
274 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
275 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
276 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
277 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
278 awful.key({ modkey }, "t", awful.client.togglemarked),
279 awful.key({ modkey,}, "m",
281 c.maximized_horizontal = not c.maximized_horizontal
282 c.maximized_vertical = not c.maximized_vertical
286 -- Compute the maximum number of digit we need, limited to 9
288 for s = 1, screen.count() do
289 keynumber = math.min(9, math.max(#tags[s], keynumber));
292 for i = 1, keynumber do
293 globalkeys = awful.util.table.join(globalkeys,
294 awful.key({ modkey }, i,
296 local screen = mouse.screen
297 if tags[screen][i] then
298 awful.tag.viewonly(tags[screen][i])
301 awful.key({ modkey, "Control" }, i,
303 local screen = mouse.screen
304 if tags[screen][i] then
305 tags[screen][i].selected = not tags[screen][i].selected
308 awful.key({ modkey, "Shift" }, i,
310 if client.focus and tags[client.focus.screen][i] then
311 awful.client.movetotag(tags[client.focus.screen][i])
314 awful.key({ modkey, "Control", "Shift" }, i,
316 if client.focus and tags[client.focus.screen][i] then
317 awful.client.toggletag(tags[client.focus.screen][i])
320 awful.key({ modkey, "Shift" }, "F" .. i,
322 local screen = mouse.screen
323 if tags[screen][i] then
324 for k, c in pairs(awful.client.getmarked()) do
325 awful.client.movetotag(tags[screen][i], c)
332 root.keys(globalkeys)
336 -- Hook function to execute when focusing a client.
337 awful.hooks.focus.register(function (c)
338 if not awful.client.ismarked(c) then
339 c.border_color = beautiful.border_focus
343 -- Hook function to execute when unfocusing a client.
344 awful.hooks.unfocus.register(function (c)
345 if not awful.client.ismarked(c) then
346 c.border_color = beautiful.border_normal
350 -- Hook function to execute when marking a client
351 awful.hooks.marked.register(function (c)
352 c.border_color = beautiful.border_marked
355 -- Hook function to execute when unmarking a client.
356 awful.hooks.unmarked.register(function (c)
357 c.border_color = beautiful.border_focus
360 -- Hook function to execute when the mouse enters a client.
361 awful.hooks.mouse_enter.register(function (c)
362 -- Sloppy focus, but disabled for magnifier layout
363 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
364 and awful.client.focus.filter(c) then
369 -- Hook function to execute when a new client appears.
370 awful.hooks.manage.register(function (c, startup)
371 -- If we are not managing this application at startup,
372 -- move it to the screen where the mouse is.
373 -- We only do it for filtered windows (i.e. no dock, etc).
374 if not startup and awful.client.focus.filter(c) then
375 c.screen = mouse.screen
380 awful.titlebar.add(c, { modkey = modkey })
382 -- Add mouse bindings
383 c:buttons(awful.util.table.join(
384 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
385 awful.button({ modkey }, 1, awful.mouse.client.move),
386 awful.button({ modkey }, 3, awful.mouse.client.resize)
388 -- New client may not receive focus
389 -- if they're not focusable, so set border anyway.
390 c.border_width = beautiful.border_width
391 c.border_color = beautiful.border_normal
393 -- Check if the application should be floating.
395 local inst = c.instance
396 if floatapps[cls] ~= nil then
397 awful.client.floating.set(c, floatapps[cls])
398 elseif floatapps[inst] ~= nil then
399 awful.client.floating.set(c, floatapps[inst])
402 -- Check application->screen/tag mappings.
405 target = apptags[cls]
406 elseif apptags[inst] then
407 target = apptags[inst]
410 c.screen = target.screen
411 awful.client.movetotag(tags[target.screen][target.tag], c)
414 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
420 -- Set the windows at the slave,
421 -- i.e. put it at the end of others instead of setting it master.
422 -- awful.client.setslave(c)
424 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
425 -- c.size_hints_honor = false
428 -- Hook function to execute when arranging the screen.
429 -- (tag switch, new client, etc)
430 awful.hooks.arrange.register(function (screen)
431 local layout = awful.layout.getname(awful.layout.get(screen))
432 if layout and beautiful["layout_" ..layout] then
433 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
435 mylayoutbox[screen].image = nil
438 -- Give focus to the latest client in history if no window has focus
439 -- or if the current window is a desktop or a dock one.
440 if not client.focus then
441 local c = awful.client.focus.history.get(screen, 0)
442 if c then client.focus = c end
446 -- Hook called every minute
447 awful.hooks.timer.register(60, function ()
448 mytextbox.text = os.date(" %a %b %d, %H:%M ")
452 awful.util.spawn_with_shell("awsetbg /usr/share/pixmaps/backgrounds/gnome/nature/GreenMeadow.jpg")