1 -- Standard awesome library
3 -- Theme handling library
5 -- Notification library
8 -- Load Debian menu entries
11 -- {{{ Variable definitions
12 -- Themes define colours, icons, and wallpapers
13 -- The default is a dark theme
14 theme_path = "/usr/share/awesome/themes/default/theme.lua"
15 -- Uncommment this for a lighter theme
16 -- theme_path = "/usr/share/awesome/themes/sky/theme.lua"
18 -- Actually load theme
19 beautiful.init(theme_path)
21 -- This is used later as the default terminal and editor to run.
22 terminal = "x-terminal-emulator"
23 editor = os.getenv("EDITOR") or "editor"
24 editor_cmd = terminal .. " -e " .. editor
27 -- Usually, Mod4 is the key with a logo between Control and Alt.
28 -- If you do not like this or do not have such a key,
29 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
30 -- However, you can use another modifier like Mod1, but it may interact with others.
33 -- Table of layouts to cover with awful.layout.inc, order matters.
36 awful.layout.suit.tile,
37 awful.layout.suit.tile.left,
38 awful.layout.suit.tile.bottom,
39 awful.layout.suit.tile.top,
40 awful.layout.suit.fair,
41 awful.layout.suit.fair.horizontal,
42 awful.layout.suit.max,
43 awful.layout.suit.max.fullscreen,
44 awful.layout.suit.magnifier,
45 awful.layout.suit.floating
48 -- Table of clients that should be set floating. The index may be either
49 -- the application class or instance. The instance is useful when running
50 -- a console app in a terminal like (Music on Console)
51 -- x-terminal-emulator -name mocp -e mocp
62 -- Applications to be moved to a pre-defined tag by class or instance.
63 -- Use the screen and tags indices.
66 -- ["Firefox"] = { screen = 1, tag = 2 },
67 -- ["mocp"] = { screen = 2, tag = 4 },
70 -- Define if we want to use titlebar on all applications.
77 for s = 1, screen.count() do
78 -- Each screen has its own tag table.
80 -- Create 9 tags per screen.
81 for tagnumber = 1, 9 do
82 tags[s][tagnumber] = tag(tagnumber)
83 -- Add tags to screen one by one
84 tags[s][tagnumber].screen = s
85 awful.layout.set(layouts[1], tags[s][tagnumber])
87 -- I'm sure you want to see at least one tag.
88 tags[s][1].selected = true
93 -- Create a textbox widget
94 mytextbox = widget({ type = "textbox", align = "right" })
95 -- Set the default text in textbox
96 mytextbox.text = "<b><small> " .. awesome.release .. " </small></b>"
98 -- Create a laucher widget and a main menu
100 { "manual", terminal .. " -e man awesome" },
101 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
102 { "restart", awesome.restart },
103 { "quit", awesome.quit }
106 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
107 { "open terminal", terminal },
108 { "Debian", debian.menu.Debian_menu.Debian }
112 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
116 mysystray = widget({ type = "systray", align = "right" })
118 -- Create a wibox for each screen and add it
123 mytaglist.buttons = awful.util.table.join(
124 awful.button({ }, 1, awful.tag.viewonly),
125 awful.button({ modkey }, 1, awful.client.movetotag),
126 awful.button({ }, 3, function (tag) tag.selected = not tag.selected end),
127 awful.button({ modkey }, 3, awful.client.toggletag),
128 awful.button({ }, 4, awful.tag.viewnext),
129 awful.button({ }, 5, awful.tag.viewprev)
132 mytasklist.buttons = awful.util.table.join(
133 awful.button({ }, 1, function (c)
134 if not c:isvisible() then
135 awful.tag.viewonly(c:tags()[1])
140 awful.button({ }, 3, function ()
145 instance = awful.menu.clients({ width=250 })
148 awful.button({ }, 4, function ()
149 awful.client.focus.byidx(1)
150 if client.focus then client.focus:raise() end
152 awful.button({ }, 5, function ()
153 awful.client.focus.byidx(-1)
154 if client.focus then client.focus:raise() end
157 for s = 1, screen.count() do
158 -- Create a promptbox for each screen
159 mypromptbox[s] = awful.widget.prompt({ align = "left" })
160 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
161 -- We need one layoutbox per screen.
162 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
163 mylayoutbox[s]:buttons(awful.util.table.join(
164 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
165 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
166 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
167 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
168 -- Create a taglist widget
169 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
171 -- Create a tasklist widget
172 mytasklist[s] = awful.widget.tasklist(function(c)
173 return awful.widget.tasklist.label.currenttags(c, s)
174 end, mytasklist.buttons)
177 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
178 -- Add widgets to the wibox - order matters
179 mywibox[s].widgets = { mylauncher,
185 s == 1 and mysystray or nil }
186 mywibox[s].screen = s
190 -- {{{ Mouse bindings
191 root.buttons(awful.util.table.join(
192 awful.button({ }, 3, function () mymainmenu:toggle() end),
193 awful.button({ }, 4, awful.tag.viewnext),
194 awful.button({ }, 5, awful.tag.viewprev)
199 globalkeys = awful.util.table.join(
200 -- awful.key({ modkey, }, "Left", awful.tag.viewprev ),
201 -- awful.key({ modkey, }, "Right", awful.tag.viewnext ),
202 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
204 awful.key({ modkey, }, "j",
206 awful.client.focus.byidx( 1)
207 if client.focus then client.focus:raise() end
209 awful.key({ modkey, }, "k",
211 awful.client.focus.byidx(-1)
212 if client.focus then client.focus:raise() end
214 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
216 -- Layout manipulation
217 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
218 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
219 awful.key({ modkey, }, "Left", function () awful.screen.focus( 1) end),
220 awful.key({ modkey, }, "Right", function () awful.screen.focus(-1) end),
221 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
222 awful.key({ modkey, }, "Tab",
224 awful.client.focus.history.previous()
231 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
232 awful.key({ modkey, "Control", "Shift" }, "r", awesome.restart),
233 awful.key({ modkey, "Control", "Shift" }, "q", awesome.quit),
235 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
236 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
237 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
238 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
239 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
240 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
241 awful.key({ modkey, }, "n", function () awful.layout.inc(layouts, 1) end),
242 awful.key({ modkey, "Shift" }, "n", function () awful.layout.inc(layouts, -1) end),
245 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
247 awful.key({ modkey }, "x",
249 awful.prompt.run({ prompt = "Run Lua code: " },
250 mypromptbox[mouse.screen].widget,
251 awful.util.eval, nil,
252 awful.util.getdir("cache") .. "/history_eval")
256 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
257 clientkeys = awful.util.table.join(
258 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
259 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
260 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
261 awful.key({ modkey, }, "space", function (c) c:swap(awful.client.getmaster()) end),
262 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
263 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
264 awful.key({ modkey }, "t", awful.client.togglemarked),
265 awful.key({ modkey,}, "m",
267 c.maximized_horizontal = not c.maximized_horizontal
268 c.maximized_vertical = not c.maximized_vertical
272 -- Compute the maximum number of digit we need, limited to 9
274 for s = 1, screen.count() do
275 keynumber = math.min(9, math.max(#tags[s], keynumber));
278 for i = 1, keynumber do
279 globalkeys = awful.util.table.join(globalkeys,
280 awful.key({ modkey }, i,
282 local screen = mouse.screen
283 if tags[screen][i] then
284 awful.tag.viewonly(tags[screen][i])
287 awful.key({ modkey, "Control" }, i,
289 local screen = mouse.screen
290 if tags[screen][i] then
291 tags[screen][i].selected = not tags[screen][i].selected
294 awful.key({ modkey, "Shift" }, i,
296 if client.focus and tags[client.focus.screen][i] then
297 awful.client.movetotag(tags[client.focus.screen][i])
300 awful.key({ modkey, "Control", "Shift" }, i,
302 if client.focus and tags[client.focus.screen][i] then
303 awful.client.toggletag(tags[client.focus.screen][i])
306 awful.key({ modkey, "Shift" }, "F" .. i,
308 local screen = mouse.screen
309 if tags[screen][i] then
310 for k, c in pairs(awful.client.getmarked()) do
311 awful.client.movetotag(tags[screen][i], c)
318 root.keys(globalkeys)
322 -- Hook function to execute when focusing a client.
323 awful.hooks.focus.register(function (c)
324 if not awful.client.ismarked(c) then
325 c.border_color = beautiful.border_focus
329 -- Hook function to execute when unfocusing a client.
330 awful.hooks.unfocus.register(function (c)
331 if not awful.client.ismarked(c) then
332 c.border_color = beautiful.border_normal
336 -- Hook function to execute when marking a client
337 awful.hooks.marked.register(function (c)
338 c.border_color = beautiful.border_marked
341 -- Hook function to execute when unmarking a client.
342 awful.hooks.unmarked.register(function (c)
343 c.border_color = beautiful.border_focus
346 -- Hook function to execute when the mouse enters a client.
347 awful.hooks.mouse_enter.register(function (c)
348 -- Sloppy focus, but disabled for magnifier layout
349 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
350 and awful.client.focus.filter(c) then
355 -- Hook function to execute when a new client appears.
356 awful.hooks.manage.register(function (c, startup)
357 -- If we are not managing this application at startup,
358 -- move it to the screen where the mouse is.
359 -- We only do it for filtered windows (i.e. no dock, etc).
360 if not startup and awful.client.focus.filter(c) then
361 c.screen = mouse.screen
366 awful.titlebar.add(c, { modkey = modkey })
368 -- Add mouse bindings
369 c:buttons(awful.util.table.join(
370 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
371 awful.button({ modkey }, 1, awful.mouse.client.move),
372 awful.button({ modkey }, 3, awful.mouse.client.resize)
374 -- New client may not receive focus
375 -- if they're not focusable, so set border anyway.
376 c.border_width = beautiful.border_width
377 c.border_color = beautiful.border_normal
379 -- Check if the application should be floating.
381 local inst = c.instance
382 if floatapps[cls] ~= nil then
383 awful.client.floating.set(c, floatapps[cls])
384 elseif floatapps[inst] ~= nil then
385 awful.client.floating.set(c, floatapps[inst])
388 -- Check application->screen/tag mappings.
391 target = apptags[cls]
392 elseif apptags[inst] then
393 target = apptags[inst]
396 c.screen = target.screen
397 awful.client.movetotag(tags[target.screen][target.tag], c)
400 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
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 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
411 -- c.size_hints_honor = false
414 -- Hook function to execute when arranging the screen.
415 -- (tag switch, new client, etc)
416 awful.hooks.arrange.register(function (screen)
417 local layout = awful.layout.getname(awful.layout.get(screen))
418 if layout and beautiful["layout_" ..layout] then
419 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
421 mylayoutbox[screen].image = nil
424 -- Give focus to the latest client in history if no window has focus
425 -- or if the current window is a desktop or a dock one.
426 if not client.focus then
427 local c = awful.client.focus.history.get(screen, 0)
428 if c then client.focus = c end
432 -- Hook called every minute
433 awful.hooks.timer.register(60, function ()
434 mytextbox.text = os.date(" %c ")