1 -- Standard awesome library
2 local awful
= require("awful")
3 awful
.rules
= require("awful.rules")
4 require("awful.autofocus")
5 -- Widget and layout library
6 local wibox
= require("wibox")
7 -- Theme handling library
8 local beautiful
= require("beautiful")
9 -- Notification library
10 local naughty
= require("naughty")
11 local menubar
= require("menubar")
14 -- Check if awesome encountered an error during startup and fell back to
15 -- another config (This code will only ever execute for the fallback config)
16 if awesome
.startup_errors
then
17 naughty
.notify({ preset
= naughty
.config
.presets
.critical
,
18 title
= "Oops, there were errors during startup!",
19 text
= awesome
.startup_errors
})
22 -- Handle runtime errors after startup
24 local in_error
= false
25 awesome
.connect_signal("debug::error", function (err
)
26 -- Make sure we don't go into an endless error loop
27 if in_error
then return end
30 naughty
.notify({ preset
= naughty
.config
.presets
.critical
,
31 title
= "Oops, an error happened!",
38 -- {{{ Variable definitions
39 -- Themes define colours, icons, and wallpapers
40 beautiful
.init("@AWESOME_THEMES_PATH@/default/theme.lua")
42 -- This is used later as the default terminal and editor to run.
44 editor
= os
.getenv("EDITOR") or "nano"
45 editor_cmd
= terminal
.. " -e " .. editor
48 -- Usually, Mod4 is the key with a logo between Control and Alt.
49 -- If you do not like this or do not have such a key,
50 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
51 -- However, you can use another modifier like Mod1, but it may interact with others.
54 -- Table of layouts to cover with awful.layout.inc, order matters.
57 awful
.layout
.suit
.floating
,
58 awful
.layout
.suit
.tile
,
59 awful
.layout
.suit
.tile
.left
,
60 awful
.layout
.suit
.tile
.bottom
,
61 awful
.layout
.suit
.tile
.top
,
62 awful
.layout
.suit
.fair
,
63 awful
.layout
.suit
.fair
.horizontal
,
64 awful
.layout
.suit
.spiral
,
65 awful
.layout
.suit
.spiral
.dwindle
,
66 awful
.layout
.suit
.max,
67 awful
.layout
.suit
.max.fullscreen
,
68 awful
.layout
.suit
.magnifier
73 -- Define a tag table which hold all screen tags.
75 for s
= 1, screen
.count() do
76 -- Each screen has its own tag table.
77 tags
[s
] = awful
.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s
, layouts
[1])
82 -- Create a laucher widget and a main menu
84 { "manual", terminal
.. " -e man awesome" },
85 { "edit config", editor_cmd
.. " " .. awesome
.conffile
},
86 { "restart", awesome
.restart
},
87 { "quit", awesome
.quit
}
90 mymainmenu
= awful
.menu({ items
= { { "awesome", myawesomemenu
, beautiful
.awesome_icon
},
91 { "open terminal", terminal
}
95 mylauncher
= awful
.widget
.launcher({ image
= beautiful
.awesome_icon
,
98 -- Menubar configuration
99 menubar
.utils
.terminal
= terminal
-- Set the terminal for applications that require it
103 -- Create a textclock widget
104 mytextclock
= awful
.widget
.textclock()
106 -- Create a wibox for each screen and add it
111 mytaglist
.buttons
= awful
.util
.table.join(
112 awful
.button({ }, 1, awful
.tag.viewonly
),
113 awful
.button({ modkey
}, 1, awful
.client
.movetotag
),
114 awful
.button({ }, 3, awful
.tag.viewtoggle
),
115 awful
.button({ modkey
}, 3, awful
.client
.toggletag
),
116 awful
.button({ }, 4, awful
.tag.viewnext
),
117 awful
.button({ }, 5, awful
.tag.viewprev
)
120 mytasklist
.buttons
= awful
.util
.table.join(
121 awful
.button({ }, 1, function (c
)
122 if c
== client
.focus
then
125 if not c
:isvisible() then
126 awful
.tag.viewonly(c
:tags()[1])
128 -- This will also un-minimize
129 -- the client, if needed
134 awful
.button({ }, 3, function ()
139 instance
= awful
.menu
.clients({ width
=250 })
142 awful
.button({ }, 4, function ()
143 awful
.client
.focus
.byidx(1)
144 if client
.focus
then client
.focus
:raise() end
146 awful
.button({ }, 5, function ()
147 awful
.client
.focus
.byidx(-1)
148 if client
.focus
then client
.focus
:raise() end
151 for s
= 1, screen
.count() do
152 -- Create a promptbox for each screen
153 mypromptbox
[s
] = awful
.widget
.prompt()
154 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
155 -- We need one layoutbox per screen.
156 mylayoutbox
[s
] = awful
.widget
.layoutbox(s
)
157 mylayoutbox
[s
]:buttons(awful
.util
.table.join(
158 awful
.button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
159 awful
.button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
160 awful
.button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
161 awful
.button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end)))
162 -- Create a taglist widget
163 mytaglist
[s
] = awful
.widget
.taglist(s
, awful
.widget
.taglist
.filter
.all
, mytaglist
.buttons
)
165 -- Create a tasklist widget
166 mytasklist
[s
] = awful
.widget
.tasklist(s
, awful
.widget
.tasklist
.filter
.currenttags
, mytasklist
.buttons
)
169 mywibox
[s
] = awful
.wibox({ position
= "top", screen
= s
})
171 -- Widgets that are aligned to the left
172 local left_layout
= wibox
.layout
.fixed
.horizontal()
173 left_layout
:add(mylauncher
)
174 left_layout
:add(mytaglist
[s
])
175 left_layout
:add(mypromptbox
[s
])
177 -- Widgets that are aligned to the right
178 local right_layout
= wibox
.layout
.fixed
.horizontal()
179 if s
== 1 then right_layout
:add(wibox
.widget
.systray()) end
180 right_layout
:add(mytextclock
)
181 right_layout
:add(mylayoutbox
[s
])
183 -- Now bring it all together (with the tasklist in the middle)
184 local layout
= wibox
.layout
.align
.horizontal()
185 layout
:set_left(left_layout
)
186 layout
:set_middle(mytasklist
[s
])
187 layout
:set_right(right_layout
)
189 mywibox
[s
]:set_widget(layout
)
193 -- {{{ Mouse bindings
194 root
.buttons(awful
.util
.table.join(
195 awful
.button({ }, 3, function () mymainmenu
:toggle() end),
196 awful
.button({ }, 4, awful
.tag.viewnext
),
197 awful
.button({ }, 5, awful
.tag.viewprev
)
202 globalkeys
= awful
.util
.table.join(
203 awful
.key({ modkey
, }, "Left", awful
.tag.viewprev
),
204 awful
.key({ modkey
, }, "Right", awful
.tag.viewnext
),
205 awful
.key({ modkey
, }, "Escape", awful
.tag.history
.restore
),
207 awful
.key({ modkey
, }, "j",
209 awful
.client
.focus
.byidx( 1)
210 if client
.focus
then client
.focus
:raise() end
212 awful
.key({ modkey
, }, "k",
214 awful
.client
.focus
.byidx(-1)
215 if client
.focus
then client
.focus
:raise() end
217 awful
.key({ modkey
, }, "w", function () mymainmenu
:show() end),
219 -- Layout manipulation
220 awful
.key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx( 1) end),
221 awful
.key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx( -1) end),
222 awful
.key({ modkey
, "Control" }, "j", function () awful
.screen
.focus_relative( 1) end),
223 awful
.key({ modkey
, "Control" }, "k", function () awful
.screen
.focus_relative(-1) end),
224 awful
.key({ modkey
, }, "u", awful
.client
.urgent
.jumpto
),
225 awful
.key({ modkey
, }, "Tab",
227 awful
.client
.focus
.history
.previous()
234 awful
.key({ modkey
, }, "Return", function () awful
.util
.spawn(terminal
) end),
235 awful
.key({ modkey
, "Control" }, "r", awesome
.restart
),
236 awful
.key({ modkey
, "Shift" }, "q", awesome
.quit
),
238 awful
.key({ modkey
, }, "l", function () awful
.tag.incmwfact( 0.05) end),
239 awful
.key({ modkey
, }, "h", function () awful
.tag.incmwfact(-0.05) end),
240 awful
.key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster( 1) end),
241 awful
.key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end),
242 awful
.key({ modkey
, "Control" }, "h", function () awful
.tag.incncol( 1) end),
243 awful
.key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end),
244 awful
.key({ modkey
, }, "space", function () awful
.layout
.inc(layouts
, 1) end),
245 awful
.key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end),
247 awful
.key({ modkey
, "Control" }, "n", awful
.client
.restore
),
250 awful
.key({ modkey
}, "r", function () mypromptbox
[mouse
.screen
]:run() end),
252 awful
.key({ modkey
}, "x",
254 awful
.prompt
.run({ prompt
= "Run Lua code: " },
255 mypromptbox
[mouse
.screen
].widget
,
256 awful
.util
.eval
, nil,
257 awful
.util
.getdir("cache") .. "/history_eval")
260 awful
.key({ modkey
}, "p", function() menubar
.show() end)
263 clientkeys
= awful
.util
.table.join(
264 awful
.key({ modkey
, }, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end),
265 awful
.key({ modkey
, "Shift" }, "c", function (c
) c
:kill() end),
266 awful
.key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
),
267 awful
.key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end),
268 awful
.key({ modkey
, }, "o", awful
.client
.movetoscreen
),
269 awful
.key({ modkey
, }, "t", function (c
) c
.ontop
= not c
.ontop
end),
270 awful
.key({ modkey
, }, "n",
272 -- The client currently has the input focus, so it cannot be
273 -- minimized, since minimized clients can't have the focus.
276 awful
.key({ modkey
, }, "m",
278 c
.maximized_horizontal
= not c
.maximized_horizontal
279 c
.maximized_vertical
= not c
.maximized_vertical
283 -- Compute the maximum number of digit we need, limited to 9
285 for s
= 1, screen
.count() do
286 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
))
289 -- Bind all key numbers to tags.
290 -- Be careful: we use keycodes to make it works on any keyboard layout.
291 -- This should map on the top row of your keyboard, usually 1 to 9.
292 for i
= 1, keynumber
do
293 globalkeys
= awful
.util
.table.join(globalkeys
,
294 awful
.key({ modkey
}, "#" .. i
+ 9,
296 local screen
= mouse
.screen
297 if tags
[screen
][i
] then
298 awful
.tag.viewonly(tags
[screen
][i
])
301 awful
.key({ modkey
, "Control" }, "#" .. i
+ 9,
303 local screen
= mouse
.screen
304 if tags
[screen
][i
] then
305 awful
.tag.viewtoggle(tags
[screen
][i
])
308 awful
.key({ modkey
, "Shift" }, "#" .. i
+ 9,
310 if client
.focus
and tags
[client
.focus
.screen
][i
] then
311 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
314 awful
.key({ modkey
, "Control", "Shift" }, "#" .. i
+ 9,
316 if client
.focus
and tags
[client
.focus
.screen
][i
] then
317 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
322 clientbuttons
= awful
.util
.table.join(
323 awful
.button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
324 awful
.button({ modkey
}, 1, awful
.mouse
.client
.move
),
325 awful
.button({ modkey
}, 3, awful
.mouse
.client
.resize
))
328 root
.keys(globalkeys
)
332 awful
.rules
.rules
= {
333 -- All clients will match this rule.
335 properties
= { border_width
= beautiful
.border_width
,
336 border_color
= beautiful
.border_normal
,
339 buttons
= clientbuttons
} },
340 { rule
= { class
= "MPlayer" },
341 properties
= { floating
= true } },
342 { rule
= { class
= "pinentry" },
343 properties
= { floating
= true } },
344 { rule
= { class
= "gimp" },
345 properties
= { floating
= true } },
346 -- Set Firefox to always map on tags number 2 of screen 1.
347 -- { rule = { class = "Firefox" },
348 -- properties = { tag = tags[1][2] } },
353 -- Signal function to execute when a new client appears.
354 client
.connect_signal("manage", function (c
, startup
)
355 -- Enable sloppy focus
356 c
:connect_signal("mouse::enter", function(c
)
357 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
358 and awful
.client
.focus
.filter(c
) then
364 -- Set the windows at the slave,
365 -- i.e. put it at the end of others instead of setting it master.
366 -- awful.client.setslave(c)
368 -- Put windows in a smart way, only if they does not set an initial position.
369 if not c
.size_hints
.user_position
and not c
.size_hints
.program_position
then
370 awful
.placement
.no_overlap(c
)
371 awful
.placement
.no_offscreen(c
)
376 client
.connect_signal("focus", function(c
) c
.border_color
= beautiful
.border_focus
end)
377 client
.connect_signal("unfocus", function(c
) c
.border_color
= beautiful
.border_normal
end)