awful.widget.taglist: remove needless taglist_squares conditions
[awesome.git] / awesomerc.lua.in
blobbd1e03e14d25e8c9910d5cfb64a7d40135fbaf14
1 -- Standard awesome library
2 require("awful")
3 -- Theme handling library
4 require("beautiful")
5 -- Notification library
6 require("naughty")
8 -- {{{ Variable definitions
9 -- Themes define colours, icons, and wallpapers
10 -- The default is a dark theme
11 theme_path = "@AWESOME_THEMES_PATH@/default/theme"
12 -- Uncommment this for a lighter theme
13 -- theme_path = "@AWESOME_THEMES_PATH@/sky/theme"
15 -- Actually load theme
16 beautiful.init(theme_path)
18 -- This is used later as the default terminal and editor to run.
19 terminal = "xterm"
20 editor = os.getenv("EDITOR") or "nano"
21 editor_cmd = terminal .. " -e " .. editor
23 -- Default modkey.
24 -- Usually, Mod4 is the key with a logo between Control and Alt.
25 -- If you do not like this or do not have such a key,
26 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
27 -- However, you can use another modifier like Mod1, but it may interact with others.
28 modkey = "Mod4"
30 -- Table of layouts to cover with awful.layout.inc, order matters.
31 layouts =
33 awful.layout.suit.tile,
34 awful.layout.suit.tile.left,
35 awful.layout.suit.tile.bottom,
36 awful.layout.suit.tile.top,
37 awful.layout.suit.fair,
38 awful.layout.suit.fair.horizontal,
39 awful.layout.suit.max,
40 awful.layout.suit.max.fullscreen,
41 awful.layout.suit.magnifier,
42 awful.layout.suit.floating
45 -- Table of clients that should be set floating. The index may be either
46 -- the application class or instance. The instance is useful when running
47 -- a console app in a terminal like (Music on Console)
48 -- xterm -name mocp -e mocp
49 floatapps =
51 -- by class
52 ["MPlayer"] = true,
53 ["pinentry"] = true,
54 ["gimp"] = true,
55 -- by instance
56 ["mocp"] = true
59 -- Applications to be moved to a pre-defined tag by class or instance.
60 -- Use the screen and tags indices.
61 apptags =
63 -- ["Firefox"] = { screen = 1, tag = 2 },
64 -- ["mocp"] = { screen = 2, tag = 4 },
67 -- Define if we want to use titlebar on all applications.
68 use_titlebar = false
69 -- }}}
71 -- {{{ Tags
72 -- Define tags table.
73 tags = {}
74 for s = 1, screen.count() do
75 -- Each screen has its own tag table.
76 tags[s] = {}
77 -- Create 9 tags per screen.
78 for tagnumber = 1, 9 do
79 tags[s][tagnumber] = tag(tagnumber)
80 -- Add tags to screen one by one
81 tags[s][tagnumber].screen = s
82 awful.layout.set(layouts[1], tags[s][tagnumber])
83 end
84 -- I'm sure you want to see at least one tag.
85 tags[s][1].selected = true
86 end
87 -- }}}
89 -- {{{ Wibox
90 -- Create a textbox widget
91 mytextbox = widget({ type = "textbox", align = "right" })
92 -- Set the default text in textbox
93 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
95 -- Create a laucher widget and a main menu
96 myawesomemenu = {
97 { "manual", terminal .. " -e man awesome" },
98 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
99 { "restart", awesome.restart },
100 { "quit", awesome.quit }
103 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
104 { "open terminal", terminal }
108 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
109 menu = mymainmenu })
111 -- Create a systray
112 mysystray = widget({ type = "systray", align = "right" })
114 -- Create a wibox for each screen and add it
115 mywibox = {}
116 mypromptbox = {}
117 mylayoutbox = {}
118 mytaglist = {}
119 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
120 button({ modkey }, 1, awful.client.movetotag),
121 button({ }, 3, function (tag) tag.selected = not tag.selected end),
122 button({ modkey }, 3, awful.client.toggletag),
123 button({ }, 4, awful.tag.viewnext),
124 button({ }, 5, awful.tag.viewprev) }
125 mytasklist = {}
126 mytasklist.buttons = { button({ }, 1, function (c)
127 if not c:isvisible() then
128 awful.tag.viewonly(c:tags()[1])
130 client.focus = c
131 c:raise()
132 end),
133 button({ }, 3, function () if instance then instance:hide() instance = nil else instance = awful.menu.clients({ width=250 }) end end),
134 button({ }, 4, function ()
135 awful.client.focus.byidx(1)
136 if client.focus then client.focus:raise() end
137 end),
138 button({ }, 5, function ()
139 awful.client.focus.byidx(-1)
140 if client.focus then client.focus:raise() end
141 end) }
143 for s = 1, screen.count() do
144 -- Create a promptbox for each screen
145 mypromptbox[s] = widget({ type = "textbox", align = "left" })
146 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
147 -- We need one layoutbox per screen.
148 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
149 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
150 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
151 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
152 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
153 -- Create a taglist widget
154 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
156 -- Create a tasklist widget
157 mytasklist[s] = awful.widget.tasklist.new(function(c)
158 return awful.widget.tasklist.label.currenttags(c, s)
159 end, mytasklist.buttons)
161 -- Create the wibox
162 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
163 -- Add widgets to the wibox - order matters
164 mywibox[s].widgets = { mylauncher,
165 mytaglist[s],
166 mytasklist[s],
167 mypromptbox[s],
168 mytextbox,
169 mylayoutbox[s],
170 s == 1 and mysystray or nil }
171 mywibox[s].screen = s
173 -- }}}
175 -- {{{ Mouse bindings
176 root.buttons({
177 button({ }, 3, function () mymainmenu:toggle() end),
178 button({ }, 4, awful.tag.viewnext),
179 button({ }, 5, awful.tag.viewprev)
181 -- }}}
183 -- {{{ Key bindings
184 globalkeys =
186 key({ modkey, }, "Left", awful.tag.viewprev ),
187 key({ modkey, }, "Right", awful.tag.viewnext ),
188 key({ modkey, }, "Escape", awful.tag.history.restore),
190 key({ modkey, }, "j",
191 function ()
192 awful.client.focus.byidx( 1)
193 if client.focus then client.focus:raise() end
194 end),
195 key({ modkey, }, "k",
196 function ()
197 awful.client.focus.byidx(-1)
198 if client.focus then client.focus:raise() end
199 end),
200 key({ modkey, }, "w", function () mymainmenu:show(true) end),
202 -- Layout manipulation
203 key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
204 key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
205 key({ modkey, "Control" }, "j", function () awful.screen.focus( 1) end),
206 key({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end),
207 key({ modkey, }, "u", awful.client.urgent.jumpto),
208 key({ modkey, }, "Tab",
209 function ()
210 awful.client.focus.history.previous()
211 if client.focus then
212 client.focus:raise()
214 end),
216 -- Standard program
217 key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
218 key({ modkey, "Control" }, "r", awesome.restart),
219 key({ modkey, "Shift" }, "q", awesome.quit),
221 key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
222 key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
223 key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
224 key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
225 key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
226 key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
227 key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
228 key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
230 -- Prompt
231 key({ modkey }, "F1",
232 function ()
233 awful.prompt.run({ prompt = "Run: " },
234 mypromptbox[mouse.screen],
235 awful.util.spawn, awful.completion.shell,
236 awful.util.getdir("cache") .. "/history")
237 end),
239 key({ modkey }, "F4",
240 function ()
241 awful.prompt.run({ prompt = "Run Lua code: " },
242 mypromptbox[mouse.screen],
243 awful.util.eval, nil,
244 awful.util.getdir("cache") .. "/history_eval")
245 end),
248 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
249 clientkeys =
251 key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
252 key({ modkey, "Shift" }, "c", function (c) c:kill() end),
253 key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
254 key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
255 key({ modkey, }, "o", awful.client.movetoscreen ),
256 key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
257 key({ modkey }, "t", awful.client.togglemarked),
258 key({ modkey,}, "m",
259 function (c)
260 c.maximized_horizontal = not c.maximized_horizontal
261 c.maximized_vertical = not c.maximized_vertical
262 end),
265 -- Compute the maximum number of digit we need, limited to 9
266 keynumber = 0
267 for s = 1, screen.count() do
268 keynumber = math.min(9, math.max(#tags[s], keynumber));
271 for i = 1, keynumber do
272 table.insert(globalkeys,
273 key({ modkey }, i,
274 function ()
275 local screen = mouse.screen
276 if tags[screen][i] then
277 awful.tag.viewonly(tags[screen][i])
279 end))
280 table.insert(globalkeys,
281 key({ modkey, "Control" }, i,
282 function ()
283 local screen = mouse.screen
284 if tags[screen][i] then
285 tags[screen][i].selected = not tags[screen][i].selected
287 end))
288 table.insert(globalkeys,
289 key({ modkey, "Shift" }, i,
290 function ()
291 if client.focus and tags[client.focus.screen][i] then
292 awful.client.movetotag(tags[client.focus.screen][i])
294 end))
295 table.insert(globalkeys,
296 key({ modkey, "Control", "Shift" }, i,
297 function ()
298 if client.focus and tags[client.focus.screen][i] then
299 awful.client.toggletag(tags[client.focus.screen][i])
301 end))
302 table.insert(globalkeys,
303 key({ modkey, "Shift" }, "F" .. i,
304 function ()
305 local screen = mouse.screen
306 if tags[screen][i] then
307 for k, c in pairs(awful.client.getmarked()) do
308 awful.client.movetotag(tags[screen][i], c)
311 end))
315 -- Set keys
316 root.keys(globalkeys)
317 -- }}}
319 -- {{{ Hooks
320 -- Hook function to execute when focusing a client.
321 awful.hooks.focus.register(function (c)
322 if not awful.client.ismarked(c) then
323 c.border_color = beautiful.border_focus
325 end)
327 -- Hook function to execute when unfocusing a client.
328 awful.hooks.unfocus.register(function (c)
329 if not awful.client.ismarked(c) then
330 c.border_color = beautiful.border_normal
332 end)
334 -- Hook function to execute when marking a client
335 awful.hooks.marked.register(function (c)
336 c.border_color = beautiful.border_marked
337 end)
339 -- Hook function to execute when unmarking a client.
340 awful.hooks.unmarked.register(function (c)
341 c.border_color = beautiful.border_focus
342 end)
344 -- Hook function to execute when the mouse enters a client.
345 awful.hooks.mouse_enter.register(function (c)
346 -- Sloppy focus, but disabled for magnifier layout
347 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
348 and awful.client.focus.filter(c) then
349 client.focus = c
351 end)
353 -- Hook function to execute when a new client appears.
354 awful.hooks.manage.register(function (c, startup)
355 -- If we are not managing this application at startup,
356 -- move it to the screen where the mouse is.
357 -- We only do it for filtered windows (i.e. no dock, etc).
358 if not startup and awful.client.focus.filter(c) then
359 c.screen = mouse.screen
362 if use_titlebar then
363 -- Add a titlebar
364 awful.titlebar.add(c, { modkey = modkey })
366 -- Add mouse bindings
367 c:buttons({
368 button({ }, 1, function (c) client.focus = c; c:raise() end),
369 button({ modkey }, 1, awful.mouse.client.move),
370 button({ modkey }, 3, awful.mouse.client.resize)
372 -- New client may not receive focus
373 -- if they're not focusable, so set border anyway.
374 c.border_width = beautiful.border_width
375 c.border_color = beautiful.border_normal
377 -- Check if the application should be floating.
378 local cls = c.class
379 local inst = c.instance
380 if floatapps[cls] then
381 awful.client.floating.set(c, floatapps[cls])
382 elseif floatapps[inst] then
383 awful.client.floating.set(c, floatapps[inst])
386 -- Check application->screen/tag mappings.
387 local target
388 if apptags[cls] then
389 target = apptags[cls]
390 elseif apptags[inst] then
391 target = apptags[inst]
393 if target then
394 c.screen = target.screen
395 awful.client.movetotag(tags[target.screen][target.tag], c)
398 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
399 client.focus = c
401 -- Set key bindings
402 c:keys(clientkeys)
404 -- Set the windows at the slave,
405 -- i.e. put it at the end of others instead of setting it master.
406 -- awful.client.setslave(c)
408 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
409 -- c.size_hints_honor = false
410 end)
412 -- Hook function to execute when arranging the screen.
413 -- (tag switch, new client, etc)
414 awful.hooks.arrange.register(function (screen)
415 local layout = awful.layout.getname(awful.layout.get(screen))
416 if layout and beautiful["layout_" ..layout] then
417 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
418 else
419 mylayoutbox[screen].image = nil
422 -- Give focus to the latest client in history if no window has focus
423 -- or if the current window is a desktop or a dock one.
424 if not client.focus then
425 local c = awful.client.focus.history.get(screen, 0)
426 if c then client.focus = c end
428 end)
430 -- Hook called every minute
431 awful.hooks.timer.register(60, function ()
432 mytextbox.text = os.date(" %a %b %d, %H:%M ")
433 end)
434 -- }}}