client: disallow client border change when fullscreen
[awesome.git] / awesomerc.lua.in
blob414c1397a017c2933f3d2384823bb2456798c6df
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 -- Themes define colours, icons, and wallpapers
11 -- The default is a dark theme
12 theme_path = "@AWESOME_THEMES_PATH@/default/theme.lua"
13 -- Uncommment this for a lighter theme
14 -- theme_path = "@AWESOME_THEMES_PATH@/sky/theme.lua"
16 -- Actually load theme
17 beautiful.init(theme_path)
19 -- This is used later as the default terminal and editor to run.
20 terminal = "xterm"
21 editor = os.getenv("EDITOR") or "nano"
22 editor_cmd = terminal .. " -e " .. editor
24 -- Default modkey.
25 -- Usually, Mod4 is the key with a logo between Control and Alt.
26 -- If you do not like this or do not have such a key,
27 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
28 -- However, you can use another modifier like Mod1, but it may interact with others.
29 modkey = "Mod4"
31 -- Table of layouts to cover with awful.layout.inc, order matters.
32 layouts =
34 awful.layout.suit.tile,
35 awful.layout.suit.tile.left,
36 awful.layout.suit.tile.bottom,
37 awful.layout.suit.tile.top,
38 awful.layout.suit.fair,
39 awful.layout.suit.fair.horizontal,
40 awful.layout.suit.spiral,
41 awful.layout.suit.spiral.dwindle,
42 awful.layout.suit.max,
43 awful.layout.suit.max.fullscreen,
44 awful.layout.suit.magnifier,
45 awful.layout.suit.floating
48 -- Table of clients that should be set floating. The index may be either
49 -- the application class or instance. The instance is useful when running
50 -- a console app in a terminal like (Music on Console)
51 -- xterm -name mocp -e mocp
52 floatapps =
54 -- by class
55 ["MPlayer"] = true,
56 ["pinentry"] = true,
57 ["gimp"] = true,
58 -- by instance
59 ["mocp"] = true
62 -- Applications to be moved to a pre-defined tag by class or instance.
63 -- Use the screen and tags indices.
64 apptags =
66 -- ["Firefox"] = { screen = 1, tag = 2 },
67 -- ["mocp"] = { screen = 2, tag = 4 },
70 -- Define if we want to use titlebar on all applications.
71 use_titlebar = false
72 -- }}}
74 -- {{{ Tags
75 -- Define tags table.
76 tags = {}
77 for s = 1, screen.count() do
78 -- Each screen has its own tag table.
79 tags[s] = {}
80 -- Create 9 tags per screen.
81 for tagnumber = 1, 9 do
82 tags[s][tagnumber] = tag { name = tagnumber }
83 -- Add tags to screen one by one
84 tags[s][tagnumber].screen = s
85 awful.layout.set(layouts[1], tags[s][tagnumber])
86 end
87 -- I'm sure you want to see at least one tag.
88 tags[s][1].selected = true
89 end
90 -- }}}
92 -- {{{ Wibox
93 -- Create a textclock widget
94 mytextclock = awful.widget.textclock({ align = "right" })
96 -- Create a laucher widget and a main menu
97 myawesomemenu = {
98 { "manual", terminal .. " -e man awesome" },
99 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
100 { "restart", awesome.restart },
101 { "quit", awesome.quit }
104 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
105 { "open terminal", terminal }
109 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
110 menu = mymainmenu })
112 -- Create a systray
113 mysystray = widget({ type = "systray" })
115 -- Create a wibox for each screen and add it
116 mywibox = {}
117 mypromptbox = {}
118 mylayoutbox = {}
119 mytaglist = {}
120 mytaglist.buttons = awful.util.table.join(
121 awful.button({ }, 1, awful.tag.viewonly),
122 awful.button({ modkey }, 1, awful.client.movetotag),
123 awful.button({ }, 3, function (tag) tag.selected = not tag.selected end),
124 awful.button({ modkey }, 3, awful.client.toggletag),
125 awful.button({ }, 4, awful.tag.viewnext),
126 awful.button({ }, 5, awful.tag.viewprev)
128 mytasklist = {}
129 mytasklist.buttons = awful.util.table.join(
130 awful.button({ }, 1, function (c)
131 if not c:isvisible() then
132 awful.tag.viewonly(c:tags()[1])
134 client.focus = c
135 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({ layout = awful.widget.layout.leftright })
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.label.all, mytaglist.buttons)
168 -- Create a tasklist widget
169 mytasklist[s] = awful.widget.tasklist(function(c)
170 return awful.widget.tasklist.label.currenttags(c, s)
171 end, mytasklist.buttons)
173 -- Create the wibox
174 mywibox[s] = awful.wibox({ position = "top", screen = s })
175 -- Add widgets to the wibox - order matters
176 mywibox[s].widgets = {
178 mylauncher,
179 mytaglist[s],
180 mypromptbox[s],
181 layout = awful.widget.layout.horizontal.leftright
183 mylayoutbox[s],
184 mytextclock,
185 s == 1 and mysystray or nil,
186 mytasklist[s],
187 layout = awful.widget.layout.horizontal.rightleft
190 -- }}}
192 -- {{{ Mouse bindings
193 root.buttons(awful.util.table.join(
194 awful.button({ }, 3, function () mymainmenu:toggle() end),
195 awful.button({ }, 4, awful.tag.viewnext),
196 awful.button({ }, 5, awful.tag.viewprev)
198 -- }}}
200 -- {{{ Key bindings
201 globalkeys = awful.util.table.join(
202 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
203 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
204 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
206 awful.key({ modkey, }, "j",
207 function ()
208 awful.client.focus.byidx( 1)
209 if client.focus then client.focus:raise() end
210 end),
211 awful.key({ modkey, }, "k",
212 function ()
213 awful.client.focus.byidx(-1)
214 if client.focus then client.focus:raise() end
215 end),
216 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
218 -- Layout manipulation
219 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
220 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
221 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus( 1) end),
222 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end),
223 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
224 awful.key({ modkey, }, "Tab",
225 function ()
226 awful.client.focus.history.previous()
227 if client.focus then
228 client.focus:raise()
230 end),
232 -- Standard program
233 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
234 awful.key({ modkey, "Control" }, "r", awesome.restart),
235 awful.key({ modkey, "Shift" }, "q", awesome.quit),
237 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
238 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
239 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
240 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
241 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
242 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
243 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
244 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
246 -- Prompt
247 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
249 awful.key({ modkey }, "x",
250 function ()
251 awful.prompt.run({ prompt = "Run Lua code: " },
252 mypromptbox[mouse.screen].widget,
253 awful.util.eval, nil,
254 awful.util.getdir("cache") .. "/history_eval")
255 end)
258 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
259 clientkeys = awful.util.table.join(
260 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
261 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
262 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
263 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
264 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
265 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
266 awful.key({ modkey,}, "m",
267 function (c)
268 c.maximized_horizontal = not c.maximized_horizontal
269 c.maximized_vertical = not c.maximized_vertical
270 end)
273 -- Compute the maximum number of digit we need, limited to 9
274 keynumber = 0
275 for s = 1, screen.count() do
276 keynumber = math.min(9, math.max(#tags[s], keynumber));
279 for i = 1, keynumber do
280 globalkeys = awful.util.table.join(globalkeys,
281 awful.key({ modkey }, i,
282 function ()
283 local screen = mouse.screen
284 if tags[screen][i] then
285 awful.tag.viewonly(tags[screen][i])
287 end),
288 awful.key({ modkey, "Control" }, i,
289 function ()
290 local screen = mouse.screen
291 if tags[screen][i] then
292 tags[screen][i].selected = not tags[screen][i].selected
294 end),
295 awful.key({ modkey, "Shift" }, i,
296 function ()
297 if client.focus and tags[client.focus.screen][i] then
298 awful.client.movetotag(tags[client.focus.screen][i])
300 end),
301 awful.key({ modkey, "Control", "Shift" }, i,
302 function ()
303 if client.focus and tags[client.focus.screen][i] then
304 awful.client.toggletag(tags[client.focus.screen][i])
306 end))
309 -- Set keys
310 root.keys(globalkeys)
311 -- }}}
313 -- {{{ Signals
314 -- Signal function to execute when a new client appears.
315 client.add_signal("manage", function (c, startup)
316 -- If we are not managing this application at startup,
317 -- move it to the screen where the mouse is.
318 -- We only do it for filtered windows (i.e. no dock, etc).
319 if not startup and awful.client.focus.filter(c) then
320 c.screen = mouse.screen
323 if use_titlebar then
324 -- Add a titlebar
325 awful.titlebar.add(c, { modkey = modkey })
327 -- Add mouse bindings
328 c:buttons(awful.util.table.join(
329 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
330 awful.button({ modkey }, 1, awful.mouse.client.move),
331 awful.button({ modkey }, 3, awful.mouse.client.resize)
333 -- New client may not receive focus
334 -- if they're not focusable, so set border anyway.
335 c.border_width = beautiful.border_width
336 c.border_color = beautiful.border_normal
338 -- Check if the application should be floating.
339 local cls = c.class
340 local inst = c.instance
341 if floatapps[cls] ~= nil then
342 awful.client.floating.set(c, floatapps[cls])
343 elseif floatapps[inst] ~= nil then
344 awful.client.floating.set(c, floatapps[inst])
347 -- Check application->screen/tag mappings.
348 local target
349 if apptags[cls] then
350 target = apptags[cls]
351 elseif apptags[inst] then
352 target = apptags[inst]
354 if target then
355 c.screen = target.screen
356 awful.client.movetotag(tags[target.screen][target.tag], c)
359 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
360 client.focus = c
362 -- Set key bindings
363 c:keys(clientkeys)
365 -- Enable sloppy focus
366 c:add_signal("mouse::enter", function(c)
367 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
368 and awful.client.focus.filter(c) then
369 client.focus = c
371 end)
373 -- Set the windows at the slave,
374 -- i.e. put it at the end of others instead of setting it master.
375 -- awful.client.setslave(c)
377 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
378 -- c.size_hints_honor = false
379 end)
380 -- }}}