textbox: Actually tell pango which space we have (FS#933)
[awesome.git] / awesomerc.lua.in
blobfcfb333f89937201af26ca479c9b560a96dcb1f8
1 -- Standard awesome library
2 require("awful")
3 require("awful.autofocus")
4 require("awful.rules")
5 -- Widget and layout library
6 require("wibox")
7 -- Theme handling library
8 require("beautiful")
9 -- Notification library
10 require("naughty")
12 -- {{{ Variable definitions
13 -- Themes define colours, icons, and wallpapers
14 beautiful.init("@AWESOME_THEMES_PATH@/default/theme.lua")
16 -- This is used later as the default terminal and editor to run.
17 terminal = "xterm"
18 editor = os.getenv("EDITOR") or "nano"
19 editor_cmd = terminal .. " -e " .. editor
21 -- Default modkey.
22 -- Usually, Mod4 is the key with a logo between Control and Alt.
23 -- If you do not like this or do not have such a key,
24 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
25 -- However, you can use another modifier like Mod1, but it may interact with others.
26 modkey = "Mod4"
28 -- Table of layouts to cover with awful.layout.inc, order matters.
29 layouts =
31 awful.layout.suit.floating,
32 awful.layout.suit.tile,
33 awful.layout.suit.tile.left,
34 awful.layout.suit.tile.bottom,
35 awful.layout.suit.tile.top,
36 awful.layout.suit.fair,
37 awful.layout.suit.fair.horizontal,
38 awful.layout.suit.spiral,
39 awful.layout.suit.spiral.dwindle,
40 awful.layout.suit.max,
41 awful.layout.suit.max.fullscreen,
42 awful.layout.suit.magnifier
44 -- }}}
46 -- {{{ Tags
47 -- Define a tag table which hold all screen tags.
48 tags = {}
49 for s = 1, screen.count() do
50 -- Each screen has its own tag table.
51 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
52 end
53 -- }}}
55 -- {{{ Menu
56 -- Create a laucher widget and a main menu
57 myawesomemenu = {
58 { "manual", terminal .. " -e man awesome" },
59 { "edit config", editor_cmd .. " " .. awesome.conffile },
60 { "restart", awesome.restart },
61 { "quit", awesome.quit }
64 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
65 { "open terminal", terminal }
69 mylauncher = awful.widget.launcher({ image = beautiful.awesome_icon,
70 menu = mymainmenu })
71 -- }}}
73 -- {{{ Wibox
74 -- Create a textclock widget
75 mytextclock = awful.widget.textclock()
77 -- Create a wibox for each screen and add it
78 mywibox = {}
79 mypromptbox = {}
80 mylayoutbox = {}
81 mytaglist = {}
82 mytaglist.buttons = awful.util.table.join(
83 awful.button({ }, 1, awful.tag.viewonly),
84 awful.button({ modkey }, 1, awful.client.movetotag),
85 awful.button({ }, 3, awful.tag.viewtoggle),
86 awful.button({ modkey }, 3, awful.client.toggletag),
87 awful.button({ }, 4, awful.tag.viewnext),
88 awful.button({ }, 5, awful.tag.viewprev)
90 mytasklist = {}
91 mytasklist.buttons = awful.util.table.join(
92 awful.button({ }, 1, function (c)
93 if c == client.focus then
94 c.minimized = true
95 else
96 if not c:isvisible() then
97 awful.tag.viewonly(c:tags()[1])
98 end
99 -- This will also un-minimize
100 -- the client, if needed
101 client.focus = c
102 c:raise()
104 end),
105 awful.button({ }, 3, function ()
106 if instance then
107 instance:hide()
108 instance = nil
109 else
110 instance = awful.menu.clients({ width=250 })
112 end),
113 awful.button({ }, 4, function ()
114 awful.client.focus.byidx(1)
115 if client.focus then client.focus:raise() end
116 end),
117 awful.button({ }, 5, function ()
118 awful.client.focus.byidx(-1)
119 if client.focus then client.focus:raise() end
120 end))
122 for s = 1, screen.count() do
123 -- Create a promptbox for each screen
124 mypromptbox[s] = awful.widget.prompt()
125 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
126 -- We need one layoutbox per screen.
127 mylayoutbox[s] = awful.widget.layoutbox(s)
128 mylayoutbox[s]:buttons(awful.util.table.join(
129 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
130 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
131 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
132 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
133 -- Create a taglist widget
134 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.filter.all, mytaglist.buttons)
136 -- Create a tasklist widget
137 mytasklist[s] = awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, mytasklist.buttons)
139 -- Create the wibox
140 mywibox[s] = awful.wibox({ position = "top", screen = s })
142 -- Widgets that are aligned to the left
143 local left_layout = wibox.layout.fixed.horizontal()
144 left_layout:add(mylauncher)
145 left_layout:add(mytaglist[s])
146 left_layout:add(mypromptbox[s])
148 -- Widgets that are aligned to the right
149 local right_layout = wibox.layout.fixed.horizontal()
150 if s == 1 then right_layout:add(wibox.widget.systray()) end
151 right_layout:add(mytextclock)
152 right_layout:add(mylayoutbox[s])
154 -- Now bring it all together (with the tasklist in the middle)
155 local layout = wibox.layout.align.horizontal()
156 layout:set_left(left_layout)
157 layout:set_middle(mytasklist[s])
158 layout:set_right(right_layout)
160 mywibox[s]:set_widget(layout)
162 -- }}}
164 -- {{{ Mouse bindings
165 root.buttons(awful.util.table.join(
166 awful.button({ }, 3, function () mymainmenu:toggle() end),
167 awful.button({ }, 4, awful.tag.viewnext),
168 awful.button({ }, 5, awful.tag.viewprev)
170 -- }}}
172 -- {{{ Key bindings
173 globalkeys = awful.util.table.join(
174 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
175 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
176 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
178 awful.key({ modkey, }, "j",
179 function ()
180 awful.client.focus.byidx( 1)
181 if client.focus then client.focus:raise() end
182 end),
183 awful.key({ modkey, }, "k",
184 function ()
185 awful.client.focus.byidx(-1)
186 if client.focus then client.focus:raise() end
187 end),
188 awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
190 -- Layout manipulation
191 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
192 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
193 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
194 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
195 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
196 awful.key({ modkey, }, "Tab",
197 function ()
198 awful.client.focus.history.previous()
199 if client.focus then
200 client.focus:raise()
202 end),
204 -- Standard program
205 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
206 awful.key({ modkey, "Control" }, "r", awesome.restart),
207 awful.key({ modkey, "Shift" }, "q", awesome.quit),
209 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
210 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
211 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
212 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
213 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
214 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
215 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
216 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
218 awful.key({ modkey, "Control" }, "n", awful.client.restore),
220 -- Prompt
221 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
223 awful.key({ modkey }, "x",
224 function ()
225 awful.prompt.run({ prompt = "Run Lua code: " },
226 mypromptbox[mouse.screen].widget,
227 awful.util.eval, nil,
228 awful.util.getdir("cache") .. "/history_eval")
229 end)
232 clientkeys = awful.util.table.join(
233 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
234 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
235 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
236 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
237 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
238 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
239 awful.key({ modkey, }, "n",
240 function (c)
241 -- The client currently has the input focus, so it cannot be
242 -- minimized, since minimized clients can't have the focus.
243 c.minimized = true
244 end),
245 awful.key({ modkey, }, "m",
246 function (c)
247 c.maximized_horizontal = not c.maximized_horizontal
248 c.maximized_vertical = not c.maximized_vertical
249 end)
252 -- Compute the maximum number of digit we need, limited to 9
253 keynumber = 0
254 for s = 1, screen.count() do
255 keynumber = math.min(9, math.max(#tags[s], keynumber));
258 -- Bind all key numbers to tags.
259 -- Be careful: we use keycodes to make it works on any keyboard layout.
260 -- This should map on the top row of your keyboard, usually 1 to 9.
261 for i = 1, keynumber do
262 globalkeys = awful.util.table.join(globalkeys,
263 awful.key({ modkey }, "#" .. i + 9,
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 + 9,
271 function ()
272 local screen = mouse.screen
273 if tags[screen][i] then
274 awful.tag.viewtoggle(tags[screen][i])
276 end),
277 awful.key({ modkey, "Shift" }, "#" .. i + 9,
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 + 9,
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 clientbuttons = awful.util.table.join(
292 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
293 awful.button({ modkey }, 1, awful.mouse.client.move),
294 awful.button({ modkey }, 3, awful.mouse.client.resize))
296 -- Set keys
297 root.keys(globalkeys)
298 -- }}}
300 -- {{{ Rules
301 awful.rules.rules = {
302 -- All clients will match this rule.
303 { rule = { },
304 properties = { border_width = beautiful.border_width,
305 border_color = beautiful.border_normal,
306 focus = true,
307 keys = clientkeys,
308 buttons = clientbuttons } },
309 { rule = { class = "MPlayer" },
310 properties = { floating = true } },
311 { rule = { class = "pinentry" },
312 properties = { floating = true } },
313 { rule = { class = "gimp" },
314 properties = { floating = true } },
315 -- Set Firefox to always map on tags number 2 of screen 1.
316 -- { rule = { class = "Firefox" },
317 -- properties = { tag = tags[1][2] } },
319 -- }}}
321 -- {{{ Signals
322 -- Signal function to execute when a new client appears.
323 client.connect_signal("manage", function (c, startup)
324 -- Enable sloppy focus
325 c:connect_signal("mouse::enter", function(c)
326 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
327 and awful.client.focus.filter(c) then
328 client.focus = c
330 end)
332 if not startup then
333 -- Set the windows at the slave,
334 -- i.e. put it at the end of others instead of setting it master.
335 -- awful.client.setslave(c)
337 -- Put windows in a smart way, only if they does not set an initial position.
338 if not c.size_hints.user_position and not c.size_hints.program_position then
339 awful.placement.no_overlap(c)
340 awful.placement.no_offscreen(c)
343 end)
345 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
346 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
347 -- }}}