1 -- Standard awesome library
3 require("awful.autofocus")
4 -- Theme handling library
6 -- Notification library
9 -- {{{ Variable definitions
10 -- This is used later as the default terminal and editor to run.
12 editor
= os
.getenv("EDITOR") or "nano"
13 editor_cmd
= terminal
.. " -e " .. editor
16 -- Usually, Mod4 is the key with a logo between Control and Alt.
17 -- If you do not like this or do not have such a key,
18 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
19 -- However, you can use another modifier like Mod1, but it may interact with others.
22 -- Table of layouts to cover with awful.layout.inc, order matters.
25 awful
.layout
.suit
.tile
,
26 awful
.layout
.suit
.tile
.left
,
27 awful
.layout
.suit
.tile
.bottom
,
28 awful
.layout
.suit
.tile
.top
,
29 awful
.layout
.suit
.fair
,
30 awful
.layout
.suit
.fair
.horizontal
,
31 awful
.layout
.suit
.spiral
,
32 awful
.layout
.suit
.spiral
.dwindle
,
33 awful
.layout
.suit
.max,
34 awful
.layout
.suit
.max.fullscreen
,
35 awful
.layout
.suit
.magnifier
,
36 awful
.layout
.suit
.floating
39 -- Table of clients that should be set floating. The index may be either
40 -- the application class or instance. The instance is useful when running
41 -- a console app in a terminal like (Music on Console)
42 -- xterm -name mocp -e mocp
53 -- Applications to be moved to a pre-defined tag by class or instance.
54 -- Use the screen and tags indices.
57 -- ["Firefox"] = { screen = 1, tag = 2 },
58 -- ["mocp"] = { screen = 2, tag = 4 },
61 -- Define if we want to use titlebar on all applications.
66 -- Define a tag table which hold all screen tags.
68 for s
= 1, screen
.count() do
69 -- Each screen has its own tag table.
70 tags
[s
] = awful
.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s
)
75 -- Create a textclock widget
76 mytextclock
= awful
.widget
.textclock({ align
= "right" })
78 -- Create a laucher widget and a main menu
80 { "manual", terminal
.. " -e man awesome" },
81 { "edit config", editor_cmd
.. " " .. awful
.util
.getdir("config") .. "/rc.lua" },
82 { "restart", awesome
.restart
},
83 { "quit", awesome
.quit
}
86 mymainmenu
= awful
.menu({ items
= { { "awesome", myawesomemenu
, beautiful
.awesome_icon
},
87 { "open terminal", terminal
}
91 mylauncher
= awful
.widget
.launcher({ image
= image(beautiful
.awesome_icon
),
95 mysystray
= widget({ type = "systray" })
97 -- Create a wibox for each screen and add it
102 mytaglist
.buttons
= awful
.util
.table.join(
103 awful
.button({ }, 1, awful
.tag.viewonly
),
104 awful
.button({ modkey
}, 1, awful
.client
.movetotag
),
105 awful
.button({ }, 3, function (tag) tag.selected
= not tag.selected
end),
106 awful
.button({ modkey
}, 3, awful
.client
.toggletag
),
107 awful
.button({ }, 4, awful
.tag.viewnext
),
108 awful
.button({ }, 5, awful
.tag.viewprev
)
111 mytasklist
.buttons
= awful
.util
.table.join(
112 awful
.button({ }, 1, function (c
)
113 if not c
:isvisible() then
114 awful
.tag.viewonly(c
:tags()[1])
119 awful
.button({ }, 3, function ()
124 instance
= awful
.menu
.clients({ width
=250 })
127 awful
.button({ }, 4, function ()
128 awful
.client
.focus
.byidx(1)
129 if client
.focus
then client
.focus
:raise() end
131 awful
.button({ }, 5, function ()
132 awful
.client
.focus
.byidx(-1)
133 if client
.focus
then client
.focus
:raise() end
136 for s
= 1, screen
.count() do
137 -- Create a promptbox for each screen
138 mypromptbox
[s
] = awful
.widget
.prompt({ layout
= awful
.widget
.layout
.leftright
})
139 -- Create an imagebox widget which will contains an icon indicating which layout we're using.
140 -- We need one layoutbox per screen.
141 mylayoutbox
[s
] = awful
.widget
.layoutbox(s
)
142 mylayoutbox
[s
]:buttons(awful
.util
.table.join(
143 awful
.button({ }, 1, function () awful
.layout
.inc(layouts
, 1) end),
144 awful
.button({ }, 3, function () awful
.layout
.inc(layouts
, -1) end),
145 awful
.button({ }, 4, function () awful
.layout
.inc(layouts
, 1) end),
146 awful
.button({ }, 5, function () awful
.layout
.inc(layouts
, -1) end)))
147 -- Create a taglist widget
148 mytaglist
[s
] = awful
.widget
.taglist(s
, awful
.widget
.taglist
.label
.all
, mytaglist
.buttons
)
150 -- Create a tasklist widget
151 mytasklist
[s
] = awful
.widget
.tasklist(function(c
)
152 return awful
.widget
.tasklist
.label
.currenttags(c
, s
)
153 end, mytasklist
.buttons
)
156 mywibox
[s
] = awful
.wibox({ position
= "top", screen
= s
})
157 -- Add widgets to the wibox - order matters
158 mywibox
[s
].widgets
= {
163 layout
= awful
.widget
.layout
.horizontal
.leftright
167 s
== 1 and mysystray
or nil,
169 layout
= awful
.widget
.layout
.horizontal
.rightleft
174 -- {{{ Mouse bindings
175 root
.buttons(awful
.util
.table.join(
176 awful
.button({ }, 3, function () mymainmenu
:toggle() end),
177 awful
.button({ }, 4, awful
.tag.viewnext
),
178 awful
.button({ }, 5, awful
.tag.viewprev
)
183 globalkeys
= awful
.util
.table.join(
184 awful
.key({ modkey
, }, "Left", awful
.tag.viewprev
),
185 awful
.key({ modkey
, }, "Right", awful
.tag.viewnext
),
186 awful
.key({ modkey
, }, "Escape", awful
.tag.history
.restore
),
188 awful
.key({ modkey
, }, "j",
190 awful
.client
.focus
.byidx( 1)
191 if client
.focus
then client
.focus
:raise() end
193 awful
.key({ modkey
, }, "k",
195 awful
.client
.focus
.byidx(-1)
196 if client
.focus
then client
.focus
:raise() end
198 awful
.key({ modkey
, }, "w", function () mymainmenu
:show(true) end),
200 -- Layout manipulation
201 awful
.key({ modkey
, "Shift" }, "j", function () awful
.client
.swap
.byidx( 1) end),
202 awful
.key({ modkey
, "Shift" }, "k", function () awful
.client
.swap
.byidx( -1) end),
203 awful
.key({ modkey
, "Control" }, "j", function () awful
.screen
.focus_relative( 1) end),
204 awful
.key({ modkey
, "Control" }, "k", function () awful
.screen
.focus_relative(-1) end),
205 awful
.key({ modkey
, }, "u", awful
.client
.urgent
.jumpto
),
206 awful
.key({ modkey
, }, "Tab",
208 awful
.client
.focus
.history
.previous()
215 awful
.key({ modkey
, }, "Return", function () awful
.util
.spawn(terminal
) end),
216 awful
.key({ modkey
, "Control" }, "r", awesome
.restart
),
217 awful
.key({ modkey
, "Shift" }, "q", awesome
.quit
),
219 awful
.key({ modkey
, }, "l", function () awful
.tag.incmwfact( 0.05) end),
220 awful
.key({ modkey
, }, "h", function () awful
.tag.incmwfact(-0.05) end),
221 awful
.key({ modkey
, "Shift" }, "h", function () awful
.tag.incnmaster( 1) end),
222 awful
.key({ modkey
, "Shift" }, "l", function () awful
.tag.incnmaster(-1) end),
223 awful
.key({ modkey
, "Control" }, "h", function () awful
.tag.incncol( 1) end),
224 awful
.key({ modkey
, "Control" }, "l", function () awful
.tag.incncol(-1) end),
225 awful
.key({ modkey
, }, "space", function () awful
.layout
.inc(layouts
, 1) end),
226 awful
.key({ modkey
, "Shift" }, "space", function () awful
.layout
.inc(layouts
, -1) end),
229 awful
.key({ modkey
}, "r", function () mypromptbox
[mouse
.screen
]:run() end),
231 awful
.key({ modkey
}, "x",
233 awful
.prompt
.run({ prompt
= "Run Lua code: " },
234 mypromptbox
[mouse
.screen
].widget
,
235 awful
.util
.eval
, nil,
236 awful
.util
.getdir("cache") .. "/history_eval")
240 -- Client awful tagging: this is useful to tag some clients and then do stuff like move to tag on them
241 clientkeys
= awful
.util
.table.join(
242 awful
.key({ modkey
, }, "f", function (c
) c
.fullscreen
= not c
.fullscreen
end),
243 awful
.key({ modkey
, "Shift" }, "c", function (c
) c
:kill() end),
244 awful
.key({ modkey
, "Control" }, "space", awful
.client
.floating
.toggle
),
245 awful
.key({ modkey
, "Control" }, "Return", function (c
) c
:swap(awful
.client
.getmaster()) end),
246 awful
.key({ modkey
, }, "o", awful
.client
.movetoscreen
),
247 awful
.key({ modkey
, "Shift" }, "r", function (c
) c
:redraw() end),
248 awful
.key({ modkey
,}, "m",
250 c
.maximized_horizontal
= not c
.maximized_horizontal
251 c
.maximized_vertical
= not c
.maximized_vertical
255 -- Compute the maximum number of digit we need, limited to 9
257 for s
= 1, screen
.count() do
258 keynumber
= math
.min(9, math
.max(#tags
[s
], keynumber
));
261 for i
= 1, keynumber
do
262 globalkeys
= awful
.util
.table.join(globalkeys
,
263 awful
.key({ modkey
}, i
,
265 local screen
= mouse
.screen
266 if tags
[screen
][i
] then
267 awful
.tag.viewonly(tags
[screen
][i
])
270 awful
.key({ modkey
, "Control" }, i
,
272 local screen
= mouse
.screen
273 if tags
[screen
][i
] then
274 tags
[screen
][i
].selected
= not tags
[screen
][i
].selected
277 awful
.key({ modkey
, "Shift" }, i
,
279 if client
.focus
and tags
[client
.focus
.screen
][i
] then
280 awful
.client
.movetotag(tags
[client
.focus
.screen
][i
])
283 awful
.key({ modkey
, "Control", "Shift" }, i
,
285 if client
.focus
and tags
[client
.focus
.screen
][i
] then
286 awful
.client
.toggletag(tags
[client
.focus
.screen
][i
])
292 root
.keys(globalkeys
)
296 -- Signal function to execute when a new client appears.
297 client
.add_signal("manage", function (c
, startup
)
298 -- If we are not managing this application at startup,
299 -- move it to the screen where the mouse is.
300 -- We only do it for filtered windows (i.e. no dock, etc).
301 if not startup
and awful
.client
.focus
.filter(c
) then
302 c
.screen
= mouse
.screen
307 awful
.titlebar
.add(c
, { modkey
= modkey
})
309 -- Add mouse bindings
310 c
:buttons(awful
.util
.table.join(
311 awful
.button({ }, 1, function (c
) client
.focus
= c
; c
:raise() end),
312 awful
.button({ modkey
}, 1, awful
.mouse
.client
.move
),
313 awful
.button({ modkey
}, 3, awful
.mouse
.client
.resize
)
315 -- New client may not receive focus
316 -- if they're not focusable, so set border anyway.
317 c
.border_width
= beautiful
.border_width
318 c
.border_color
= beautiful
.border_normal
320 -- Check if the application should be floating.
322 local inst
= c
.instance
323 if floatapps
[cls
] ~= nil then
324 awful
.client
.floating
.set(c
, floatapps
[cls
])
325 elseif floatapps
[inst
] ~= nil then
326 awful
.client
.floating
.set(c
, floatapps
[inst
])
329 -- Check application->screen/tag mappings.
332 target
= apptags
[cls
]
333 elseif apptags
[inst
] then
334 target
= apptags
[inst
]
337 c
.screen
= target
.screen
338 awful
.client
.movetotag(tags
[target
.screen
][target
.tag], c
)
341 -- Do this after tag mapping, so you don't see it on the wrong tag for a split second.
347 -- Enable sloppy focus
348 c
:add_signal("mouse::enter", function(c
)
349 if awful
.layout
.get(c
.screen
) ~= awful
.layout
.suit
.magnifier
350 and awful
.client
.focus
.filter(c
) then
355 -- Set the windows at the slave,
356 -- i.e. put it at the end of others instead of setting it master.
357 -- awful.client.setslave(c)
359 -- Honor size hints: if you want to drop the gaps between windows, set this to false.
360 -- c.size_hints_honor = false
363 client
.add_signal("focus", function(c
) c
.border_color
= beautiful
.border_focus
end)
364 client
.add_signal("unfocus", function(c
) c
.border_color
= beautiful
.border_normal
end)