Print signal number while dying
[awesome.git] / awesomerc.lua.in
blob261fa50b07e24c46f84f75b8e4393ab64932fcd9
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")
13 -- {{{ Error handling
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 })
20 end
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
28 in_error = true
30 naughty.notify({ preset = naughty.config.presets.critical,
31 title = "Oops, an error happened!",
32 text = err })
33 in_error = false
34 end)
35 end
36 -- }}}
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.
43 terminal = "xterm"
44 editor = os.getenv("EDITOR") or "nano"
45 editor_cmd = terminal .. " -e " .. editor
47 -- Default modkey.
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.
52 modkey = "Mod4"
54 -- Table of layouts to cover with awful.layout.inc, order matters.
55 local layouts =
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
70 -- }}}
72 -- {{{ Tags
73 -- Define a tag table which hold all screen tags.
74 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])
78 end
79 -- }}}
81 -- {{{ Menu
82 -- Create a laucher widget and a main menu
83 myawesomemenu = {
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,
96 menu = mymainmenu })
98 -- Menubar configuration
99 menubar.utils.terminal = terminal -- Set the terminal for applications that require it
100 -- }}}
102 -- {{{ Wibox
103 -- Create a textclock widget
104 mytextclock = awful.widget.textclock()
106 -- Create a wibox for each screen and add it
107 mywibox = {}
108 mypromptbox = {}
109 mylayoutbox = {}
110 mytaglist = {}
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, function(t) awful.tag.viewnext(t.screen) end),
117 awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
119 mytasklist = {}
120 mytasklist.buttons = awful.util.table.join(
121 awful.button({ }, 1, function (c)
122 if c == client.focus then
123 c.minimized = true
124 else
125 -- Without this, the following
126 -- :isvisible() makes no sense
127 c.minimized = false
128 if not c:isvisible() then
129 awful.tag.viewonly(c:tags()[1])
131 -- This will also un-minimize
132 -- the client, if needed
133 client.focus = c
134 c:raise()
136 end),
137 awful.button({ }, 3, function ()
138 if instance then
139 instance:hide()
140 instance = nil
141 else
142 instance = awful.menu.clients({ width=250 })
144 end),
145 awful.button({ }, 4, function ()
146 awful.client.focus.byidx(1)
147 if client.focus then client.focus:raise() end
148 end),
149 awful.button({ }, 5, function ()
150 awful.client.focus.byidx(-1)
151 if client.focus then client.focus:raise() end
152 end))
154 for s = 1, screen.count() do
155 -- Create a promptbox for each screen
156 mypromptbox[s] = awful.widget.prompt()
157 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
158 -- We need one layoutbox per screen.
159 mylayoutbox[s] = awful.widget.layoutbox(s)
160 mylayoutbox[s]:buttons(awful.util.table.join(
161 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
162 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
163 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
164 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
165 -- Create a taglist widget
166 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
168 -- Create a tasklist widget
169 mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
171 -- Create the wibox
172 mywibox[s] = awful.wibox({ position = "top", screen = s })
174 -- Widgets that are aligned to the left
175 local left_layout = wibox.layout.fixed.horizontal()
176 left_layout:add(mylauncher)
177 left_layout:add(mytaglist[s])
178 left_layout:add(mypromptbox[s])
180 -- Widgets that are aligned to the right
181 local right_layout = wibox.layout.fixed.horizontal()
182 if s == 1 then right_layout:add(wibox.widget.systray()) end
183 right_layout:add(mytextclock)
184 right_layout:add(mylayoutbox[s])
186 -- Now bring it all together (with the tasklist in the middle)
187 local layout = wibox.layout.align.horizontal()
188 layout:set_left(left_layout)
189 layout:set_middle(mytasklist[s])
190 layout:set_right(right_layout)
192 mywibox[s]:set_widget(layout)
194 -- }}}
196 -- {{{ Mouse bindings
197 root.buttons(awful.util.table.join(
198 awful.button({ }, 3, function () mymainmenu:toggle() end),
199 awful.button({ }, 4, awful.tag.viewnext),
200 awful.button({ }, 5, awful.tag.viewprev)
202 -- }}}
204 -- {{{ Key bindings
205 globalkeys = awful.util.table.join(
206 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
207 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
208 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
210 awful.key({ modkey, }, "j",
211 function ()
212 awful.client.focus.byidx( 1)
213 if client.focus then client.focus:raise() end
214 end),
215 awful.key({ modkey, }, "k",
216 function ()
217 awful.client.focus.byidx(-1)
218 if client.focus then client.focus:raise() end
219 end),
220 awful.key({ modkey, }, "w", function () mymainmenu:show() end),
222 -- Layout manipulation
223 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
224 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
225 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
226 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
227 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
228 awful.key({ modkey, }, "Tab",
229 function ()
230 awful.client.focus.history.previous()
231 if client.focus then
232 client.focus:raise()
234 end),
236 -- Standard program
237 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
238 awful.key({ modkey, "Control" }, "r", awesome.restart),
239 awful.key({ modkey, "Shift" }, "q", awesome.quit),
241 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
242 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
243 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
244 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
245 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
246 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
247 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
248 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
250 awful.key({ modkey, "Control" }, "n", awful.client.restore),
252 -- Prompt
253 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
255 awful.key({ modkey }, "x",
256 function ()
257 awful.prompt.run({ prompt = "Run Lua code: " },
258 mypromptbox[mouse.screen].widget,
259 awful.util.eval, nil,
260 awful.util.getdir("cache") .. "/history_eval")
261 end),
262 -- Menubar
263 awful.key({ modkey }, "p", function() menubar.show() end)
266 clientkeys = awful.util.table.join(
267 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
268 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
269 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
270 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
271 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
272 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
273 awful.key({ modkey, }, "n",
274 function (c)
275 -- The client currently has the input focus, so it cannot be
276 -- minimized, since minimized clients can't have the focus.
277 c.minimized = true
278 end),
279 awful.key({ modkey, }, "m",
280 function (c)
281 c.maximized_horizontal = not c.maximized_horizontal
282 c.maximized_vertical = not c.maximized_vertical
283 end)
286 -- Compute the maximum number of digit we need, limited to 9
287 keynumber = 0
288 for s = 1, screen.count() do
289 keynumber = math.min(9, math.max(#tags[s], keynumber))
292 -- Bind all key numbers to tags.
293 -- Be careful: we use keycodes to make it works on any keyboard layout.
294 -- This should map on the top row of your keyboard, usually 1 to 9.
295 for i = 1, keynumber do
296 globalkeys = awful.util.table.join(globalkeys,
297 awful.key({ modkey }, "#" .. i + 9,
298 function ()
299 local screen = mouse.screen
300 if tags[screen][i] then
301 awful.tag.viewonly(tags[screen][i])
303 end),
304 awful.key({ modkey, "Control" }, "#" .. i + 9,
305 function ()
306 local screen = mouse.screen
307 if tags[screen][i] then
308 awful.tag.viewtoggle(tags[screen][i])
310 end),
311 awful.key({ modkey, "Shift" }, "#" .. i + 9,
312 function ()
313 if client.focus and tags[client.focus.screen][i] then
314 awful.client.movetotag(tags[client.focus.screen][i])
316 end),
317 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
318 function ()
319 if client.focus and tags[client.focus.screen][i] then
320 awful.client.toggletag(tags[client.focus.screen][i])
322 end))
325 clientbuttons = awful.util.table.join(
326 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
327 awful.button({ modkey }, 1, awful.mouse.client.move),
328 awful.button({ modkey }, 3, awful.mouse.client.resize))
330 -- Set keys
331 root.keys(globalkeys)
332 -- }}}
334 -- {{{ Rules
335 awful.rules.rules = {
336 -- All clients will match this rule.
337 { rule = { },
338 properties = { border_width = beautiful.border_width,
339 border_color = beautiful.border_normal,
340 focus = awful.client.focus.filter,
341 keys = clientkeys,
342 buttons = clientbuttons } },
343 { rule = { class = "MPlayer" },
344 properties = { floating = true } },
345 { rule = { class = "pinentry" },
346 properties = { floating = true } },
347 { rule = { class = "gimp" },
348 properties = { floating = true } },
349 -- Set Firefox to always map on tags number 2 of screen 1.
350 -- { rule = { class = "Firefox" },
351 -- properties = { tag = tags[1][2] } },
353 -- }}}
355 -- {{{ Signals
356 -- Signal function to execute when a new client appears.
357 client.connect_signal("manage", function (c, startup)
358 -- Enable sloppy focus
359 c:connect_signal("mouse::enter", function(c)
360 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
361 and awful.client.focus.filter(c) then
362 client.focus = c
364 end)
366 if not startup then
367 -- Set the windows at the slave,
368 -- i.e. put it at the end of others instead of setting it master.
369 -- awful.client.setslave(c)
371 -- Put windows in a smart way, only if they does not set an initial position.
372 if not c.size_hints.user_position and not c.size_hints.program_position then
373 awful.placement.no_overlap(c)
374 awful.placement.no_offscreen(c)
377 end)
379 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
380 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
381 -- }}}