1 -- Standard awesome library
3 require("awful.autofocus")
5 -- Theme handling library
7 -- Notification library
10 -- Load Debian menu entries
11 require("debian.menu")
13 -- {{{ Variable definitions
14 -- Themes define colours, icons, and wallpapers
15 beautiful.init("/usr/share/awesome/themes/sky/theme.lua")
16 -- beautiful.init("/usr/share/awesome/themes/default/theme.lua")
18 -- This is used later as the default terminal and editor to run.
19 terminal = "x-terminal-emulator"
20 editor = os.getenv("EDITOR") or "editor"
21 editor_cmd = terminal .. " -e " .. editor
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.
31 require('delightful.widgets.battery')
32 require('delightful.widgets.cpu')
33 require('delightful.widgets.datetime')
34 require('delightful.widgets.memory')
35 require('delightful.widgets.network')
36 require('delightful.widgets.pulseaudio')
38 -- Which widgets to install?
39 -- This is the order the widgets appear in the wibox.
40 install_delightful = {
41 delightful.widgets.battery,
42 delightful.widgets.network,
43 delightful.widgets.cpu,
44 delightful.widgets.memory,
45 -- delightful.widgets.pulseaudio,
46 delightful.widgets.datetime
49 -- Widget configuration
51 [delightful.widgets.network] = {
52 excluded_devices = { '^lo.*$' },
54 [delightful.widgets.cpu] = {
55 command = 'gnome-system-monitor',
57 [delightful.widgets.memory] = {
58 command = 'gnome-system-monitor',
60 [delightful.widgets.battery] = {
63 -- [delightful.widgets.pulseaudio] = {
64 -- mixer_command = 'gnome-volume-control',
68 -- Prepare the container that is used when constructing the wibox
69 local delightful_container = { widgets = {}, icons = {} }
70 if install_delightful then
71 for _, widget in pairs(awful.util.table.reverse(install_delightful)) do
72 local config = delightful_config and delightful_config[widget]
73 local widgets, icons = widget:load(config)
78 table.insert(delightful_container.widgets, awful.util.table.reverse(widgets))
79 table.insert(delightful_container.icons, awful.util.table.reverse(icons))
84 -- Table of layouts to cover with awful.layout.inc, order matters.
87 awful.layout.suit.tile,
88 awful.layout.suit.max,
89 awful.layout.suit.floating
94 -- Define a tag table which hold all screen tags.
96 for s = 1, screen.count() do
97 -- Each screen has its own tag table.
98 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
103 -- Create a laucher widget and a main menu
105 { "manual", terminal .. " -e man awesome" },
106 { "edit config", editor_cmd .. " " .. awesome.conffile },
107 { "restart", awesome.restart },
108 { "quit", awesome.quit }
111 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
112 { "Debian", debian.menu.Debian_menu.Debian },
113 { "open terminal", terminal }
117 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
122 -- Create a textclock widget
123 mytextclock = awful.widget.textclock({ align = "right" })
126 mysystray = widget({ type = "systray" })
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 local widgets_front = {
200 layout = awful.widget.layout.horizontal.leftright
204 local widgets_middle = {}
205 for delightful_container_index, delightful_container_data in pairs(delightful_container.widgets) do
206 for widget_index, widget_data in pairs(delightful_container_data) do
207 table.insert(widgets_middle, widget_data)
208 if delightful_container.icons[delightful_container_index] and delightful_container.icons[delightful_container_index][widget_index] then
209 table.insert(widgets_middle, delightful_container.icons[delightful_container_index][widget_index])
213 local widgets_end = {
214 s == 1 and mysystray or nil,
216 layout = awful.widget.layout.horizontal.rightleft
218 mywibox[s].widgets = awful.util.table.join(widgets_front, widgets_middle, widgets_end)
222 -- {{{ Mouse bindings
223 root.buttons(awful.util.table.join(
224 awful.button({ }, 3, function () mymainmenu:toggle() end),
225 awful.button({ }, 4, awful.tag.viewnext),
226 awful.button({ }, 5, awful.tag.viewprev)
231 globalkeys = awful.util.table.join(
232 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
233 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
234 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
236 awful.key({ modkey, }, "j",
238 awful.client.focus.byidx( 1)
239 if client.focus then client.focus:raise() end
241 awful.key({ modkey, }, "k",
243 awful.client.focus.byidx(-1)
244 if client.focus then client.focus:raise() end
246 awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
248 -- Layout manipulation
249 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
250 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
251 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
252 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
253 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
254 awful.key({ modkey, }, "Tab",
256 awful.client.focus.history.previous()
263 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
264 awful.key({ modkey, "Control" }, "r", awesome.restart),
265 awful.key({ modkey, "Shift" }, "q", awesome.quit),
267 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
268 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
269 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
270 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
271 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
272 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
273 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
274 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
276 awful.key({ modkey, "Control" }, "n", awful.client.restore),
279 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
281 awful.key({ modkey }, "x",
283 awful.prompt.run({ prompt = "Run in Terminal: " },
284 mypromptbox[mouse.screen].widget,
285 function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end) end),
287 awful.key({ modkey, "Shift" }, "x",
289 awful.prompt.run({ prompt = "Run Lua code: " },
290 mypromptbox[mouse.screen].widget,
291 awful.util.eval, nil,
292 awful.util.getdir("cache") .. "/history_eval")
294 awful.key({ modkey }, "q",
296 awful.tag.incnmaster(-1)
301 clientkeys = awful.util.table.join(
302 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
303 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
304 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
305 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
306 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
307 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
308 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
309 awful.key({ modkey, }, "n",
311 -- The client currently has the input focus, so it cannot be
312 -- minimized, since minimized clients can't have the focus.
315 awful.key({ modkey, }, "m",
317 c.maximized_horizontal = not c.maximized_horizontal
318 c.maximized_vertical = not c.maximized_vertical
322 -- Compute the maximum number of digit we need, limited to 9
324 for s = 1, screen.count() do
325 keynumber = math.min(9, math.max(#tags[s], keynumber));
328 -- Bind all key numbers to tags.
329 -- Be careful: we use keycodes to make it works on any keyboard layout.
330 -- This should map on the top row of your keyboard, usually 1 to 9.
331 for i = 1, keynumber do
332 globalkeys = awful.util.table.join(globalkeys,
333 awful.key({ modkey }, "#" .. i + 9,
335 local screen = mouse.screen
336 if tags[screen][i] then
337 awful.tag.viewonly(tags[screen][i])
340 awful.key({ modkey, "Control" }, "#" .. i + 9,
342 local screen = mouse.screen
343 if tags[screen][i] then
344 awful.tag.viewtoggle(tags[screen][i])
347 awful.key({ modkey, "Shift" }, "#" .. i + 9,
349 if client.focus and tags[client.focus.screen][i] then
350 awful.client.movetotag(tags[client.focus.screen][i])
353 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
355 if client.focus and tags[client.focus.screen][i] then
356 awful.client.toggletag(tags[client.focus.screen][i])
361 clientbuttons = awful.util.table.join(
362 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
363 awful.button({ modkey }, 1, awful.mouse.client.move),
364 awful.button({ modkey }, 3, awful.mouse.client.resize))
367 root.keys(globalkeys)
371 awful.rules.rules = {
372 -- All clients will match this rule.
374 properties = { border_width = beautiful.border_width,
375 border_color = beautiful.border_normal,
378 buttons = clientbuttons } },
379 { rule = { class = "MPlayer" },
380 properties = { floating = true } },
381 { rule = { class = "pinentry" },
382 properties = { floating = true } },
383 { rule = { class = "gimp" },
384 properties = { floating = true } },
385 -- Set Firefox to always map on tags number 2 of screen 1.
386 -- { rule = { class = "Firefox" },
387 -- properties = { tag = tags[1][2] } },
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)