1 -- Standard awesome library
3 require("awful.autofocus")
5 -- Theme handling library
7 -- Notification library
10 -- {{{ Variable definitions
11 -- This is used later as the default terminal and editor to run.
13 editor = os.getenv("EDITOR") or "nano"
14 editor_cmd = terminal .. " -e " .. editor
17 -- Usually, Mod4 is the key with a logo between Control and Alt.
18 -- If you do not like this or do not have such a key,
19 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
20 -- However, you can use another modifier like Mod1, but it may interact with others.
23 -- Table of layouts to cover with awful.layout.inc, order matters.
26 awful.layout.suit.tile,
27 awful.layout.suit.tile.left,
28 awful.layout.suit.tile.bottom,
29 awful.layout.suit.tile.top,
30 awful.layout.suit.fair,
31 awful.layout.suit.fair.horizontal,
32 awful.layout.suit.spiral,
33 awful.layout.suit.spiral.dwindle,
34 awful.layout.suit.max,
35 awful.layout.suit.max.fullscreen,
36 awful.layout.suit.magnifier,
37 awful.layout.suit.floating
42 -- Define a tag table which hold all screen tags.
44 for s = 1, screen.count() do
45 -- Each screen has its own tag table.
46 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s)
51 -- Create a laucher widget and a main menu
53 { "manual", terminal .. " -e man awesome" },
54 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
55 { "restart", awesome.restart },
56 { "quit", awesome.quit }
59 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
60 { "open terminal", terminal }
64 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
69 -- Create a textclock widget
70 mytextclock = awful.widget.textclock({ align = "right" })
73 mysystray = widget({ type = "systray" })
75 -- Create a wibox for each screen and add it
80 mytaglist.buttons = awful.util.table.join(
81 awful.button({ }, 1, awful.tag.viewonly),
82 awful.button({ modkey }, 1, awful.client.movetotag),
83 awful.button({ }, 3, awful.tag.viewtoggle),
84 awful.button({ modkey }, 3, awful.client.toggletag),
85 awful.button({ }, 4, awful.tag.viewnext),
86 awful.button({ }, 5, awful.tag.viewprev)
89 mytasklist.buttons = awful.util.table.join(
90 awful.button({ }, 1, function (c)
91 if not c:isvisible() then
92 awful.tag.viewonly(c:tags()[1])
97 awful.button({ }, 3, function ()
102 instance = awful.menu.clients({ width=250 })
105 awful.button({ }, 4, function ()
106 awful.client.focus.byidx(1)
107 if client.focus then client.focus:raise() end
109 awful.button({ }, 5, function ()
110 awful.client.focus.byidx(-1)
111 if client.focus then client.focus:raise() end
114 for s = 1, screen.count() do
115 -- Create a promptbox for each screen
116 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
117 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
118 -- We need one layoutbox per screen.
119 mylayoutbox[s] = awful.widget.layoutbox(s)
120 mylayoutbox[s]:buttons(awful.util.table.join(
121 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
122 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
123 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
124 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
125 -- Create a taglist widget
126 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
128 -- Create a tasklist widget
129 mytasklist[s] = awful.widget.tasklist(function(c)
130 return awful.widget.tasklist.label.currenttags(c, s)
131 end, mytasklist.buttons)
134 mywibox[s] = awful.wibox({ position = "top", screen = s })
135 -- Add widgets to the wibox - order matters
136 mywibox[s].widgets = {
141 layout = awful.widget.layout.horizontal.leftright
145 s == 1 and mysystray or nil,
147 layout = awful.widget.layout.horizontal.rightleft
152 -- {{{ Mouse bindings
153 root.buttons(awful.util.table.join(
154 awful.button({ }, 3, function () mymainmenu:toggle() end),
155 awful.button({ }, 4, awful.tag.viewnext),
156 awful.button({ }, 5, awful.tag.viewprev)
161 globalkeys = awful.util.table.join(
162 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
163 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
164 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
166 awful.key({ modkey, }, "j",
168 awful.client.focus.byidx( 1)
169 if client.focus then client.focus:raise() end
171 awful.key({ modkey, }, "k",
173 awful.client.focus.byidx(-1)
174 if client.focus then client.focus:raise() end
176 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
178 -- Layout manipulation
179 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
180 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
181 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
182 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
183 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
184 awful.key({ modkey, }, "Tab",
186 awful.client.focus.history.previous()
193 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
194 awful.key({ modkey, "Control" }, "r", awesome.restart),
195 awful.key({ modkey, "Shift" }, "q", awesome.quit),
197 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
198 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
199 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
200 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
201 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
202 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
203 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
204 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
207 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
209 awful.key({ modkey }, "x",
211 awful.prompt.run({ prompt = "Run Lua code: " },
212 mypromptbox[mouse.screen].widget,
213 awful.util.eval, nil,
214 awful.util.getdir("cache") .. "/history_eval")
218 clientkeys = awful.util.table.join(
219 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
220 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
221 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
222 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
223 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
224 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
225 awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
226 awful.key({ modkey, }, "m",
228 c.maximized_horizontal = not c.maximized_horizontal
229 c.maximized_vertical = not c.maximized_vertical
233 -- Compute the maximum number of digit we need, limited to 9
235 for s = 1, screen.count() do
236 keynumber = math.min(9, math.max(#tags[s], keynumber));
239 for i = 1, keynumber do
240 globalkeys = awful.util.table.join(globalkeys,
241 awful.key({ modkey }, i,
243 local screen = mouse.screen
244 if tags[screen][i] then
245 awful.tag.viewonly(tags[screen][i])
248 awful.key({ modkey, "Control" }, i,
250 local screen = mouse.screen
251 if tags[screen][i] then
252 awful.tag.viewtoggle(tags[screen][i])
255 awful.key({ modkey, "Shift" }, i,
257 if client.focus and tags[client.focus.screen][i] then
258 awful.client.movetotag(tags[client.focus.screen][i])
261 awful.key({ modkey, "Control", "Shift" }, i,
263 if client.focus and tags[client.focus.screen][i] then
264 awful.client.toggletag(tags[client.focus.screen][i])
269 clientbuttons = awful.util.table.join(
270 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
271 awful.button({ modkey }, 1, awful.mouse.client.move),
272 awful.button({ modkey }, 3, awful.mouse.client.resize))
275 root.keys(globalkeys)
279 awful.rules.rules = {
280 -- All clients will match this rule.
282 properties = { border_width = beautiful.border_width,
283 border_color = beautiful.border_normal,
286 buttons = clientbuttons } },
287 { rule = { class = "MPlayer" },
288 properties = { floating = true } },
289 { rule = { class = "pinentry" },
290 properties = { floating = true } },
291 { rule = { class = "gimp" },
292 properties = { floating = true } },
293 -- Set Firefox to always map on tags number 2 of screen 1.
294 -- { rule = { class = "Firefox" },
295 -- properties = { tag = tags[1][2] } },
300 -- Signal function to execute when a new client appears.
301 client.add_signal("manage", function (c, startup)
303 -- awful.titlebar.add(c, { modkey = modkey })
305 -- Enable sloppy focus
306 c:add_signal("mouse::enter", function(c)
307 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
308 and awful.client.focus.filter(c) then
313 -- Set the windows at the slave,
314 -- i.e. put it at the end of others instead of setting it master.
315 -- awful.client.setslave(c)
318 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
319 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)