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/default/theme.lua")
17 -- This is used later as the default terminal and editor to run.
18 terminal = "x-terminal-emulator"
19 editor = os.getenv("EDITOR") or "editor"
20 editor_cmd = terminal .. " -e " .. editor
23 -- Usually, Mod4 is the key with a logo between Control and Alt.
24 -- If you do not like this or do not have such a key,
25 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
26 -- However, you can use another modifier like Mod1, but it may interact with others.
29 -- Table of layouts to cover with awful.layout.inc, order matters.
32 awful.layout.suit.tile,
33 awful.layout.suit.tile.left,
34 awful.layout.suit.tile.bottom,
35 awful.layout.suit.tile.top,
36 awful.layout.suit.fair,
37 awful.layout.suit.fair.horizontal,
38 awful.layout.suit.spiral,
39 awful.layout.suit.spiral.dwindle,
40 awful.layout.suit.max,
41 awful.layout.suit.max.fullscreen,
42 awful.layout.suit.magnifier,
43 awful.layout.suit.floating
48 -- Define a tag table which hold all screen tags.
50 for s = 1, screen.count() do
51 -- Each screen has its own tag table.
52 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s)
57 -- Create a laucher widget and a main menu
59 { "manual", terminal .. " -e man awesome" },
60 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
61 { "restart", awesome.restart },
62 { "quit", awesome.quit }
65 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
66 { "Debian", debian.menu.Debian_menu.Debian },
67 { "open terminal", terminal }
71 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
76 -- Create a textclock widget
77 mytextclock = awful.widget.textclock({ align = "right" }, " %c ", 1)
80 mysystray = widget({ type = "systray" })
82 -- Create a wibox for each screen and add it
87 mytaglist.buttons = awful.util.table.join(
88 awful.button({ }, 1, awful.tag.viewonly),
89 awful.button({ modkey }, 1, awful.client.movetotag),
90 awful.button({ }, 3, awful.tag.viewtoggle),
91 awful.button({ modkey }, 3, awful.client.toggletag),
92 awful.button({ }, 4, awful.tag.viewnext),
93 awful.button({ }, 5, awful.tag.viewprev)
96 mytasklist.buttons = awful.util.table.join(
97 awful.button({ }, 1, function (c)
98 if not c:isvisible() then
99 awful.tag.viewonly(c:tags()[1])
104 awful.button({ }, 3, function ()
109 instance = awful.menu.clients({ width=250 })
112 awful.button({ }, 4, function ()
113 awful.client.focus.byidx(1)
114 if client.focus then client.focus:raise() end
116 awful.button({ }, 5, function ()
117 awful.client.focus.byidx(-1)
118 if client.focus then client.focus:raise() end
121 for s = 1, screen.count() do
122 -- Create a promptbox for each screen
123 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
124 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
125 -- We need one layoutbox per screen.
126 mylayoutbox[s] = awful.widget.layoutbox(s)
127 mylayoutbox[s]:buttons(awful.util.table.join(
128 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
129 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
130 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
131 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
132 -- Create a taglist widget
133 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
135 -- Create a tasklist widget
136 mytasklist[s] = awful.widget.tasklist(function(c)
137 return awful.widget.tasklist.label.currenttags(c, s)
138 end, mytasklist.buttons)
141 mywibox[s] = awful.wibox({ position = "top", screen = s })
142 -- Add widgets to the wibox - order matters
143 mywibox[s].widgets = {
148 layout = awful.widget.layout.horizontal.leftright
152 s == 1 and mysystray or nil,
154 layout = awful.widget.layout.horizontal.rightleft
159 -- {{{ Mouse bindings
160 root.buttons(awful.util.table.join(
161 awful.button({ }, 3, function () mymainmenu:toggle() end),
162 awful.button({ }, 4, awful.tag.viewnext),
163 awful.button({ }, 5, awful.tag.viewprev)
168 globalkeys = awful.util.table.join(
169 -- awful.key({ modkey, }, "Left", awful.tag.viewprev ),
170 -- awful.key({ modkey, }, "Right", awful.tag.viewnext ),
171 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
173 awful.key({ modkey, }, "j",
175 awful.client.focus.byidx( 1)
176 if client.focus then client.focus:raise() end
178 awful.key({ modkey, }, "k",
180 awful.client.focus.byidx(-1)
181 if client.focus then client.focus:raise() end
183 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
185 -- Layout manipulation
186 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
187 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
188 awful.key({ modkey, }, "Left", function () awful.screen.focus_relative( 1) end),
189 awful.key({ modkey, }, "Right", function () awful.screen.focus_relative(-1) end),
190 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
191 awful.key({ modkey, }, "Tab",
193 awful.client.focus.history.previous()
200 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
201 awful.key({ modkey, "Control", "Shift" }, "r", awesome.restart),
202 awful.key({ modkey, "Control", "Shift" }, "q", awesome.quit),
204 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
205 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
206 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
207 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
208 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
209 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
210 awful.key({ modkey, }, "n", function () awful.layout.inc(layouts, 1) end),
211 awful.key({ modkey, "Shift" }, "n", function () awful.layout.inc(layouts, -1) end),
214 awful.key({ modkey, "Shift" }, "Down", function () awful.client.moveresize(0, 20, 0, 0) end),
215 awful.key({ modkey, "Shift" }, "Up", function () awful.client.moveresize(0, -20, 0, 0) end),
216 awful.key({ modkey, "Shift" }, "Left", function () awful.client.moveresize(-20, 0, 0, 0) end),
217 awful.key({ modkey, "Shift" }, "Right", function () awful.client.moveresize(20, 0, 0, 0) end),
218 awful.key({ modkey, "Control" }, "Down", function () awful.client.moveresize(0, 0, 0, -20) end),
219 awful.key({ modkey, "Control" }, "Up", function () awful.client.moveresize(0, 0, 0, 20) end),
220 awful.key({ modkey, "Control" }, "Left", function () awful.client.moveresize(0, 0, -20, 0) end),
221 awful.key({ modkey, "Control" }, "Right", function () awful.client.moveresize(0, 0, 20, 0) end),
223 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
225 awful.key({ modkey }, "x",
227 awful.prompt.run({ prompt = "Run Lua code: " },
228 mypromptbox[mouse.screen].widget,
229 awful.util.eval, nil,
230 awful.util.getdir("cache") .. "/history_eval")
234 clientkeys = awful.util.table.join(
235 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
236 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
237 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
238 awful.key({ modkey, }, "space", function (c) c:swap(awful.client.getmaster()) end),
239 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
240 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
241 awful.key({ modkey, "Shift" }, "m", function (c) c.minimized = not c.minimized end),
242 awful.key({ modkey, }, "m",
244 c.maximized_horizontal = not c.maximized_horizontal
245 c.maximized_vertical = not c.maximized_vertical
249 -- Compute the maximum number of digit we need, limited to 9
251 for s = 1, screen.count() do
252 keynumber = math.min(9, math.max(#tags[s], keynumber));
255 -- Bind all key numbers to tags.
256 -- Be careful: we use keycodes to make it works on any keyboard layout.
257 -- This should map on the top row of your keyboard, usually 1 to 9.
258 for i = 1, keynumber do
259 globalkeys = awful.util.table.join(globalkeys,
260 awful.key({ modkey }, "#" .. i + 9,
262 local screen = mouse.screen
263 if tags[screen][i] then
264 awful.tag.viewonly(tags[screen][i])
267 awful.key({ modkey, "Control" }, "#" .. i + 9,
269 local screen = mouse.screen
270 if tags[screen][i] then
271 awful.tag.viewtoggle(tags[screen][i])
274 awful.key({ modkey, "Shift" }, "#" .. i + 9,
276 if client.focus and tags[client.focus.screen][i] then
277 awful.client.movetotag(tags[client.focus.screen][i])
280 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
282 if client.focus and tags[client.focus.screen][i] then
283 awful.client.toggletag(tags[client.focus.screen][i])
288 clientbuttons = awful.util.table.join(
289 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
290 awful.button({ modkey }, 1, awful.mouse.client.move),
291 awful.button({ modkey }, 3, awful.mouse.client.resize))
294 root.keys(globalkeys)
298 awful.rules.rules = {
299 -- All clients will match this rule.
301 properties = { border_width = beautiful.border_width,
302 border_color = beautiful.border_normal,
305 buttons = clientbuttons } },
306 { rule = { class = "MPlayer" },
307 properties = { floating = true } },
308 { rule = { class = "pinentry" },
309 properties = { floating = true } },
310 { rule = { class = "gimp" },
311 properties = { floating = true } },
312 -- Set Firefox to always map on tags number 2 of screen 1.
313 -- { rule = { class = "Firefox" },
314 -- properties = { tag = tags[1][2] } },
319 -- Signal function to execute when a new client appears.
320 client.add_signal("manage", function (c, startup)
322 -- awful.titlebar.add(c, { modkey = modkey })
324 -- Enable sloppy focus
325 c:add_signal("mouse::enter", function(c)
326 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
327 and awful.client.focus.filter(c) then
333 -- Set the windows at the slave,
334 -- i.e. put it at the end of others instead of setting it master.
335 -- awful.client.setslave(c)
337 -- Put windows in a smart way, only if they does not set an initial position.
338 if not c.size_hints.user_position and not c.size_hints.program_position then
339 awful.placement.no_overlap(c)
340 awful.placement.no_offscreen(c)
345 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
346 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)