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 -- require vicious widgets
16 -- {{{ Variable definitions
17 -- Themes define colours, icons, and wallpapers
18 beautiful.init(os.getenv("HOME") .. "/.config/awesome/theme.lua")
20 -- This is used later as the default terminal and editor to run.
21 terminal = "x-terminal-emulator"
22 editor = os.getenv("EDITOR") or "editor"
23 editor_cmd = terminal .. " -e " .. editor
26 -- Usually, Mod4 is the key with a logo between Control and Alt.
27 -- If you do not like this or do not have such a key,
28 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
29 -- However, you can use another modifier like Mod1, but it may interact with others.
32 -- Table of layouts to cover with awful.layout.inc, order matters.
35 -- awful.layout.suit.tile,
36 -- awful.layout.suit.tile.left,
37 -- awful.layout.suit.tile.bottom,
38 -- awful.layout.suit.tile.top,
39 -- awful.layout.suit.fair,
40 -- awful.layout.suit.fair.horizontal,
41 -- awful.layout.suit.spiral,
42 awful.layout.suit.spiral.dwindle,
43 awful.layout.suit.max,
44 -- awful.layout.suit.max.fullscreen,
45 -- awful.layout.suit.magnifier,
46 awful.layout.suit.floating,
51 -- Define a tag table which hold all screen tags.
53 for s = 1, screen.count() do
54 -- Each screen has its own tag table.
55 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
60 -- Create a laucher widget and a main menu
62 { "manual", terminal .. " -e man awesome" },
63 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
64 { "restart", awesome.restart },
65 { "quit", awesome.quit }
68 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
69 { "Debian", debian.menu.Debian_menu.Debian },
70 { "open terminal", terminal }
74 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
79 -- Create a textclock widget
80 mytextclock = awful.widget.textclock({ align = "right" })
83 mysystray = widget({ type = "systray" })
85 mycpuwidget = widget({ type = "textbox" })
86 vicious.register(mycpuwidget, vicious.widgets.cpu, "CPU:$1%", 2)
88 mynetwidget = widget({ type = "textbox" })
89 vicious.register(mynetwidget, vicious.widgets.net, "${wlan23 up_kb}(OUT) ${wlan23 down_kb}(IN)", 1)
91 spacer = widget({ type = "textbox"})
94 sep = widget({ type = "textbox"})
97 -- Create a wibox for each screen and add it
102 mytaglist.buttons = awful.util.table.join(
103 awful.button({ }, 1, awful.tag.viewonly),
104 awful.button({ modkey }, 1, awful.client.movetotag),
105 awful.button({ }, 3, awful.tag.viewtoggle),
106 awful.button({ modkey }, 3, awful.client.toggletag),
107 awful.button({ }, 4, awful.tag.viewnext),
108 awful.button({ }, 5, awful.tag.viewprev)
111 mytasklist.buttons = awful.util.table.join(
112 awful.button({ }, 1, function (c)
113 if not c:isvisible() then
114 awful.tag.viewonly(c:tags()[1])
119 awful.button({ }, 3, function ()
124 instance = awful.menu.clients({ width=250 })
127 awful.button({ }, 4, function ()
128 awful.client.focus.byidx(1)
129 if client.focus then client.focus:raise() end
131 awful.button({ }, 5, function ()
132 awful.client.focus.byidx(-1)
133 if client.focus then client.focus:raise() end
136 for s = 1, screen.count() do
137 -- Create a promptbox for each screen
138 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
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] = awful.widget.layoutbox(s)
142 mylayoutbox[s]:buttons(awful.util.table.join(
143 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
144 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
145 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
146 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
147 -- Create a taglist widget
148 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
150 -- Create a tasklist widget
151 mytasklist[s] = awful.widget.tasklist(function(c)
152 return awful.widget.tasklist.label.currenttags(c, s)
153 end, mytasklist.buttons)
156 mywibox[s] = awful.wibox({ position = "top", screen = s })
157 -- Add widgets to the wibox - order matters
158 mywibox[s].widgets = {
163 layout = awful.widget.layout.horizontal.leftright
167 sep, spacer, mynetwidget,
168 spacer, sep, spacer, mycpuwidget,
169 s == 1 and mysystray or nil,
171 layout = awful.widget.layout.horizontal.rightleft
176 -- {{{ Mouse bindings
177 root.buttons(awful.util.table.join(
178 awful.button({ }, 3, function () mymainmenu:toggle() end),
179 awful.button({ }, 4, awful.tag.viewnext),
180 awful.button({ }, 5, awful.tag.viewprev)
185 globalkeys = awful.util.table.join(
186 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
187 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
188 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
190 awful.key({ modkey, }, "j",
192 awful.client.focus.byidx( 1)
193 if client.focus then client.focus:raise() end
195 awful.key({ modkey, }, "k",
197 awful.client.focus.byidx(-1)
198 if client.focus then client.focus:raise() end
200 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
202 -- Layout manipulation
203 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
204 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
205 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
206 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
207 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
208 awful.key({ modkey, }, "Tab",
210 awful.client.focus.history.previous()
217 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
218 awful.key({ modkey, "Control" }, "r", awesome.restart),
219 awful.key({ modkey, "Shift" }, "q", awesome.quit),
221 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
222 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
223 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
224 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
225 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
226 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
227 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
228 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
231 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
233 awful.key({ modkey }, "x",
235 awful.prompt.run({ prompt = "Run in Terminal: " },
236 mypromptbox[mouse.screen].widget,
237 function (prog) awful.util.spawn_with_shell(terminal .. " -title " .. prog .. " -e " .. prog) end) end),
239 awful.key({ modkey, "Shift"}, "x",
241 awful.prompt.run({ prompt = "Run Lua code: " },
242 mypromptbox[mouse.screen].widget,
243 awful.util.eval, nil,
244 awful.util.getdir("cache") .. "/history_eval")
248 clientkeys = awful.util.table.join(
249 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
250 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
251 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
252 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
253 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
254 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
255 awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
256 awful.key({ modkey, }, "m",
258 c.maximized_horizontal = not c.maximized_horizontal
259 c.maximized_vertical = not c.maximized_vertical
263 -- Compute the maximum number of digit we need, limited to 9
265 for s = 1, screen.count() do
266 keynumber = math.min(9, math.max(#tags[s], keynumber));
269 -- Bind all key numbers to tags.
270 -- Be careful: we use keycodes to make it works on any keyboard layout.
271 -- This should map on the top row of your keyboard, usually 1 to 9.
272 for i = 1, keynumber do
273 globalkeys = awful.util.table.join(globalkeys,
274 awful.key({ modkey }, "#" .. i + 9,
276 local screen = mouse.screen
277 if tags[screen][i] then
278 awful.tag.viewonly(tags[screen][i])
281 awful.key({ modkey, "Control" }, "#" .. i + 9,
283 local screen = mouse.screen
284 if tags[screen][i] then
285 awful.tag.viewtoggle(tags[screen][i])
288 awful.key({ modkey, "Shift" }, "#" .. i + 9,
290 if client.focus and tags[client.focus.screen][i] then
291 awful.client.movetotag(tags[client.focus.screen][i])
294 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
296 if client.focus and tags[client.focus.screen][i] then
297 awful.client.toggletag(tags[client.focus.screen][i])
302 clientbuttons = awful.util.table.join(
303 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
304 awful.button({ modkey }, 1, awful.mouse.client.move),
305 awful.button({ modkey }, 3, awful.mouse.client.resize))
308 root.keys(globalkeys)
312 awful.rules.rules = {
313 -- All clients will match this rule.
315 properties = { border_width = beautiful.border_width,
316 border_color = beautiful.border_normal,
319 buttons = clientbuttons } },
320 { rule = { class = "MPlayer" },
321 properties = { floating = true } },
322 { rule = { class = "pinentry" },
323 properties = { floating = true } },
324 { rule = { class = "gimp" },
325 properties = { floating = true } },
326 -- Set Firefox to always map on tags number 2 of screen 1.
327 { rule = { class = "Iceweasel" },
328 properties = { tag = tags[1][3] } },
329 { rule = { name = "oli" },
330 properties = { tag = tags[1][9] } },
331 { rule = { name = "emacs" },
332 properties = { tag = tags[1][2] } },
333 { rule = { name = "tunnel" },
334 properties = { tag = tags[1][9] } },
339 -- Signal function to execute when a new client appears.
340 client.add_signal("manage", function (c, startup)
342 -- awful.titlebar.add(c, { modkey = modkey })
344 -- Enable sloppy focus
345 c:add_signal("mouse::enter", function(c)
346 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
347 and awful.client.focus.filter(c) then
353 -- Set the windows at the slave,
354 -- i.e. put it at the end of others instead of setting it master.
355 -- awful.client.setslave(c)
357 -- Put windows in a smart way, only if they does not set an initial position.
358 if not c.size_hints.user_position and not c.size_hints.program_position then
359 awful.placement.no_overlap(c)
360 awful.placement.no_offscreen(c)
365 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
366 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)