client: fix translator for fixed window, add BELOW (FS#377)
[awesome.git] / awesomerc.lua.in
blobcd7b11bcb43b188212917ed4b1b1cff48d23980f
1 -- Include awesome libraries, with lots of useful function!
2 require("awful")
3 require("beautiful")
5 -- {{{ Variable definitions
6 -- Themes define colours, icons, and wallpapers
7 -- The default is a dark theme
8 theme_path = "@AWESOME_THEMES_PATH@/default/theme"
9 -- Uncommment this for a lighter theme
10 -- theme_path = "@AWESOME_THEMES_PATH@/sky/theme"
12 -- Actually load theme
13 beautiful.init(theme_path)
15 -- This is used later as the default terminal and editor to run.
16 terminal = "xterm"
17 editor = os.getenv("EDITOR") or "nano"
18 editor_cmd = terminal .. " -e " .. editor
20 -- Default modkey.
21 -- Usually, Mod4 is the key with a logo between Control and Alt.
22 -- If you do not like this or do not have such a key,
23 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
24 -- However, you can use another modifier like Mod1, but it may interact with others.
25 modkey = "Mod4"
27 -- Table of layouts to cover with awful.layout.inc, order matters.
28 layouts =
30 "tile",
31 "tileleft",
32 "tilebottom",
33 "tiletop",
34 "fairh",
35 "fairv",
36 "magnifier",
37 "max",
38 "fullscreen",
39 "spiral",
40 "dwindle",
41 "floating"
44 -- Table of clients that should be set floating. The index may be either
45 -- the application class or instance. The instance is useful when running
46 -- a console app in a terminal like (Music on Console)
47 -- xterm -name mocp -e mocp
48 floatapps =
50 -- by class
51 ["MPlayer"] = true,
52 ["pinentry"] = true,
53 ["gimp"] = true,
54 -- by instance
55 ["mocp"] = true
58 -- Applications to be moved to a pre-defined tag by class or instance.
59 -- Use the screen and tags indices.
60 apptags =
62 -- ["Firefox"] = { screen = 1, tag = 2 },
63 -- ["mocp"] = { screen = 2, tag = 4 },
66 -- Define if we want to use titlebar on all applications.
67 use_titlebar = false
68 -- }}}
70 -- {{{ Tags
71 -- Define tags table.
72 tags = {}
73 for s = 1, screen.count() do
74 -- Each screen has its own tag table.
75 tags[s] = {}
76 -- Create 9 tags per screen.
77 for tagnumber = 1, 9 do
78 tags[s][tagnumber] = tag({ name = tagnumber, layout = layouts[1] })
79 -- Add tags to screen one by one
80 tags[s][tagnumber].screen = s
81 end
82 -- I'm sure you want to see at least one tag.
83 tags[s][1].selected = true
84 end
85 -- }}}
87 -- {{{ Wibox
88 -- Create a textbox widget
89 mytextbox = widget({ type = "textbox", align = "right" })
90 -- Set the default text in textbox
91 mytextbox.text = "<b><small> " .. AWESOME_RELEASE .. " </small></b>"
93 -- Create a laucher widget and a main menu
94 myawesomemenu = {
95 { "manual", terminal .. " -e man awesome" },
96 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
97 { "restart", awesome.restart },
98 { "quit", awesome.quit }
101 mymainmenu = awful.menu.new({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
102 { "open terminal", terminal }
106 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
107 menu = mymainmenu })
109 -- Create a systray
110 mysystray = widget({ type = "systray", align = "right" })
112 -- Create a wibox for each screen and add it
113 mywibox = {}
114 mypromptbox = {}
115 mylayoutbox = {}
116 mytaglist = {}
117 mytaglist.buttons = { button({ }, 1, awful.tag.viewonly),
118 button({ modkey }, 1, awful.client.movetotag),
119 button({ }, 3, function (tag) tag.selected = not tag.selected end),
120 button({ modkey }, 3, awful.client.toggletag),
121 button({ }, 4, awful.tag.viewnext),
122 button({ }, 5, awful.tag.viewprev) }
123 mytasklist = {}
124 mytasklist.buttons = { button({ }, 1, function (c) client.focus = c; c:raise() end),
125 button({ }, 3, function () awful.menu.clients({ width=250 }) end),
126 button({ }, 4, function () awful.client.focus.byidx(1) end),
127 button({ }, 5, function () awful.client.focus.byidx(-1) end) }
129 for s = 1, screen.count() do
130 -- Create a promptbox for each screen
131 mypromptbox[s] = widget({ type = "textbox", align = "left" })
132 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
133 -- We need one layoutbox per screen.
134 mylayoutbox[s] = widget({ type = "imagebox", align = "right" })
135 mylayoutbox[s]:buttons({ button({ }, 1, function () awful.layout.inc(layouts, 1) end),
136 button({ }, 3, function () awful.layout.inc(layouts, -1) end),
137 button({ }, 4, function () awful.layout.inc(layouts, 1) end),
138 button({ }, 5, function () awful.layout.inc(layouts, -1) end) })
139 -- Create a taglist widget
140 mytaglist[s] = awful.widget.taglist.new(s, awful.widget.taglist.label.all, mytaglist.buttons)
142 -- Create a tasklist widget
143 mytasklist[s] = awful.widget.tasklist.new(function(c)
144 return awful.widget.tasklist.label.currenttags(c, s)
145 end, mytasklist.buttons)
147 -- Create the wibox
148 mywibox[s] = wibox({ position = "top", fg = beautiful.fg_normal, bg = beautiful.bg_normal })
149 -- Add widgets to the wibox - order matters
150 mywibox[s].widgets = { mylauncher,
151 mytaglist[s],
152 mytasklist[s],
153 mypromptbox[s],
154 mytextbox,
155 mylayoutbox[s],
156 s == 1 and mysystray or nil }
157 mywibox[s].screen = s
159 -- }}}
161 -- {{{ Mouse bindings
162 awesome.buttons({
163 button({ }, 3, function () mymainmenu:toggle() end),
164 button({ }, 4, awful.tag.viewnext),
165 button({ }, 5, awful.tag.viewprev)
167 -- }}}
169 -- {{{ Key bindings
171 -- Bind keyboard digits
172 -- Compute the maximum number of digit we need, limited to 9
173 keynumber = 0
174 for s = 1, screen.count() do
175 keynumber = math.min(9, math.max(#tags[s], keynumber));
178 for i = 1, keynumber do
179 keybinding({ modkey }, i,
180 function ()
181 local screen = mouse.screen
182 if tags[screen][i] then
183 awful.tag.viewonly(tags[screen][i])
185 end):add()
186 keybinding({ modkey, "Control" }, i,
187 function ()
188 local screen = mouse.screen
189 if tags[screen][i] then
190 tags[screen][i].selected = not tags[screen][i].selected
192 end):add()
193 keybinding({ modkey, "Shift" }, i,
194 function ()
195 if client.focus then
196 if tags[client.focus.screen][i] then
197 awful.client.movetotag(tags[client.focus.screen][i])
200 end):add()
201 keybinding({ modkey, "Control", "Shift" }, i,
202 function ()
203 if client.focus then
204 if tags[client.focus.screen][i] then
205 awful.client.toggletag(tags[client.focus.screen][i])
208 end):add()
211 keybinding({ modkey }, "Left", awful.tag.viewprev):add()
212 keybinding({ modkey }, "Right", awful.tag.viewnext):add()
213 keybinding({ modkey }, "Escape", awful.tag.history.restore):add()
215 -- Standard program
216 keybinding({ modkey }, "Return", function () awful.util.spawn(terminal) end):add()
218 keybinding({ modkey, "Control" }, "r", function ()
219 mypromptbox[mouse.screen].text =
220 awful.util.escape(awful.util.restart())
221 end):add()
222 keybinding({ modkey, "Shift" }, "q", awesome.quit):add()
224 -- Client manipulation
225 keybinding({ modkey }, "m", awful.client.maximize):add()
226 keybinding({ modkey }, "f", function () client.focus.fullscreen = not client.focus.fullscreen end):add()
227 keybinding({ modkey, "Shift" }, "c", function () client.focus:kill() end):add()
228 keybinding({ modkey }, "j", function () awful.client.focus.byidx(1); client.focus:raise() end):add()
229 keybinding({ modkey }, "k", function () awful.client.focus.byidx(-1); client.focus:raise() end):add()
230 keybinding({ modkey, "Shift" }, "j", function () awful.client.swap.byidx(1) end):add()
231 keybinding({ modkey, "Shift" }, "k", function () awful.client.swap(-1) end):add()
232 keybinding({ modkey, "Control" }, "j", function () awful.screen.focus(1) end):add()
233 keybinding({ modkey, "Control" }, "k", function () awful.screen.focus(-1) end):add()
234 keybinding({ modkey, "Control" }, "space", awful.client.togglefloating):add()
235 keybinding({ modkey, "Control" }, "Return", function () client.focus:swap(awful.client.getmaster()) end):add()
236 keybinding({ modkey }, "o", awful.client.movetoscreen):add()
237 keybinding({ modkey }, "Tab", awful.client.focus.history.previous):add()
238 keybinding({ modkey }, "u", awful.client.urgent.jumpto):add()
239 keybinding({ modkey, "Shift" }, "r", function () client.focus:redraw() end):add()
241 -- Layout manipulation
242 keybinding({ modkey }, "l", function () awful.tag.incmwfact(0.05) end):add()
243 keybinding({ modkey }, "h", function () awful.tag.incmwfact(-0.05) end):add()
244 keybinding({ modkey, "Shift" }, "h", function () awful.tag.incnmaster(1) end):add()
245 keybinding({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end):add()
246 keybinding({ modkey, "Control" }, "h", function () awful.tag.incncol(1) end):add()
247 keybinding({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end):add()
248 keybinding({ modkey }, "space", function () awful.layout.inc(layouts, 1) end):add()
249 keybinding({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end):add()
251 -- Prompt
252 keybinding({ modkey }, "F1", function ()
253 awful.prompt.run({ prompt = "Run: " }, mypromptbox[mouse.screen], awful.util.spawn, awful.completion.bash,
254 awful.util.getdir("cache") .. "/history")
255 end):add()
256 keybinding({ modkey }, "F4", function ()
257 awful.prompt.run({ prompt = "Run Lua code: " }, mypromptbox[mouse.screen], awful.util.eval, awful.prompt.bash,
258 awful.util.getdir("cache") .. "/history_eval")
259 end):add()
261 keybinding({ modkey, "Ctrl" }, "i", function ()
262 local s = mouse.screen
263 if mypromptbox[s].text then
264 mypromptbox[s].text = nil
265 else
266 mypromptbox[s].text = nil
267 if client.focus.class then
268 mypromptbox[s].text = "Class: " .. client.focus.class .. " "
270 if client.focus.instance then
271 mypromptbox[s].text = mypromptbox[s].text .. "Instance: ".. client.focus.instance .. " "
273 if client.focus.role then
274 mypromptbox[s].text = mypromptbox[s].text .. "Role: ".. client.focus.role
277 end):add()
279 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
280 keybinding({ modkey }, "t", awful.client.togglemarked):add()
282 for i = 1, keynumber do
283 keybinding({ modkey, "Shift" }, "F" .. i,
284 function ()
285 local screen = mouse.screen
286 if tags[screen][i] then
287 for k, c in pairs(awful.client.getmarked()) do
288 awful.client.movetotag(tags[screen][i], c)
291 end):add()
293 -- }}}
295 -- {{{ Hooks
296 -- Hook function to execute when focusing a client.
297 awful.hooks.focus.register(function (c)
298 if not awful.client.ismarked(c) then
299 c.border_color = beautiful.border_focus
301 end)
303 -- Hook function to execute when unfocusing a client.
304 awful.hooks.unfocus.register(function (c)
305 if not awful.client.ismarked(c) then
306 c.border_color = beautiful.border_normal
308 end)
310 -- Hook function to execute when marking a client
311 awful.hooks.marked.register(function (c)
312 c.border_color = beautiful.border_marked
313 end)
315 -- Hook function to execute when unmarking a client.
316 awful.hooks.unmarked.register(function (c)
317 c.border_color = beautiful.border_focus
318 end)
320 -- Hook function to execute when the mouse enters a client.
321 awful.hooks.mouse_enter.register(function (c)
322 -- Sloppy focus, but disabled for magnifier layout
323 if awful.layout.get(c.screen) ~= "magnifier"
324 and awful.client.focus.filter(c) then
325 client.focus = c
327 end)
329 -- Hook function to execute when a new client appears.
330 awful.hooks.manage.register(function (c)
331 if use_titlebar then
332 -- Add a titlebar
333 awful.titlebar.add(c, { modkey = modkey })
335 -- Add mouse bindings
336 c:buttons({
337 button({ }, 1, function (c) client.focus = c; c:raise() end),
338 button({ modkey }, 1, function (c) c:mouse_move() end),
339 button({ modkey }, 3, function (c) c:mouse_resize() end)
341 -- New client may not receive focus
342 -- if they're not focusable, so set border anyway.
343 c.border_width = beautiful.border_width
344 c.border_color = beautiful.border_normal
345 client.focus = c
347 -- Check if the application should be floating.
348 local cls = c.class
349 local inst = c.instance
350 if floatapps[cls] then
351 c.floating = floatapps[cls]
352 elseif floatapps[inst] then
353 c.floating = floatapps[inst]
356 -- Check application->screen/tag mappings.
357 local target
358 if apptags[cls] then
359 target = apptags[cls]
360 elseif apptags[inst] then
361 target = apptags[inst]
363 if target then
364 c.screen = target.screen
365 awful.client.movetotag(tags[target.screen][target.tag], c)
368 -- Set the windows at the slave,
369 -- i.e. put it at the end of others instead of setting it master.
370 -- awful.client.setslave(c)
372 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
373 -- c.honorsizehints = false
374 end)
376 -- Hook function to execute when arranging the screen.
377 -- (tag switch, new client, etc)
378 awful.hooks.arrange.register(function (screen)
379 local layout = awful.layout.get(screen)
380 if layout then
381 mylayoutbox[screen].image = image(beautiful["layout_" .. layout])
382 else
383 mylayoutbox[screen].image = nil
386 -- Give focus to the latest client in history if no window has focus
387 -- or if the current window is a desktop or a dock one.
388 if not client.focus then
389 local c = awful.client.focus.history.get(screen, 0)
390 if c then client.focus = c end
393 -- Uncomment if you want mouse warping
394 --[[
395 if client.focus then
396 local c_c = client.focus:fullgeometry()
397 local m_c = mouse.coords()
399 if m_c.x < c_c.x or m_c.x >= c_c.x + c_c.width or
400 m_c.y < c_c.y or m_c.y >= c_c.y + c_c.height then
401 if table.maxn(m_c.buttons) == 0 then
402 mouse.coords({ x = c_c.x + 5, y = c_c.y + 5})
407 end)
409 -- Hook called every second
410 awful.hooks.timer.register(1, function ()
411 -- For unix time_t lovers
412 mytextbox.text = " " .. os.time() .. " time_t "
413 -- Otherwise use:
414 -- mytextbox.text = " " .. os.date() .. " "
415 end)
416 -- }}}