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")
|
9
|
|
10
|
require("blingbling")
|
11
|
|
12
|
|
13
|
require("run_once")
|
14
|
|
15
|
-- allow for transparancy. taken from http://awesome.naquadah.org/wiki/Transparency
|
16
|
-- for some nice dropshadows. Replace with cairo-compmgr sometime if viable
|
17
|
|
18
|
--awful.util.spawn_with_shell("xcompmgr -CcFf -t-5 -l-5 -r10.2 -o.55 -D3 -I-.015 -O-.03 &")
|
19
|
awful.util.spawn_with_shell("unagi")
|
20
|
-- {{{ Variable definitions
|
21
|
-- Themes define colours, icons, and wallpapers
|
22
|
beautiful.init(awful.util.getdir("config") .. "/themes/zenburn/theme.lua")
|
23
|
|
24
|
-- This is used later as the default terminal and editor to run.
|
25
|
terminal = "urxvt"
|
26
|
editor = os.getenv("EDITOR") or "nano"
|
27
|
editor_cmd = terminal .. " -e " .. editor
|
28
|
|
29
|
-- Default modkey.
|
30
|
-- Usually, Mod4 is the key with a logo between Control and Alt.
|
31
|
-- If you do not like this or do not have such a key,
|
32
|
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
|
33
|
-- However, you can use another modifier like Mod1, but it may interact with others.
|
34
|
modkey = "Mod4"
|
35
|
|
36
|
-- Table of layouts to cover with awful.layout.inc, order matters.
|
37
|
layouts =
|
38
|
{
|
39
|
awful.layout.suit.floating,
|
40
|
awful.layout.suit.tile,
|
41
|
awful.layout.suit.tile.left,
|
42
|
awful.layout.suit.tile.bottom,
|
43
|
awful.layout.suit.tile.top,
|
44
|
awful.layout.suit.fair,
|
45
|
awful.layout.suit.fair.horizontal,
|
46
|
awful.layout.suit.spiral,
|
47
|
awful.layout.suit.spiral.dwindle,
|
48
|
awful.layout.suit.max,
|
49
|
awful.layout.suit.max.fullscreen,
|
50
|
awful.layout.suit.magnifier
|
51
|
}
|
52
|
-- }}}
|
53
|
|
54
|
-- {{{ Tags
|
55
|
-- Define a tag table which hold all screen tags.
|
56
|
tags = {}
|
57
|
for s = 1, screen.count() do
|
58
|
-- Each screen has its own tag table.
|
59
|
tags[s] = awful.tag({ 1, 2, 3, 4, 5, 6, 7, 8, 9 }, s, layouts[1])
|
60
|
end
|
61
|
-- }}}
|
62
|
mythememenu = {}
|
63
|
|
64
|
function theme_load(theme)
|
65
|
local cfg_path = awful.util.getdir("config")
|
66
|
|
67
|
-- Create a symlink from the given theme to /home/user/.config/awesome/current_theme
|
68
|
awful.util.spawn("ln -sfn " .. cfg_path .. "/themes/" .. theme .. " " .. cfg_path .. "/current_theme")
|
69
|
awesome.restart()
|
70
|
end
|
71
|
|
72
|
function theme_menu()
|
73
|
-- List your theme files and feed the menu table
|
74
|
local cmd = "ls -1 " .. awful.util.getdir("config") .. "/themes/"
|
75
|
local f = io.popen(cmd)
|
76
|
|
77
|
for l in f:lines() do
|
78
|
local item = { l, function () theme_load(l) end }
|
79
|
table.insert(mythememenu, item)
|
80
|
end
|
81
|
|
82
|
f:close()
|
83
|
end
|
84
|
|
85
|
-- Generate your table at startup or restart
|
86
|
theme_menu()
|
87
|
-- {{{ Menu
|
88
|
-- Create a laucher widget and a main menu
|
89
|
myawesomemenu = {
|
90
|
{ "manual", terminal .. " -e man awesome" },
|
91
|
{ "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
|
92
|
{ "themes", mythememenu },
|
93
|
{ "restart", awesome.restart },
|
94
|
{ "quit", awesome.quit }
|
95
|
}
|
96
|
|
97
|
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
|
98
|
{ "open terminal", terminal },
|
99
|
{"Log out", '~/scripts/desktop/wm-logout'},
|
100
|
}
|
101
|
})
|
102
|
|
103
|
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
|
104
|
menu = mymainmenu })
|
105
|
-- }}}
|
106
|
|
107
|
-- {{{ Wibox
|
108
|
-- Create a textclock widget
|
109
|
mytextclock = awful.widget.textclock({ align = "right" })
|
110
|
|
111
|
require("orglendar")
|
112
|
orglendar.files = { "/home/bearcat/org_files/notes.org"}
|
113
|
orglendar.register(mytextclock)
|
114
|
|
115
|
-- Create a systray
|
116
|
mysystray = widget({ type = "systray" })
|
117
|
|
118
|
-- Create a wibox for each screen and add it
|
119
|
mywibox = {}
|
120
|
mypromptbox = {}
|
121
|
mylayoutbox = {}
|
122
|
mytaglist = {}
|
123
|
mytaglist.buttons = awful.util.table.join(
|
124
|
awful.button({ }, 1, awful.tag.viewonly),
|
125
|
awful.button({ modkey }, 1, awful.client.movetotag),
|
126
|
awful.button({ }, 3, awful.tag.viewtoggle),
|
127
|
awful.button({ modkey }, 3, awful.client.toggletag),
|
128
|
awful.button({ }, 4, awful.tag.viewnext),
|
129
|
awful.button({ }, 5, awful.tag.viewprev)
|
130
|
)
|
131
|
mytasklist = {}
|
132
|
mytasklist.buttons = awful.util.table.join(
|
133
|
awful.button({ }, 1, function (c)
|
134
|
if c == client.focus then
|
135
|
c.minimized = true
|
136
|
else
|
137
|
if not c:isvisible() then
|
138
|
awful.tag.viewonly(c:tags()[1])
|
139
|
end
|
140
|
-- This will also un-minimize
|
141
|
-- the client, if needed
|
142
|
client.focus = c
|
143
|
c:raise()
|
144
|
end
|
145
|
end),
|
146
|
awful.button({ }, 3, function ()
|
147
|
if instance then
|
148
|
instance:hide()
|
149
|
instance = nil
|
150
|
else
|
151
|
instance = awful.menu.clients({ width=250 })
|
152
|
end
|
153
|
end),
|
154
|
awful.button({ }, 4, function ()
|
155
|
awful.client.focus.byidx(1)
|
156
|
if client.focus then client.focus:raise() end
|
157
|
end),
|
158
|
awful.button({ }, 5, function ()
|
159
|
awful.client.focus.byidx(-1)
|
160
|
if client.focus then client.focus:raise() end
|
161
|
end))
|
162
|
|
163
|
for s = 1, screen.count() do
|
164
|
-- Create a promptbox for each screen
|
165
|
mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
|
166
|
-- Create an imagebox widget which will contains an icon indicating which layout we're using.
|
167
|
-- We need one layoutbox per screen.
|
168
|
mylayoutbox[s] = awful.widget.layoutbox(s)
|
169
|
mylayoutbox[s]:buttons(awful.util.table.join(
|
170
|
awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
|
171
|
awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
|
172
|
awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
|
173
|
awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
|
174
|
-- Create a taglist widget
|
175
|
mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
|
176
|
|
177
|
-- Create a tasklist widget
|
178
|
mytasklist[s] = awful.widget.tasklist(function(c)
|
179
|
return awful.widget.tasklist.label.currenttags(c, s)
|
180
|
end, mytasklist.buttons)
|
181
|
-- Disc mounting widgets taken from http://awesome.naquadah.org/wiki/Blingbling#example_of_udisks-glue_menu
|
182
|
--- ud_glue = blingbling.udisks_glue.new(beautiful.dialog_ok)
|
183
|
--- ud_glue:set_mount_icon(beautiful.dialog_ok)
|
184
|
--- ud_glue:set_umount_icon(beautiful.dialog_cancel)
|
185
|
--- ud_glue:set_detach_icon(beautiful.dialog_cancel)
|
186
|
--- ud_glue:set_Usb_icon(beautiful.usb_icon)
|
187
|
--- ud_glue:set_Cdrom_icon(beautiful.cdrom_icon)
|
188
|
|
189
|
--Alsa Volume widget
|
190
|
--- myvolume = blingbling.volume.new()
|
191
|
--- myvolume:set_height(18)
|
192
|
--- myvolume:set_width(30)
|
193
|
--bind the volume widget on the master channel
|
194
|
--- my_volume:update_master()
|
195
|
--- my_volume:set_master_control()
|
196
|
--- my_volume:set_bar(true)
|
197
|
|
198
|
|
199
|
-- Create the wibox
|
200
|
mywibox[s] = awful.wibox({ position = "top", screen = s })
|
201
|
-- Add widgets to the wibox - order matters
|
202
|
mywibox[s].widgets = {
|
203
|
{
|
204
|
mylauncher,
|
205
|
mytaglist[s],
|
206
|
mypromptbox[s],
|
207
|
--- ud_glue.widget,
|
208
|
--- myvolume.widget,
|
209
|
layout = awful.widget.layout.horizontal.leftright
|
210
|
},
|
211
|
mylayoutbox[s],
|
212
|
mytextclock,
|
213
|
s == 1 and mysystray or nil,
|
214
|
mytasklist[s],
|
215
|
layout = awful.widget.layout.horizontal.rightleft
|
216
|
}
|
217
|
end
|
218
|
-- }}}
|
219
|
|
220
|
-- {{{ Mouse bindings
|
221
|
root.buttons(awful.util.table.join(
|
222
|
awful.button({ }, 3, function () mymainmenu:toggle() end),
|
223
|
awful.button({ }, 4, awful.tag.viewnext),
|
224
|
awful.button({ }, 5, awful.tag.viewprev)
|
225
|
))
|
226
|
-- }}}
|
227
|
|
228
|
-- {{{ Key bindings
|
229
|
globalkeys = awful.util.table.join(
|
230
|
awful.key({ modkey, }, "Left", awful.tag.viewprev ),
|
231
|
awful.key({ modkey, }, "Right", awful.tag.viewnext ),
|
232
|
awful.key({ modkey, }, "Escape", awful.tag.history.restore),
|
233
|
|
234
|
awful.key({ modkey, }, "j",
|
235
|
function ()
|
236
|
awful.client.focus.byidx( 1)
|
237
|
if client.focus then client.focus:raise() end
|
238
|
end),
|
239
|
awful.key({ modkey, }, "k",
|
240
|
function ()
|
241
|
awful.client.focus.byidx(-1)
|
242
|
if client.focus then client.focus:raise() end
|
243
|
end),
|
244
|
awful.key({ modkey, }, "w", function () mymainmenu:show({keygrabber=true}) end),
|
245
|
|
246
|
-- Layout manipulation
|
247
|
awful.key({ modkey, "Shift" }, "j", function () awful.client.swap.byidx( 1) end),
|
248
|
awful.key({ modkey, "Shift" }, "k", function () awful.client.swap.byidx( -1) end),
|
249
|
awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
|
250
|
awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
|
251
|
awful.key({ modkey, }, "u", awful.client.urgent.jumpto),
|
252
|
awful.key({ modkey, }, "Tab",
|
253
|
function ()
|
254
|
awful.client.focus.history.previous()
|
255
|
if client.focus then
|
256
|
client.focus:raise()
|
257
|
end
|
258
|
end),
|
259
|
|
260
|
-- Standard program
|
261
|
awful.key({ modkey, }, "Return", function () awful.util.spawn(terminal) end),
|
262
|
awful.key({ modkey, "Control" }, "r", awesome.restart),
|
263
|
awful.key({ modkey, "Shift" }, "q", awesome.quit),
|
264
|
|
265
|
awful.key({ modkey, }, "l", function () awful.tag.incmwfact( 0.05) end),
|
266
|
awful.key({ modkey, }, "h", function () awful.tag.incmwfact(-0.05) end),
|
267
|
awful.key({ modkey, "Shift" }, "h", function () awful.tag.incnmaster( 1) end),
|
268
|
awful.key({ modkey, "Shift" }, "l", function () awful.tag.incnmaster(-1) end),
|
269
|
awful.key({ modkey, "Control" }, "h", function () awful.tag.incncol( 1) end),
|
270
|
awful.key({ modkey, "Control" }, "l", function () awful.tag.incncol(-1) end),
|
271
|
awful.key({ modkey, }, "space", function () awful.layout.inc(layouts, 1) end),
|
272
|
awful.key({ modkey, "Shift" }, "space", function () awful.layout.inc(layouts, -1) end),
|
273
|
|
274
|
awful.key({ modkey, "Control" }, "n", awful.client.restore),
|
275
|
|
276
|
-- Prompt
|
277
|
awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
|
278
|
|
279
|
awful.key({ modkey }, "x",
|
280
|
function ()
|
281
|
awful.prompt.run({ prompt = "Run Lua code: " },
|
282
|
mypromptbox[mouse.screen].widget,
|
283
|
awful.util.eval, nil,
|
284
|
awful.util.getdir("cache") .. "/history_eval")
|
285
|
end)
|
286
|
)
|
287
|
|
288
|
clientkeys = awful.util.table.join(
|
289
|
awful.key({ modkey, }, "f", function (c) c.fullscreen = not c.fullscreen end),
|
290
|
awful.key({ modkey, "Shift" }, "c", function (c) c:kill() end),
|
291
|
awful.key({ modkey, "Control" }, "space", awful.client.floating.toggle ),
|
292
|
awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
|
293
|
awful.key({ modkey, }, "o", awful.client.movetoscreen ),
|
294
|
awful.key({ modkey, "Shift" }, "r", function (c) c:redraw() end),
|
295
|
awful.key({ modkey, }, "t", function (c) c.ontop = not c.ontop end),
|
296
|
awful.key({ modkey, }, "n",
|
297
|
function (c)
|
298
|
-- The client currently has the input focus, so it cannot be
|
299
|
-- minimized, since minimized clients can't have the focus.
|
300
|
c.minimized = true
|
301
|
end),
|
302
|
awful.key({ modkey, }, "m",
|
303
|
function (c)
|
304
|
c.maximized_horizontal = not c.maximized_horizontal
|
305
|
c.maximized_vertical = not c.maximized_vertical
|
306
|
end)
|
307
|
)
|
308
|
|
309
|
-- Compute the maximum number of digit we need, limited to 9
|
310
|
keynumber = 0
|
311
|
for s = 1, screen.count() do
|
312
|
keynumber = math.min(9, math.max(#tags[s], keynumber));
|
313
|
end
|
314
|
|
315
|
-- Bind all key numbers to tags.
|
316
|
-- Be careful: we use keycodes to make it works on any keyboard layout.
|
317
|
-- This should map on the top row of your keyboard, usually 1 to 9.
|
318
|
for i = 1, keynumber do
|
319
|
globalkeys = awful.util.table.join(globalkeys,
|
320
|
awful.key({ modkey }, "#" .. i + 9,
|
321
|
function ()
|
322
|
local screen = mouse.screen
|
323
|
if tags[screen][i] then
|
324
|
awful.tag.viewonly(tags[screen][i])
|
325
|
end
|
326
|
end),
|
327
|
awful.key({ modkey, "Control" }, "#" .. i + 9,
|
328
|
function ()
|
329
|
local screen = mouse.screen
|
330
|
if tags[screen][i] then
|
331
|
awful.tag.viewtoggle(tags[screen][i])
|
332
|
end
|
333
|
end),
|
334
|
awful.key({ modkey, "Shift" }, "#" .. i + 9,
|
335
|
function ()
|
336
|
if client.focus and tags[client.focus.screen][i] then
|
337
|
awful.client.movetotag(tags[client.focus.screen][i])
|
338
|
end
|
339
|
end),
|
340
|
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
|
341
|
function ()
|
342
|
if client.focus and tags[client.focus.screen][i] then
|
343
|
awful.client.toggletag(tags[client.focus.screen][i])
|
344
|
end
|
345
|
end))
|
346
|
end
|
347
|
|
348
|
clientbuttons = awful.util.table.join(
|
349
|
awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
|
350
|
awful.button({ modkey }, 1, awful.mouse.client.move),
|
351
|
awful.button({ modkey }, 3, awful.mouse.client.resize))
|
352
|
|
353
|
-- Set keys
|
354
|
root.keys(globalkeys)
|
355
|
-- }}}
|
356
|
|
357
|
-- {{{ Rules
|
358
|
awful.rules.rules = {
|
359
|
-- All clients will match this rule.
|
360
|
{ rule = { },
|
361
|
properties = { border_width = beautiful.border_width,
|
362
|
border_color = beautiful.border_normal,
|
363
|
focus = true,
|
364
|
keys = clientkeys,
|
365
|
buttons = clientbuttons } },
|
366
|
{ rule = { class = "MPlayer" },
|
367
|
properties = { floating = true } },
|
368
|
{ rule = { class = "pinentry" },
|
369
|
properties = { floating = true } },
|
370
|
{ rule = { class = "gimp" },
|
371
|
properties = { floating = true } },
|
372
|
{ rule = { class = "QEMU" },
|
373
|
properties = { floating = true } },
|
374
|
{ rule = { class = "feh" },
|
375
|
properties = { floating = true }},
|
376
|
-- { rule = { class = "URxvt" },
|
377
|
-- properties = { opacity = 0.8 } },
|
378
|
|
379
|
|
380
|
-- Set Firefox to always map on tags number 2 of screen 1.
|
381
|
-- { rule = { class = "Firefox" },
|
382
|
-- properties = { tag = tags[1][2] } },
|
383
|
}
|
384
|
-- }}}
|
385
|
|
386
|
-- {{{ Signals
|
387
|
-- Signal function to execute when a new client appears.
|
388
|
client.add_signal("manage", function (c, startup)
|
389
|
-- Add a titlebar
|
390
|
-- awful.titlebar.add(c, { modkey = modkey })
|
391
|
|
392
|
-- Enable sloppy focus
|
393
|
c:add_signal("mouse::enter", function(c)
|
394
|
if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
|
395
|
and awful.client.focus.filter(c) then
|
396
|
client.focus = c
|
397
|
end
|
398
|
end)
|
399
|
|
400
|
if not startup then
|
401
|
-- Set the windows at the slave,
|
402
|
-- i.e. put it at the end of others instead of setting it master.
|
403
|
-- awful.client.setslave(c)
|
404
|
|
405
|
-- Put windows in a smart way, only if they does not set an initial position.
|
406
|
if not c.size_hints.user_position and not c.size_hints.program_position then
|
407
|
awful.placement.no_overlap(c)
|
408
|
awful.placement.no_offscreen(c)
|
409
|
end
|
410
|
end
|
411
|
end)
|
412
|
|
413
|
client.add_signal("focus", function(c)
|
414
|
c.border_color = beautiful.border_focus
|
415
|
if c.class and (c.class:lower():find("rxvt")) then
|
416
|
c.opacity = 1.0
|
417
|
end
|
418
|
end)
|
419
|
client.add_signal("unfocus", function(c)
|
420
|
c.border_color = beautiful.border_normal
|
421
|
if c.class and (c.class:lower():find("rxvt")) then
|
422
|
c.opacity = 0.5
|
423
|
end
|
424
|
end)
|
425
|
-- }}}
|
426
|
-- If there is no terminal open, open one on start
|
427
|
--run_once("urxvt")
|