1 -- Standard awesome library
3 require("awful.autofocus")
5 -- Theme handling library
7 -- Notification library
11 -- Check if awesome encountered an error during startup and fell back to
12 -- another config (This code will only ever execute for the fallback config)
13 if awesome
.startup_errors
then
14 naughty
.notify({ preset
= naughty
.config
.presets
.critical
,
15 title
= "Oops, there were errors during startup!",
16 text
= awesome
.startup_errors
})
19 -- Handle runtime errors after startup
21 local in_error
= false
22 awesome
.add_signal("debug::error", function (err
)
23 -- Make sure we don't go into an endless error loop
24 if in_error
then return end
27 naughty
.notify({ preset
= naughty
.config
.presets
.critical
,
28 title
= "Oops, an error happened!",
35 -- {{{ Variable definitions
36 -- Themes define colours, icons, and wallpapers
37 beautiful
.init("@AWESOME_THEMES_PATH@/default/theme.lua")
39 -- This is used later as the default terminal and editor to run.
41 editor
= os
.getenv("EDITOR") or "nano"
42 editor_cmd
= terminal
.. " -e " .. editor
45 -- Usually, Mod4 is the key with a logo between Control and Alt.
46 -- If you do not like this or do not have such a key,
47 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
48 -- However, you can use another modifier like Mod1, but it may interact with others.
51 -- Table of layouts to cover with awful.layout.inc, order matters.
54 awful
.layout
.suit
.floating
,
55 awful
.layout
.suit
.tile
,
56 awful
.layout
.suit
.tile
.left
,
57 awful
.layout
.suit
.tile
.bottom
,
58 awful
.layout
.suit
.tile
.top
,
59 awful
.layout
.suit
.fair
,
60 awful
.layout
.suit
.fair
.horizontal
,
61 awful
.layout
.suit
.spiral
,
62 awful
.layout
.suit
.spiral
.dwindle
,
63 awful
.layout
.suit
.max,
64 awful
.layout
.suit
.max.fullscreen
,
65 awful
.layout
.suit
.magnifier
70 -- Define a tag table which hold all screen tags.
72 for s
= 1, screen
.count() do
73 -- Each screen has its own tag table.
74 tags
[s
] = awful
.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s
, layouts
[1])
79 -- Create a laucher widget and a main menu
81 { "manual", terminal
.. " -e man awesome" },
82 { "edit config", editor_cmd
.. " " .. awesome
.conffile
},
83 { "restart", awesome
.restart
},
84 { "quit", awesome
.quit
}
87 mymainmenu
= awful
.menu({ items
= { { "awesome", myawesomemenu
, beautiful
.awesome_icon
},
88 { "open terminal", terminal
}
92 mylauncher
= awful
.widget
.launcher({ image
= image(beautiful
.awesome_icon
),
97 -- Create a textclock widget
98 mytextclock
= awful
.widget
.textclock({ align
= "right" })
101 mysystray
= widget({ type = "systray" })
103 -- Create a wibox for each screen and add it
108 mytaglist
.buttons
= awful
.util
.table.join(
109 awful
.button({ }, 1, awful
.tag.viewonly
),
110 awful
.button({ modkey
}, 1, awful
.client
.movetotag
),
111 awful
.button({ }, 3, awful
.tag.viewtoggle
),
112 awful
.button({ modkey
}, 3, awful
.client
.toggletag
),
113 awful
.button({ }, 4, awful
.tag.viewnext
),
114 awful
.button({ }, 5, awful
.tag.viewprev
)
117 mytasklist
.buttons
= awful
.util
.table.join(
118 awful
.button({ }, 1, function (c
)
119 if c
== client
.focus
then
122 if not c
:isvisible() then
123 awful
.tag.viewonly(c
:tags()[1])
125 -- This will also un-minimize
126 -- the client, if needed
131 awful
.button({ }, 3, function ()
136 instance
= awful
.menu
.clients({ width
=250 })
139 awful
.button({ }, 4, function ()
140 awful
.client
.focus
.byidx(1)
141 if client
.focus
then client
.focus
:raise() end
143 awful
.button({ }, 5, function ()
144 awful
.client
.focus
.byidx(-1)
145 if client
.focus
then client
.focus
:raise() end
148 for s
= 1, screen
.count() do
149 -- Create a promptbox for each screen
150 mypromptbox
[s
] = awful
.widget
.prompt({ layout
= awful
.widget
.layout
.horizontal
.leftright
})
151 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
152 -- We need one layoutbox per screen.
153 mylayoutbox
[s
] = awful
.widget
.layoutbox(s
)
154 mylayoutbox
[s
]:buttons(awful
.util
.table.join(
155 awful
.button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
156 awful
.button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
157 awful
.button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
158 awful
.button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end)))
159 -- Create a taglist widget
160 mytaglist
[s
] = awful
.widget
.taglist(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
162 -- Create a tasklist widget
163 mytasklist
[s
] = awful
.widget
.tasklist(function(c
)
164 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
165 end, mytasklist
.buttons
)
168 mywibox
[s
] = awful
.wibox({ position
= "top", screen
= s
})
169 -- Add widgets to the wibox - order matters
170 mywibox
[s
].widgets
= {
175 layout
= awful
.widget
.layout
.horizontal
.leftright
179 s
== 1 and mysystray
or nil,
181 layout
= awful
.widget
.layout
.horizontal
.rightleft
186 -- {{{ Mouse bindings
187 root
.buttons(awful
.util
.table.join(
188 awful
.button({ }, 3, function () mymainmenu
:toggle() end),
189 awful
.button({ }, 4, awful
.tag.viewnext
),
190 awful
.button({ }, 5, awful
.tag.viewprev
)
195 globalkeys
= awful
.util
.table.join(
196 awful
.key({ modkey
, }, "Left", awful
.tag.viewprev
),
197 awful
.key({ modkey
, }, "Right", awful
.tag.viewnext
),
198 awful
.key({ modkey
, }, "Escape", awful
.tag.history
.restore
),
200 awful
.key({ modkey
, }, "j",
202 awful
.client
.focus
.byidx( 1)
203 if client
.focus
then client
.focus
:raise() end
205 awful
.key({ modkey
, }, "k",
207 awful
.client
.focus
.byidx(-1)
208 if client
.focus
then client
.focus
:raise() end
210 awful
.key({ modkey
, }, "w", function () mymainmenu
:show({keygrabber
=true}) end),
212 -- Layout manipulation
213 awful
.key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx( 1) end),
214 awful
.key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx( -1) end),
215 awful
.key({ modkey
, "Control" }, "j", function () awful
.screen
.focus_relative( 1) end),
216 awful
.key({ modkey
, "Control" }, "k", function () awful
.screen
.focus_relative(-1) end),
217 awful
.key({ modkey
, }, "u", awful
.client
.urgent
.jumpto
),
218 awful
.key({ modkey
, }, "Tab",
220 awful
.client
.focus
.history
.previous()
227 awful
.key({ modkey
, }, "Return", function () awful
.util
.spawn(terminal
) end),
228 awful
.key({ modkey
, "Control" }, "r", awesome
.restart
),
229 awful
.key({ modkey
, "Shift" }, "q", awesome
.quit
),
231 awful
.key({ modkey
, }, "l", function () awful
.tag.incmwfact( 0.05) end),
232 awful
.key({ modkey
, }, "h", function () awful
.tag.incmwfact(-0.05) end),
233 awful
.key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster( 1) end),
234 awful
.key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end),
235 awful
.key({ modkey
, "Control" }, "h", function () awful
.tag.incncol( 1) end),
236 awful
.key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end),
237 awful
.key({ modkey
, }, "space", function () awful
.layout
.inc(layouts
, 1) end),
238 awful
.key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end),
240 awful
.key({ modkey
, "Control" }, "n", awful
.client
.restore
),
243 awful
.key({ modkey
}, "r", function () mypromptbox
[mouse
.screen
]:run() end),
245 awful
.key({ modkey
}, "x",
247 awful
.prompt
.run({ prompt
= "Run Lua code: " },
248 mypromptbox
[mouse
.screen
].widget
,
249 awful
.util
.eval
, nil,
250 awful
.util
.getdir("cache") .. "/history_eval")
254 clientkeys
= awful
.util
.table.join(
255 awful
.key({ modkey
, }, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end),
256 awful
.key({ modkey
, "Shift" }, "c", function (c
) c
:kill() end),
257 awful
.key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
),
258 awful
.key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end),
259 awful
.key({ modkey
, }, "o", awful
.client
.movetoscreen
),
260 awful
.key({ modkey
, "Shift" }, "r", function (c
) c
:redraw() end),
261 awful
.key({ modkey
, }, "t", function (c
) c
.ontop
= not c
.ontop
end),
262 awful
.key({ modkey
, }, "n",
264 -- The client currently has the input focus, so it cannot be
265 -- minimized, since minimized clients can't have the focus.
268 awful
.key({ modkey
, }, "m",
270 c
.maximized_horizontal
= not c
.maximized_horizontal
271 c
.maximized_vertical
= not c
.maximized_vertical
275 -- Compute the maximum number of digit we need, limited to 9
277 for s
= 1, screen
.count() do
278 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
281 -- Bind all key numbers to tags.
282 -- Be careful: we use keycodes to make it works on any keyboard layout.
283 -- This should map on the top row of your keyboard, usually 1 to 9.
284 for i
= 1, keynumber
do
285 globalkeys
= awful
.util
.table.join(globalkeys
,
286 awful
.key({ modkey
}, "#" .. i
+ 9,
288 local screen
= mouse
.screen
289 if tags
[screen
][i
] then
290 awful
.tag.viewonly(tags
[screen
][i
])
293 awful
.key({ modkey
, "Control" }, "#" .. i
+ 9,
295 local screen
= mouse
.screen
296 if tags
[screen
][i
] then
297 awful
.tag.viewtoggle(tags
[screen
][i
])
300 awful
.key({ modkey
, "Shift" }, "#" .. i
+ 9,
302 if client
.focus
and tags
[client
.focus
.screen
][i
] then
303 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
306 awful
.key({ modkey
, "Control", "Shift" }, "#" .. i
+ 9,
308 if client
.focus
and tags
[client
.focus
.screen
][i
] then
309 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
314 clientbuttons
= awful
.util
.table.join(
315 awful
.button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
316 awful
.button({ modkey
}, 1, awful
.mouse
.client
.move
),
317 awful
.button({ modkey
}, 3, awful
.mouse
.client
.resize
))
320 root
.keys(globalkeys
)
324 awful
.rules
.rules
= {
325 -- All clients will match this rule.
327 properties
= { border_width
= beautiful
.border_width
,
328 border_color
= beautiful
.border_normal
,
331 buttons
= clientbuttons
} },
332 { rule
= { class
= "MPlayer" },
333 properties
= { floating
= true } },
334 { rule
= { class
= "pinentry" },
335 properties
= { floating
= true } },
336 { rule
= { class
= "gimp" },
337 properties
= { floating
= true } },
338 -- Set Firefox to always map on tags number 2 of screen 1.
339 -- { rule = { class = "Firefox" },
340 -- properties = { tag = tags[1][2] } },
345 -- Signal function to execute when a new client appears.
346 client
.add_signal("manage", function (c
, startup
)
348 -- awful.titlebar.add(c, { modkey = modkey })
350 -- Enable sloppy focus
351 c
:add_signal("mouse::enter", function(c
)
352 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
353 and awful
.client
.focus
.filter(c
) then
359 -- Set the windows at the slave,
360 -- i.e. put it at the end of others instead of setting it master.
361 -- awful.client.setslave(c)
363 -- Put windows in a smart way, only if they does not set an initial position.
364 if not c
.size_hints
.user_position
and not c
.size_hints
.program_position
then
365 awful
.placement
.no_overlap(c
)
366 awful
.placement
.no_offscreen(c
)
371 client
.add_signal("focus", function(c
) c
.border_color
= beautiful
.border_focus
end)
372 client
.add_signal("unfocus", function(c
) c
.border_color
= beautiful
.border_normal
end)