awesomerc: stop handling beautiful
[awesome.git] / awesomerc.lua.in
blobb1239316412238e4c3d5bd78d1c6e0144b3383f7
1 -- Standard awesome library
2 require("awful")
3 require("awful.autofocus")
4 -- Theme handling library
5 require("beautiful")
6 -- Notification library
7 require("naughty")
9 -- {{{ Variable definitions
10 -- This is used later as the default terminal and editor to run.
11 terminal = "xterm"
12 editor = os.getenv("EDITOR") or "nano"
13 editor_cmd = terminal .. " -e " .. editor
15 -- Default modkey.
16 -- Usually, Mod4 is the key with a logo between Control and Alt.
17 -- If you do not like this or do not have such a key,
18 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
19 -- However, you can use another modifier like Mod1, but it may interact with others.
20 modkey = "Mod4"
22 -- Table of layouts to cover with awful.layout.inc, order matters.
23 layouts =
25 awful.layout.suit.tile,
26 awful.layout.suit.tile.left,
27 awful.layout.suit.tile.bottom,
28 awful.layout.suit.tile.top,
29 awful.layout.suit.fair,
30 awful.layout.suit.fair.horizontal,
31 awful.layout.suit.spiral,
32 awful.layout.suit.spiral.dwindle,
33 awful.layout.suit.max,
34 awful.layout.suit.max.fullscreen,
35 awful.layout.suit.magnifier,
36 awful.layout.suit.floating
39 -- Table of clients that should be set floating. The index may be either
40 -- the application class or instance. The instance is useful when running
41 -- a console app in a terminal like (Music on Console)
42 -- xterm -name mocp -e mocp
43 floatapps =
45 -- by class
46 ["MPlayer"] = true,
47 ["pinentry"] = true,
48 ["gimp"] = true,
49 -- by instance
50 ["mocp"] = true
53 -- Applications to be moved to a pre-defined tag by class or instance.
54 -- Use the screen and tags indices.
55 apptags =
57 -- ["Firefox"] = { screen = 1, tag = 2 },
58 -- ["mocp"] = { screen = 2, tag = 4 },
61 -- Define if we want to use titlebar on all applications.
62 use_titlebar = false
63 -- }}}
65 -- {{{ Tags
66 -- Define a tag table which hold all screen tags.
67 tags = {}
68 for s = 1, screen.count() do
69 -- Each screen has its own tag table.
70 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s)
71 end
72 -- }}}
74 -- {{{ Wibox
75 -- Create a textclock widget
76 mytextclock = awful.widget.textclock({ align = "right" })
78 -- Create a laucher widget and a main menu
79 myawesomemenu = {
80 { "manual", terminal .. " -e man awesome" },
81 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
82 { "restart", awesome.restart },
83 { "quit", awesome.quit }
86 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
87 { "open terminal", terminal }
91 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
92 menu = mymainmenu })
94 -- Create a systray
95 mysystray = widget({ type = "systray" })
97 -- Create a wibox for each screen and add it
98 mywibox = {}
99 mypromptbox = {}
100 mylayoutbox = {}
101 mytaglist = {}
102 mytaglist.buttons = awful.util.table.join(
103 awful.button({ }, 1, awful.tag.viewonly),
104 awful.button({ modkey }, 1, awful.client.movetotag),
105 awful.button({ }, 3, function (tag) tag.selected = not tag.selected end),
106 awful.button({ modkey }, 3, awful.client.toggletag),
107 awful.button({ }, 4, awful.tag.viewnext),
108 awful.button({ }, 5, awful.tag.viewprev)
110 mytasklist = {}
111 mytasklist.buttons = awful.util.table.join(
112 awful.button({ }, 1, function (c)
113 if not c:isvisible() then
114 awful.tag.viewonly(c:tags()[1])
116 client.focus = c
117 c:raise()
118 end),
119 awful.button({ }, 3, function ()
120 if instance then
121 instance:hide()
122 instance = nil
123 else
124 instance = awful.menu.clients({ width=250 })
126 end),
127 awful.button({ }, 4, function ()
128 awful.client.focus.byidx(1)
129 if client.focus then client.focus:raise() end
130 end),
131 awful.button({ }, 5, function ()
132 awful.client.focus.byidx(-1)
133 if client.focus then client.focus:raise() end
134 end))
136 for s = 1, screen.count() do
137 -- Create a promptbox for each screen
138 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.leftright })
139 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
140 -- We need one layoutbox per screen.
141 mylayoutbox[s] = awful.widget.layoutbox(s)
142 mylayoutbox[s]:buttons(awful.util.table.join(
143 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
144 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
145 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
146 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
147 -- Create a taglist widget
148 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
150 -- Create a tasklist widget
151 mytasklist[s] = awful.widget.tasklist(function(c)
152 return awful.widget.tasklist.label.currenttags(c, s)
153 end, mytasklist.buttons)
155 -- Create the wibox
156 mywibox[s] = awful.wibox({ position = "top", screen = s })
157 -- Add widgets to the wibox - order matters
158 mywibox[s].widgets = {
160 mylauncher,
161 mytaglist[s],
162 mypromptbox[s],
163 layout = awful.widget.layout.horizontal.leftright
165 mylayoutbox[s],
166 mytextclock,
167 s == 1 and mysystray or nil,
168 mytasklist[s],
169 layout = awful.widget.layout.horizontal.rightleft
172 -- }}}
174 -- {{{ Mouse bindings
175 root.buttons(awful.util.table.join(
176 awful.button({ }, 3, function () mymainmenu:toggle() end),
177 awful.button({ }, 4, awful.tag.viewnext),
178 awful.button({ }, 5, awful.tag.viewprev)
180 -- }}}
182 -- {{{ Key bindings
183 globalkeys = awful.util.table.join(
184 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
185 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
186 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
188 awful.key({ modkey, }, "j",
189 function ()
190 awful.client.focus.byidx( 1)
191 if client.focus then client.focus:raise() end
192 end),
193 awful.key({ modkey, }, "k",
194 function ()
195 awful.client.focus.byidx(-1)
196 if client.focus then client.focus:raise() end
197 end),
198 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
200 -- Layout manipulation
201 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
202 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
203 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus( 1) end),
204 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end),
205 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
206 awful.key({ modkey, }, "Tab",
207 function ()
208 awful.client.focus.history.previous()
209 if client.focus then
210 client.focus:raise()
212 end),
214 -- Standard program
215 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
216 awful.key({ modkey, "Control" }, "r", awesome.restart),
217 awful.key({ modkey, "Shift" }, "q", awesome.quit),
219 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
220 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
221 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
222 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
223 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
224 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
225 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
226 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
228 -- Prompt
229 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
231 awful.key({ modkey }, "x",
232 function ()
233 awful.prompt.run({ prompt = "Run Lua code: " },
234 mypromptbox[mouse.screen].widget,
235 awful.util.eval, nil,
236 awful.util.getdir("cache") .. "/history_eval")
237 end)
240 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
241 clientkeys = awful.util.table.join(
242 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
243 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
244 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
245 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
246 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
247 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
248 awful.key({ modkey,}, "m",
249 function (c)
250 c.maximized_horizontal = not c.maximized_horizontal
251 c.maximized_vertical = not c.maximized_vertical
252 end)
255 -- Compute the maximum number of digit we need, limited to 9
256 keynumber = 0
257 for s = 1, screen.count() do
258 keynumber = math.min(9, math.max(#tags[s], keynumber));
261 for i = 1, keynumber do
262 globalkeys = awful.util.table.join(globalkeys,
263 awful.key({ modkey }, i,
264 function ()
265 local screen = mouse.screen
266 if tags[screen][i] then
267 awful.tag.viewonly(tags[screen][i])
269 end),
270 awful.key({ modkey, "Control" }, i,
271 function ()
272 local screen = mouse.screen
273 if tags[screen][i] then
274 tags[screen][i].selected = not tags[screen][i].selected
276 end),
277 awful.key({ modkey, "Shift" }, i,
278 function ()
279 if client.focus and tags[client.focus.screen][i] then
280 awful.client.movetotag(tags[client.focus.screen][i])
282 end),
283 awful.key({ modkey, "Control", "Shift" }, i,
284 function ()
285 if client.focus and tags[client.focus.screen][i] then
286 awful.client.toggletag(tags[client.focus.screen][i])
288 end))
291 -- Set keys
292 root.keys(globalkeys)
293 -- }}}
295 -- {{{ Signals
296 -- Signal function to execute when a new client appears.
297 client.add_signal("manage", function (c, startup)
298 -- If we are not managing this application at startup,
299 -- move it to the screen where the mouse is.
300 -- We only do it for filtered windows (i.e. no dock, etc).
301 if not startup and awful.client.focus.filter(c) then
302 c.screen = mouse.screen
305 if use_titlebar then
306 -- Add a titlebar
307 awful.titlebar.add(c, { modkey = modkey })
309 -- Add mouse bindings
310 c:buttons(awful.util.table.join(
311 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
312 awful.button({ modkey }, 1, awful.mouse.client.move),
313 awful.button({ modkey }, 3, awful.mouse.client.resize)
315 -- New client may not receive focus
316 -- if they're not focusable, so set border anyway.
317 c.border_width = beautiful.border_width
318 c.border_color = beautiful.border_normal
320 -- Check if the application should be floating.
321 local cls = c.class
322 local inst = c.instance
323 if floatapps[cls] ~= nil then
324 awful.client.floating.set(c, floatapps[cls])
325 elseif floatapps[inst] ~= nil then
326 awful.client.floating.set(c, floatapps[inst])
329 -- Check application->screen/tag mappings.
330 local target
331 if apptags[cls] then
332 target = apptags[cls]
333 elseif apptags[inst] then
334 target = apptags[inst]
336 if target then
337 c.screen = target.screen
338 awful.client.movetotag(tags[target.screen][target.tag], c)
341 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
342 client.focus = c
344 -- Set key bindings
345 c:keys(clientkeys)
347 -- Enable sloppy focus
348 c:add_signal("mouse::enter", function(c)
349 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
350 and awful.client.focus.filter(c) then
351 client.focus = c
353 end)
355 -- Set the windows at the slave,
356 -- i.e. put it at the end of others instead of setting it master.
357 -- awful.client.setslave(c)
359 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
360 -- c.size_hints_honor = false
361 end)
362 -- }}}