[download]
config/awesome/rc.lua
1 local gears = require("gears")
2 local awful = require("awful")
3 local wibox = require("wibox")
4 local beautiful = require("beautiful")
5
6 beautiful.font = "Terminus 9"
7 beautiful.master_width_factor = 0.55
8
9 beautiful.wibar_width = 0.75
10 beautiful.wibar_height = 20
11
12 beautiful.tasklist_spacing = 5
13 awesome.set_preferred_icon_size(48)
14
15 beautiful.border_width = 2
16 beautiful.titlebar_height = 17
17
18 beautiful.padding = 300
19 beautiful.gaps_outer = 15
20 beautiful.gaps_inner = 15
21
22 awful.rules.rules = {}
23 awful.layout.layouts = {
24 awful.layout.suit.tile,
25 awful.layout.suit.floating,
26 awful.layout.suit.max
27 }
28
29 Mod1 = { "Mod1" }
30 Mod1s = { "Mod1", "Shift" }
31
32 Mod4 = { "Mod4" }
33 Mod4a = { "Mod4", "Mod1" }
34 Mod4s = { "Mod4", "Shift" }
35 Mod4c = { "Mod4", "Control" }
36
37 -- Colors {{{
38
39 local bg = awesome.xrdb_get_value("", "Awesome.background")
40 local ba = awesome.xrdb_get_value("", "Awesome.background_rgba")
41 local fg = awesome.xrdb_get_value("", "Awesome.foreground")
42 local ug = awesome.xrdb_get_value("", "Awesome.yellow1")
43
44 beautiful.bg_normal = ba
45 beautiful.fg_normal = fg
46 beautiful.border_normal = ba
47
48 beautiful.bg_focus = fg
49 beautiful.fg_focus = bg
50 beautiful.border_focus = fg
51
52 beautiful.bg_urgent = ug
53 beautiful.fg_urgent = bg
54 beautiful.border_urgent = ug
55
56 theme_assets = require("beautiful.theme_assets")
57 beautiful.taglist_squares_sel = theme_assets.taglist_squares_sel(4, fg)
58 beautiful.taglist_squares_unsel = theme_assets.taglist_squares_unsel(4, fg)
59
60 beautiful.tasklist_bg_normal = "#0000"
61
62 -- }}}
63 -- Wibar {{{
64
65 awful.screen.connect_for_each_screen(function(s)
66 awful.tag({ " www ", " dev ", " doc ", " srv ", " alt ", " vid " }, s, awful.layout.layouts[1])
67
68 awful.widget.layoutbox(s):buttons(gears.table.join(
69 awful.button({}, 1, function() awful.layout.set(awful.layout.layouts[1]) end),
70 awful.button({}, 2, function() awful.layout.set(awful.layout.layouts[2]) end),
71 awful.button({}, 3, function() awful.layout.set(awful.layout.layouts[3]) end)
72 ))
73
74 s.bar = awful.wibar({ type = "dock" })
75 s.bar:setup({ layout = wibox.layout.fixed.horizontal, {
76 layout = wibox.layout.align.horizontal,
77 forced_width = (s.geometry.width * beautiful.wibar_width),
78
79 {
80 layout = wibox.layout.fixed.horizontal,
81 awful.widget.taglist(s, awful.widget.taglist.filter.all, gears.table.join(
82 awful.button({}, 1, function(t) t:view_only() end),
83 awful.button({}, 3, awful.tag.viewtoggle),
84
85 awful.button(Mod4, 1, function(t) client.focus:move_to_tag(t) end),
86 awful.button(Mod4, 3, function(t) client.focus:toggle_tag(t) end)
87 )),
88 wibox.widget.textbox(" ["),
89 awful.widget.layoutbox(s),
90 wibox.widget.textbox("] ")
91 },
92
93 {
94 layout = wibox.layout.fixed.horizontal,
95 awful.widget.tasklist(s, awful.widget.tasklist.filter.currenttags, gears.table.join(
96 awful.button({}, 1, function(c) client.focus = c; c:raise() end),
97 awful.button({}, 2, function(c) c:kill() end),
98 awful.button({}, 3, function(c) c:swap(awful.client.getmaster()) end),
99 awful.button({}, 4, function() awful.client.focus.byidx(-1) end),
100 awful.button({}, 5, function() awful.client.focus.byidx( 1) end)
101 ))
102 },
103
104 {
105 layout = wibox.layout.fixed.horizontal,
106 wibox.widget.textbox(" "),
107 wibox.widget.systray()
108 }
109 }})
110 end)
111
112 -- }}}
113 -- Keys {{{
114
115 table.insert(awful.rules.rules, { rule = {}, properties = {
116 raise = true,
117 screen = awful.screen.preferred,
118 focus = awful.client.focus.filter,
119
120 buttons = gears.table.join(
121 awful.button({}, 1, function(c) c:raise() end),
122 awful.button(Mod4, 1, function(c) c.floating = true; awful.mouse.client.move(c); c:raise() end),
123 awful.button(Mod4, 3, function(c) c.floating = true; awful.mouse.client.resize(c); c:raise() end)
124 ),
125
126 keys = gears.table.join(
127 awful.key(Mod4, "q", function(c) c:kill() end),
128 awful.key(Mod4, "z", function(c) c:swap(awful.client.getmaster()) end),
129 awful.key(Mod4s, "z", function(c) c.fullscreen = not c.fullscreen end),
130 awful.key(Mod4s, "space", function(c) c.floating = not c.floating end)
131 )
132 }})
133
134 root.keys(gears.table.join(root.keys(),
135 awful.key(Mod1, "Tab", function() awful.client.focus.byidx( 1) end),
136 awful.key(Mod1s, "Tab", function() awful.client.focus.byidx(-1) end),
137
138 awful.key(Mod4, "Up", function() awful.client.focus.byidx(-1) end),
139 awful.key(Mod4, "Down", function() awful.client.focus.byidx( 1) end),
140 awful.key(Mod4, "Left", function() awful.client.focus.byidx(-1) end),
141 awful.key(Mod4, "Right", function() awful.client.focus.byidx( 1) end),
142
143 awful.key(Mod4s, "Up", function() awful.client.swap.byidx(-1) end),
144 awful.key(Mod4s, "Down", function() awful.client.swap.byidx( 1) end),
145 awful.key(Mod4s, "Left", function() awful.client.swap.byidx(-1) end),
146 awful.key(Mod4s, "Right", function() awful.client.swap.byidx( 1) end),
147
148 awful.key(Mod4c, "Left", function() awful.tag.incmwfact(-0.01) end),
149 awful.key(Mod4c, "Right", function() awful.tag.incmwfact( 0.01) end),
150
151 awful.key(Mod4c, "i", function() awful.tag.incnmaster( 1) end),
152 awful.key(Mod4c, "o", function() awful.tag.incnmaster(-1) end),
153
154 awful.key(Mod4c, "t", function() awful.layout.set(awful.layout.suit.tile) end),
155 awful.key(Mod4c, "f", function() awful.layout.set(awful.layout.suit.floating) end),
156 awful.key(Mod4c, "z", function() awful.layout.set(awful.layout.suit.max) end),
157 awful.key(Mod4c, "g", function() awful.layout.set(awful.layout.suit.fair) end),
158 awful.key(Mod4c, "c", function() awful.layout.set(awful.layout.suit.magnifier) end),
159 awful.key(Mod4c, "v", function()
160 local t = awful.screen.focused().selected_tag
161 t.gap = t.gap == 0 and beautiful.gaps_inner or 0
162 end)
163 ))
164
165 for i = 1, 9 do
166 local t = awful.screen.focused().tags[i]
167 root.keys(gears.table.join(root.keys(),
168 awful.key(Mod4, "Tab", awful.tag.history.restore),
169 awful.key(Mod4, "#"..(i + 9), function() t:view_only() end),
170 awful.key(Mod4s, "#"..(i + 9), function() client.focus:move_to_tag(t) end),
171 awful.key(Mod4c, "#"..(i + 9), function() awful.tag.viewtoggle(t) end),
172 awful.key(Mod4a, "#"..(i + 9), function() client.focus:toggle_tag(t) end)
173 ))
174 end
175
176 -- }}}
177 -- Titlebar {{{
178
179 client.connect_signal("request::titlebars", function(c)
180 c.has_titlebar = true
181 awful.titlebar(c, { size = beautiful.titlebar_height }):setup({
182 layout = wibox.layout.align.horizontal,
183
184 {
185 awful.titlebar.widget.iconwidget(c),
186 layout = wibox.layout.fixed.horizontal
187 },
188
189 {
190 {
191 align = "center",
192 widget = awful.titlebar.widget.titlewidget(c)
193 },
194 layout = wibox.layout.flex.horizontal,
195 buttons = gears.table.join(
196 awful.button({}, 1, function() awful.mouse.client.move() end),
197 awful.button({}, 2, function() client.focus:kill() end),
198 awful.button({}, 3, function() awful.mouse.client.resize() end)
199 )
200 }
201 })
202 end)
203
204 -- }}}
205 -- Rules {{{
206
207 table.insert(awful.rules.rules, {
208 rule = { type = "dock" },
209 properties = { focusable = false }
210 })
211
212 table.insert(awful.rules.rules, {
213 rule_any = { type = { "normal", "dialog" } },
214 properties = { titlebars_enabled = true }
215 })
216
217 table.insert(awful.rules.rules, {
218 rule_any = {
219 role = { "pop-up" },
220 class = {
221 "explorer.exe",
222 "Xfce4-settings-manager",
223 }
224 },
225 properties = { floating = true }
226 })
227
228 table.insert(awful.rules.rules, {
229 rule = { x = 0 },
230 properties = { placement = awful.placement.centered }
231 })
232
233 table.insert(awful.rules.rules, {
234 rule = { class = "Audacious" },
235 properties = { titlebars_enabled = false }
236 })
237
238 -- }}}
239 -- Signals {{{
240
241 require("awful.autofocus")
242
243 screen.connect_signal("arrange", function(s) -- {{{
244 if s.selected_tag.gap == 0 or s.selected_tag.layout == awful.layout.suit.max then
245 if s.padding.left ~= 0 then s.padding = {} end
246 return
247 end
248
249 if #s.tiled_clients == 1 then
250 local padding = {
251 top = beautiful.gaps_outer - beautiful.gaps_inner,
252 bottom = beautiful.gaps_outer - beautiful.gaps_inner,
253 left = beautiful.padding - beautiful.gaps_inner,
254 right = beautiful.padding - beautiful.gaps_inner
255 }
256
257 if s.padding.left ~= padding.left then s.padding = padding end
258 elseif #s.tiled_clients > 1 then
259 local padding = {
260 top = beautiful.gaps_outer - beautiful.gaps_inner,
261 bottom = beautiful.gaps_outer - beautiful.gaps_inner,
262 left = beautiful.gaps_outer - beautiful.gaps_inner,
263 right = beautiful.gaps_outer - beautiful.gaps_inner
264 }
265
266 if s.padding.left ~= padding.left then s.padding = padding end
267 end
268 end) -- }}}
269 screen.connect_signal("arrange", function(s) -- {{{
270 for _, c in pairs(s.clients) do
271 c.border_width = s.selected_tag.gap == 0 and
272 not c.floating and beautiful.border_width or 0
273
274 if c.has_titlebar then
275 awful.titlebar[c.border_width == 0 and "show" or "hide"](c)
276 end
277 end
278 end) -- }}}
279 screen.connect_signal("arrange", function(s) -- {{{
280 local fullscreen = false
281
282 for _, c in pairs(s.clients) do fullscreen = fullscreen or c.fullscreen end
283 for _, c in pairs(s.clients) do c.ontop = c.floating and not fullscreen end
284 end) -- }}}
285
286 client.connect_signal("mouse::enter", function(c) client.focus = c end)
287 client.connect_signal("property::maximized", function(c) c.maximized = false end)
288
289 client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
290 client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
291
292 awesome.register_xproperty("_COMPTON_SHADOW", "boolean")
293 client.connect_signal("property::floating", function(c)
294 c:set_xproperty("_COMPTON_SHADOW", c.floating or nil)
295 end)
296
297 -- }}}
|