awful.tag: filter out window before switching screens (FS#633)
[awesome.git] / awesomerc.lua.in
bloba889037edc1f91004e1a205ec40fad4feaab2507
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 -- This is used later as the default terminal and editor to run.
12 terminal = "xterm"
13 editor = os.getenv("EDITOR") or "nano"
14 editor_cmd = terminal .. " -e " .. editor
16 -- Default modkey.
17 -- Usually, Mod4 is the key with a logo between Control and Alt.
18 -- If you do not like this or do not have such a key,
19 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
20 -- However, you can use another modifier like Mod1, but it may interact with others.
21 modkey = "Mod4"
23 -- Table of layouts to cover with awful.layout.inc, order matters.
24 layouts =
26 awful.layout.suit.tile,
27 awful.layout.suit.tile.left,
28 awful.layout.suit.tile.bottom,
29 awful.layout.suit.tile.top,
30 awful.layout.suit.fair,
31 awful.layout.suit.fair.horizontal,
32 awful.layout.suit.spiral,
33 awful.layout.suit.spiral.dwindle,
34 awful.layout.suit.max,
35 awful.layout.suit.max.fullscreen,
36 awful.layout.suit.magnifier,
37 awful.layout.suit.floating
39 -- }}}
41 -- {{{ Tags
42 -- Define a tag table which hold all screen tags.
43 tags = {}
44 for s = 1, screen.count() do
45 -- Each screen has its own tag table.
46 tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s)
47 end
48 -- }}}
50 -- {{{ Menu
51 -- Create a laucher widget and a main menu
52 myawesomemenu = {
53 { "manual", terminal .. " -e man awesome" },
54 { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
55 { "restart", awesome.restart },
56 { "quit", awesome.quit }
59 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
60 { "open terminal", terminal }
64 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
65 menu = mymainmenu })
66 -- }}}
68 -- {{{ Wibox
69 -- Create a textclock widget
70 mytextclock = awful.widget.textclock({ align = "right" })
72 -- Create a systray
73 mysystray = widget({ type = "systray" })
75 -- Create a wibox for each screen and add it
76 mywibox = {}
77 mypromptbox = {}
78 mylayoutbox = {}
79 mytaglist = {}
80 mytaglist.buttons = awful.util.table.join(
81 awful.button({ }, 1, awful.tag.viewonly),
82 awful.button({ modkey }, 1, awful.client.movetotag),
83 awful.button({ }, 3, awful.tag.viewtoggle),
84 awful.button({ modkey }, 3, awful.client.toggletag),
85 awful.button({ }, 4, awful.tag.viewnext),
86 awful.button({ }, 5, awful.tag.viewprev)
88 mytasklist = {}
89 mytasklist.buttons = awful.util.table.join(
90 awful.button({ }, 1, function (c)
91 if not c:isvisible() then
92 awful.tag.viewonly(c:tags()[1])
93 end
94 client.focus = c
95 c:raise()
96 end),
97 awful.button({ }, 3, function ()
98 if instance then
99 instance:hide()
100 instance = nil
101 else
102 instance = awful.menu.clients({ width=250 })
104 end),
105 awful.button({ }, 4, function ()
106 awful.client.focus.byidx(1)
107 if client.focus then client.focus:raise() end
108 end),
109 awful.button({ }, 5, function ()
110 awful.client.focus.byidx(-1)
111 if client.focus then client.focus:raise() end
112 end))
114 for s = 1, screen.count() do
115 -- Create a promptbox for each screen
116 mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
117 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
118 -- We need one layoutbox per screen.
119 mylayoutbox[s] = awful.widget.layoutbox(s)
120 mylayoutbox[s]:buttons(awful.util.table.join(
121 awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
122 awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
123 awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
124 awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
125 -- Create a taglist widget
126 mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
128 -- Create a tasklist widget
129 mytasklist[s] = awful.widget.tasklist(function(c)
130 return awful.widget.tasklist.label.currenttags(c, s)
131 end, mytasklist.buttons)
133 -- Create the wibox
134 mywibox[s] = awful.wibox({ position = "top", screen = s })
135 -- Add widgets to the wibox - order matters
136 mywibox[s].widgets = {
138 mylauncher,
139 mytaglist[s],
140 mypromptbox[s],
141 layout = awful.widget.layout.horizontal.leftright
143 mylayoutbox[s],
144 mytextclock,
145 s == 1 and mysystray or nil,
146 mytasklist[s],
147 layout = awful.widget.layout.horizontal.rightleft
150 -- }}}
152 -- {{{ Mouse bindings
153 root.buttons(awful.util.table.join(
154 awful.button({ }, 3, function () mymainmenu:toggle() end),
155 awful.button({ }, 4, awful.tag.viewnext),
156 awful.button({ }, 5, awful.tag.viewprev)
158 -- }}}
160 -- {{{ Key bindings
161 globalkeys = awful.util.table.join(
162 awful.key({ modkey, }, "Left", awful.tag.viewprev ),
163 awful.key({ modkey, }, "Right", awful.tag.viewnext ),
164 awful.key({ modkey, }, "Escape", awful.tag.history.restore),
166 awful.key({ modkey, }, "j",
167 function ()
168 awful.client.focus.byidx( 1)
169 if client.focus then client.focus:raise() end
170 end),
171 awful.key({ modkey, }, "k",
172 function ()
173 awful.client.focus.byidx(-1)
174 if client.focus then client.focus:raise() end
175 end),
176 awful.key({ modkey, }, "w", function () mymainmenu:show(true) end),
178 -- Layout manipulation
179 awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
180 awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
181 awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
182 awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
183 awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
184 awful.key({ modkey, }, "Tab",
185 function ()
186 awful.client.focus.history.previous()
187 if client.focus then
188 client.focus:raise()
190 end),
192 -- Standard program
193 awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
194 awful.key({ modkey, "Control" }, "r", awesome.restart),
195 awful.key({ modkey, "Shift" }, "q", awesome.quit),
197 awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
198 awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
199 awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
200 awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
201 awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
202 awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
203 awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
204 awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
206 -- Prompt
207 awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
209 awful.key({ modkey }, "x",
210 function ()
211 awful.prompt.run({ prompt = "Run Lua code: " },
212 mypromptbox[mouse.screen].widget,
213 awful.util.eval, nil,
214 awful.util.getdir("cache") .. "/history_eval")
215 end)
218 clientkeys = awful.util.table.join(
219 awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
220 awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
221 awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
222 awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
223 awful.key({ modkey, }, "o", awful.client.movetoscreen ),
224 awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
225 awful.key({ modkey, }, "n", function (c) c.minimized = not c.minimized end),
226 awful.key({ modkey, }, "m",
227 function (c)
228 c.maximized_horizontal = not c.maximized_horizontal
229 c.maximized_vertical = not c.maximized_vertical
230 end)
233 -- Compute the maximum number of digit we need, limited to 9
234 keynumber = 0
235 for s = 1, screen.count() do
236 keynumber = math.min(9, math.max(#tags[s], keynumber));
239 -- Bind all key numbers to tags.
240 -- Be careful: we use keycodes to make it works on any keyboard layout.
241 -- This should map on the top row of your keyboard, usually 1 to 9.
242 for i = 1, keynumber do
243 globalkeys = awful.util.table.join(globalkeys,
244 awful.key({ modkey }, "#" .. i + 9,
245 function ()
246 local screen = mouse.screen
247 if tags[screen][i] then
248 awful.tag.viewonly(tags[screen][i])
250 end),
251 awful.key({ modkey, "Control" }, "#" .. i + 9,
252 function ()
253 local screen = mouse.screen
254 if tags[screen][i] then
255 awful.tag.viewtoggle(tags[screen][i])
257 end),
258 awful.key({ modkey, "Shift" }, "#" .. i + 9,
259 function ()
260 if client.focus and tags[client.focus.screen][i] then
261 awful.client.movetotag(tags[client.focus.screen][i])
263 end),
264 awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
265 function ()
266 if client.focus and tags[client.focus.screen][i] then
267 awful.client.toggletag(tags[client.focus.screen][i])
269 end))
272 clientbuttons = awful.util.table.join(
273 awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
274 awful.button({ modkey }, 1, awful.mouse.client.move),
275 awful.button({ modkey }, 3, awful.mouse.client.resize))
277 -- Set keys
278 root.keys(globalkeys)
279 -- }}}
281 -- {{{ Rules
282 awful.rules.rules = {
283 -- All clients will match this rule.
284 { rule = { },
285 properties = { border_width = beautiful.border_width,
286 border_color = beautiful.border_normal,
287 focus = true,
288 keys = clientkeys,
289 buttons = clientbuttons } },
290 { rule = { class = "MPlayer" },
291 properties = { floating = true } },
292 { rule = { class = "pinentry" },
293 properties = { floating = true } },
294 { rule = { class = "gimp" },
295 properties = { floating = true } },
296 -- Set Firefox to always map on tags number 2 of screen 1.
297 -- { rule = { class = "Firefox" },
298 -- properties = { tag = tags[1][2] } },
300 -- }}}
302 -- {{{ Signals
303 -- Signal function to execute when a new client appears.
304 client.add_signal("manage", function (c, startup)
305 -- Add a titlebar
306 -- awful.titlebar.add(c, { modkey = modkey })
308 -- Enable sloppy focus
309 c:add_signal("mouse::enter", function(c)
310 if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
311 and awful.client.focus.filter(c) then
312 client.focus = c
314 end)
316 if not startup then
317 -- Set the windows at the slave,
318 -- i.e. put it at the end of others instead of setting it master.
319 -- awful.client.setslave(c)
321 -- Put windows in a smart way.
322 awful.placement.no_overlap(c)
323 awful.placement.no_offscreen(c)
325 end)
327 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
328 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
329 -- }}}