Correctly read a textbox' ellipsize and wrap properties
[awesome.git] / awesomerc.lua.in
blobaaf40a2ace86af15c37fd3d13da0c9051e4bc2e4
1 -- Standard awesome library
2 require("awful")
3 require("awful.autofocus")
4 require("awful.rules")
5 -- Theme handling library
6 require("beautiful")
7 -- Notification library
8 require("naughty")
10 -- {{{ Variable definitions
11 -- Themes define colours, icons, and wallpapers
12 beautiful.init("@AWESOME_THEMES_PATH@/default/theme.lua")
14 -- This is used later as the default terminal and editor to run.
15 terminal = "xterm"
16 editor = os.getenv("EDITOR") or "nano"
17 editor_cmd = terminal .. " -e " .. editor
19 -- Default modkey.
20 -- Usually, Mod4 is the key with a logo between Control and Alt.
21 -- If you do not like this or do not have such a key,
22 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
23 -- However, you can use another modifier like Mod1, but it may interact with others.
24 modkey = "Mod4"
26 -- Table of layouts to cover with awful.layout.inc, order matters.
27 layouts =
29 awful.layout.suit.floating,
30 awful.layout.suit.tile,
31 awful.layout.suit.tile.left,
32 awful.layout.suit.tile.bottom,
33 awful.layout.suit.tile.top,
34 awful.layout.suit.fair,
35 awful.layout.suit.fair.horizontal,
36 awful.layout.suit.spiral,
37 awful.layout.suit.spiral.dwindle,
38 awful.layout.suit.max,
39 awful.layout.suit.max.fullscreen,
40 awful.layout.suit.magnifier
42 -- }}}
44 -- {{{ Tags
45 -- Define a tag table which hold all screen tags.
46 tags = {}
47 for s = 1, screen.count() do
48 -- Each screen has its own tag table.
49 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
50 end
51 -- }}}
53 -- {{{ Menu
54 -- Create a laucher widget and a main menu
55 myawesomemenu = {
56 { "manual", terminal .. " -e man awesome" },
57 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
58 { "restart", awesome.restart },
59 { "quit", awesome.quit }
62 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
63 { "open terminal", terminal }
67 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
68 menu = mymainmenu })
69 -- }}}
71 -- {{{ Wibox
72 -- Create a textclock widget
73 mytextclock = awful.widget.textclock({ align = "right" })
75 -- Create a systray
76 mysystray = widget({ type = "systray" })
78 -- Create a wibox for each screen and add it
79 mywibox = {}
80 mypromptbox = {}
81 mylayoutbox = {}
82 mytaglist = {}
83 mytaglist.buttons = awful.util.table.join(
84 awful.button({ }, 1, awful.tag.viewonly),
85 awful.button({ modkey }, 1, awful.client.movetotag),
86 awful.button({ }, 3, awful.tag.viewtoggle),
87 awful.button({ modkey }, 3, awful.client.toggletag),
88 awful.button({ }, 4, awful.tag.viewnext),
89 awful.button({ }, 5, awful.tag.viewprev)
91 mytasklist = {}
92 mytasklist.buttons = awful.util.table.join(
93 awful.button({ }, 1, function (c)
94 if not c:isvisible() then
95 awful.tag.viewonly(c:tags()[1])
96 end
97 client.focus = c
98 c:raise()
99 end),
100 awful.button({ }, 3, function ()
101 if instance then
102 instance:hide()
103 instance = nil
104 else
105 instance = awful.menu.clients({ width=250 })
107 end),
108 awful.button({ }, 4, function ()
109 awful.client.focus.byidx(1)
110 if client.focus then client.focus:raise() end
111 end),
112 awful.button({ }, 5, function ()
113 awful.client.focus.byidx(-1)
114 if client.focus then client.focus:raise() end
115 end))
117 for s = 1, screen.count() do
118 -- Create a promptbox for each screen
119 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
120 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
121 -- We need one layoutbox per screen.
122 mylayoutbox[s] = awful.widget.layoutbox(s)
123 mylayoutbox[s]:buttons(awful.util.table.join(
124 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
125 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
126 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
127 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
128 -- Create a taglist widget
129 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
131 -- Create a tasklist widget
132 mytasklist[s] = awful.widget.tasklist(function(c)
133 return awful.widget.tasklist.label.currenttags(c, s)
134 end, mytasklist.buttons)
136 -- Create the wibox
137 mywibox[s] = awful.wibox({ position = "top", screen = s })
138 -- Add widgets to the wibox - order matters
139 mywibox[s].widgets = {
141 mylauncher,
142 mytaglist[s],
143 mypromptbox[s],
144 layout = awful.widget.layout.horizontal.leftright
146 mylayoutbox[s],
147 mytextclock,
148 s == 1 and mysystray or nil,
149 mytasklist[s],
150 layout = awful.widget.layout.horizontal.rightleft
153 -- }}}
155 -- {{{ Mouse bindings
156 root.buttons(awful.util.table.join(
157 awful.button({ }, 3, function () mymainmenu:toggle() end),
158 awful.button({ }, 4, awful.tag.viewnext),
159 awful.button({ }, 5, awful.tag.viewprev)
161 -- }}}
163 -- {{{ Key bindings
164 globalkeys = awful.util.table.join(
165 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
166 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
167 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
169 awful.key({ modkey, }, "j",
170 function ()
171 awful.client.focus.byidx( 1)
172 if client.focus then client.focus:raise() end
173 end),
174 awful.key({ modkey, }, "k",
175 function ()
176 awful.client.focus.byidx(-1)
177 if client.focus then client.focus:raise() end
178 end),
179 awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
181 -- Layout manipulation
182 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
183 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
184 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
185 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
186 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
187 awful.key({ modkey, }, "Tab",
188 function ()
189 awful.client.focus.history.previous()
190 if client.focus then
191 client.focus:raise()
193 end),
195 -- Standard program
196 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
197 awful.key({ modkey, "Control" }, "r", awesome.restart),
198 awful.key({ modkey, "Shift" }, "q", awesome.quit),
200 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
201 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
202 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
203 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
204 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
205 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
206 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
207 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
209 -- Prompt
210 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
212 awful.key({ modkey }, "x",
213 function ()
214 awful.prompt.run({ prompt = "Run Lua code: " },
215 mypromptbox[mouse.screen].widget,
216 awful.util.eval, nil,
217 awful.util.getdir("cache") .. "/history_eval")
218 end)
221 clientkeys = awful.util.table.join(
222 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
223 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
224 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
225 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
226 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
227 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
228 awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
229 awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
230 awful.key({ modkey, }, "m",
231 function (c)
232 c.maximized_horizontal = not c.maximized_horizontal
233 c.maximized_vertical = not c.maximized_vertical
234 end)
237 -- Compute the maximum number of digit we need, limited to 9
238 keynumber = 0
239 for s = 1, screen.count() do
240 keynumber = math.min(9, math.max(#tags[s], keynumber));
243 -- Bind all key numbers to tags.
244 -- Be careful: we use keycodes to make it works on any keyboard layout.
245 -- This should map on the top row of your keyboard, usually 1 to 9.
246 for i = 1, keynumber do
247 globalkeys = awful.util.table.join(globalkeys,
248 awful.key({ modkey }, "#" .. i + 9,
249 function ()
250 local screen = mouse.screen
251 if tags[screen][i] then
252 awful.tag.viewonly(tags[screen][i])
254 end),
255 awful.key({ modkey, "Control" }, "#" .. i + 9,
256 function ()
257 local screen = mouse.screen
258 if tags[screen][i] then
259 awful.tag.viewtoggle(tags[screen][i])
261 end),
262 awful.key({ modkey, "Shift" }, "#" .. i + 9,
263 function ()
264 if client.focus and tags[client.focus.screen][i] then
265 awful.client.movetotag(tags[client.focus.screen][i])
267 end),
268 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
269 function ()
270 if client.focus and tags[client.focus.screen][i] then
271 awful.client.toggletag(tags[client.focus.screen][i])
273 end))
276 clientbuttons = awful.util.table.join(
277 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
278 awful.button({ modkey }, 1, awful.mouse.client.move),
279 awful.button({ modkey }, 3, awful.mouse.client.resize))
281 -- Set keys
282 root.keys(globalkeys)
283 -- }}}
285 -- {{{ Rules
286 awful.rules.rules = {
287 -- All clients will match this rule.
288 { rule = { },
289 properties = { border_width = beautiful.border_width,
290 border_color = beautiful.border_normal,
291 focus = true,
292 keys = clientkeys,
293 buttons = clientbuttons } },
294 { rule = { class = "MPlayer" },
295 properties = { floating = true } },
296 { rule = { class = "pinentry" },
297 properties = { floating = true } },
298 { rule = { class = "gimp" },
299 properties = { floating = true } },
300 -- Set Firefox to always map on tags number 2 of screen 1.
301 -- { rule = { class = "Firefox" },
302 -- properties = { tag = tags[1][2] } },
304 -- }}}
306 -- {{{ Signals
307 -- Signal function to execute when a new client appears.
308 client.add_signal("manage", function (c, startup)
309 -- Add a titlebar
310 -- awful.titlebar.add(c, { modkey = modkey })
312 -- Enable sloppy focus
313 c:add_signal("mouse::enter", function(c)
314 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
315 and awful.client.focus.filter(c) then
316 client.focus = c
318 end)
320 if not startup then
321 -- Set the windows at the slave,
322 -- i.e. put it at the end of others instead of setting it master.
323 -- awful.client.setslave(c)
325 -- Put windows in a smart way, only if they does not set an initial position.
326 if not c.size_hints.user_position and not c.size_hints.program_position then
327 awful.placement.no_overlap(c)
328 awful.placement.no_offscreen(c)
331 end)
333 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
334 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
335 -- }}}