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
require("vicious")
10
-- Load Debian menu entries
11
require("debian.menu")
12
13
-- {{{ Variable definitions
14
-- Themes define colours, icons, and wallpapers
15
beautiful.init(awful.util.getdir("config") .. "/themes/.current")
16
17
-- This is used later as the default terminal and editor to run.
18
browser = "firefox-bin"
19
mail = "rxvt-unicode -bg black -tint green +sb -tr -sh 15 -fn 8x13 -fg green -geometry 75x25 -e mutt"
20
-- terminal = "rxvt-unicode -bg black -tint green +sb -tr -sh 15 -fn 8x13 -fg green -geometry 75x25"
21
terminal = "rxvt-unicode -bg black -tint green +sb -tr -sh 15 -fn 8x13 -fg green -geometry 75x25"
22
editor = "vim"
23
mixer = "alsamixer"
24
editor_cmd = terminal .. " -e " .. editor
25
26
-- Default modkey.
27
-- Usually, Mod4 is the key with a logo between Control and Alt.
28
-- If you do not like this or do not have such a key,
29
-- I suggest you to remap Mod4 to another key using xmodmap or other tools.
30
-- However, you can use another modifier like Mod1, but it may interact with others.
31
modkey = "Mod4"
32
33
-- Table of layouts to cover with awful.layout.inc, order matters.
34
layouts =
35
{
36
    awful.layout.suit.tile,
37
    awful.layout.suit.tile.left,
38
    awful.layout.suit.tile.bottom,
39
    awful.layout.suit.tile.top,
40
    awful.layout.suit.fair,
41
    awful.layout.suit.fair.horizontal,
42
    awful.layout.suit.spiral,
43
    awful.layout.suit.spiral.dwindle,
44
    awful.layout.suit.max,
45
    awful.layout.suit.max.fullscreen,
46
    awful.layout.suit.magnifier,
47
    awful.layout.suit.floating
48
}
49
-- }}}
50
51
52
-- {{{ Separators
53
myspacer         = widget({ type = "textbox", name = "myspacer" })
54
myseparator      = widget({ type = "textbox", name = "myseparator" })
55
myspacer.text    = " "
56
myseparator.text = "|"
57
-- }}}
58
59
-- {{{ Tags
60
-- Define a tag table which hold all screen tags.
61
tags = {}
62
for s = 1, screen.count() do
63
    -- Each screen has its own tag table.
64
    tags[s] = awful.tag({ "mail", "im", "web", "media", "tty1", "tty2", "tty3", "tty4", "tty5"}, s, layouts[1])
65
end
66
-- }}}
67
68
-- {{{ Menu
69
-- Create a laucher widget and a main menu
70
myawesomemenu = {
71
   { "manual", terminal .. " -e man awesome" },
72
   { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
73
   { "restart", awesome.restart },
74
   { "quit", awesome.quit }
75
}
76
77
mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
78
                                    { "Debian", debian.menu.Debian_menu.Debian },
79
                                    { "open terminal", terminal }
80
                                  }
81
                        })
82
83
mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
84
                                     menu = mymainmenu })
85
-- }}}
86
87
-- {{{ Wibox
88
-- Vol
89
volicon = widget({ type = "imagebox" })
90
volicon.image = image(beautiful.widget_vol)
91
92
volwidget = awful.widget.progressbar({ layout = awful.widget.layout.horizontal.rightleft })
93
volwidgettext = widget({ type = "textbox" })
94
95
volwidget:set_vertical(true):set_ticks(true)
96
volwidget:set_height(14):set_width(8):set_ticks_size(2)
97
volwidget:set_background_color(beautiful.fg_off_widget)
98
volwidget:set_gradient_colors({ beautiful.fg_center_widget,
99
   beautiful.fg_center_widget, beautiful.fg_end_widget
100
}) 
101
vicious.cache(vicious.widgets.volume)
102
103
vicious.register(volwidget,    vicious.widgets.volume,  "$1",  2, "PCM")
104
vicious.register(volwidgettext, vicious.widgets.volume, " $1% ", 2, "PCM")
105
106
-- Memory
107
memicon       = widget({ type = "imagebox", name = "memicon" })
108
memicon.image = image(beautiful.widget_mem)
109
110
memwidget = awful.widget.progressbar({ layout = awful.widget.layout.horizontal.rightleft })
111
112
memwidget:set_width(40)
113
memwidget:set_height(14)
114
memwidget:set_max_value(1)
115
memwidget:set_background_color(theme.bg_widget)
116
memwidget:set_border_color(nil)
117
memwidget:set_color(theme.fg_widget)
118
119
vicious.register(memwidget, vicious.widgets.mem, "$1", 15)
120
121
memwidgettext = widget({ type = "textbox" })
122
vicious.register(memwidgettext, vicious.widgets.mem, " $1% ($2MB/$3MB) ", 15)
123
124
-- CPU
125
cpuicon        = widget({ type = "imagebox", name = "cpuicon" })
126
cpuicon.image  = image(beautiful.widget_cpu)
127
128
cpuwidget = awful.widget.graph({ layout = awful.widget.layout.horizontal.rightleft })
129
130
cpuwidget:set_width(40)
131
cpuwidget:set_height(14)
132
cpuwidget:set_max_value(1)
133
cpuwidget:set_background_color(theme.bg_widget)
134
cpuwidget:set_border_color(nil)
135
cpuwidget:set_gradient_angle(0)
136
cpuwidget:set_gradient_colors({
137
    beautiful.fg_end_widget,
138
    beautiful.fg_center_widget,
139
    beautiful.fg_widget })
140
141
vicious.register(cpuwidget, vicious.widgets.cpu, "$1")
142
143
mytextclock = awful.widget.textclock({ align = "right" })
144
mysystray = widget({ type = "systray" })
145
146
-- Temperature
147
tempwidgettext = widget({ type = "textbox" })
148
vicious.register(tempwidgettext, vicious.widgets.thermal, " $1C ", 15, {"ATF0","proc"})
149
150
tempicon       = widget({ type = "imagebox", name = "thermicon" })
151
tempicon.image = image(beautiful.widget_temp)
152
153
tempwidget = awful.widget.progressbar({ layout = awful.widget.layout.horizontal.rightleft })
154
155
tempwidget:set_width(8)
156
tempwidget:set_height(14)
157
tempwidget:set_vertical(true)
158
tempwidget:set_max_value(1)
159
tempwidget:set_background_color(theme.bg_widget)
160
tempwidget:set_border_color(nil)
161
tempwidget:set_gradient_colors({
162
    beautiful.fg_end_widget,
163
    beautiful.fg_center_widget,
164
    beautiful.fg_widget })
165
166
vicious.register(tempwidget, vicious.widgets.thermal, "$1", 15, {"ATF0","proc"})
167
168
memwidgettext = widget({ type = "textbox" })
169
vicious.register(memwidgettext, vicious.widgets.mem, " $1% ($2MB/$3MB) ", 15)
170
171
-- Battery
172
batwidgettext = widget({ type = "textbox" })
173
vicious.register(batwidgettext, vicious.widgets.bat, " $2% ", 1, "BAT1")
174
175
baticon       = widget({ type = "imagebox", name = "baticon" })
176
baticon.image = image(beautiful.widget_bat)
177
178
batwidget = awful.widget.progressbar({ layout = awful.widget.layout.horizontal.rightleft })
179
180
batwidget:set_width(40)
181
batwidget:set_height(14)
182
batwidget:set_max_value(1)
183
batwidget:set_background_color(theme.bg_widget)
184
batwidget:set_border_color(nil)
185
batwidget:set_color(theme.fg_widget)
186
187
vicious.register(batwidget, vicious.widgets.bat, "$2", 15, "BAT1")
188
189
awful.widget.layout.margins[cpuwidget.widget] = { top = 2 }
190
awful.widget.layout.margins[memwidget.widget] = { top = 2 }
191
awful.widget.layout.margins[tempwidget.widget] = { top = 2 }
192
awful.widget.layout.margins[batwidget.widget] = { top = 2 }
193
awful.widget.layout.margins[volwidget.widget] = { top = 2 }
194
195
--memwidgettext = widget({ type = "textbox" })
196
-- vicious.register(batwidgettext, vicious.widgets.bat, " $1% ($2MB/$3MB) ", 15)
197
198
199
200
-- Create a wibox for each screen and add it
201
mywibox = {}
202
mypromptbox = {}
203
mylayoutbox = {}
204
mytaglist = {}
205
mytaglist.buttons = awful.util.table.join(
206
                    awful.button({ }, 1, awful.tag.viewonly),
207
                    awful.button({ modkey }, 1, awful.client.movetotag),
208
                    awful.button({ }, 3, awful.tag.viewtoggle),
209
                    awful.button({ modkey }, 3, awful.client.toggletag),
210
                    awful.button({ }, 4, awful.tag.viewnext),
211
                    awful.button({ }, 5, awful.tag.viewprev)
212
                    )
213
mytasklist = {}
214
mytasklist.buttons = awful.util.table.join(
215
                     awful.button({ }, 1, function (c)
216
                                              if not c:isvisible() then
217
                                                  awful.tag.viewonly(c:tags()[1])
218
                                              end
219
                                              client.focus = c
220
                                              c:raise()
221
                                          end),
222
                     awful.button({ }, 3, function ()
223
                                              if instance then
224
                                                  instance:hide()
225
                                                  instance = nil
226
                                              else
227
                                                  instance = awful.menu.clients({ width=250 })
228
                                              end
229
                                          end),
230
                     awful.button({ }, 4, function ()
231
                                              awful.client.focus.byidx(1)
232
                                              if client.focus then client.focus:raise() end
233
                                          end),
234
                     awful.button({ }, 5, function ()
235
                                              awful.client.focus.byidx(-1)
236
                                              if client.focus then client.focus:raise() end
237
                                          end))
238
239
240
widgets = {}
241
widgets[1] = {
242
            mytextclock, myseparator, -- clock
243
            volwidget, volwidgettext, volicon, -- vol
244
            memwidget, memwidgettext, memicon, -- mem
245
            cpuwidget, cpuicon, -- cpu
246
            tempwidget, tempwidgettext, tempicon, -- temp
247
            batwidget, batwidgettext, baticon -- bat
248
249
}
250
widgets[2] = {}
251
252
for s = 1, screen.count() do
253
    -- Create a promptbox for each screen
254
    mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
255
    -- Create an imagebox widget which will contains an icon indicating which layout we're using.
256
    -- We need one layoutbox per screen.
257
    mylayoutbox[s] = awful.widget.layoutbox(s)
258
    mylayoutbox[s]:buttons(awful.util.table.join(
259
                           awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
260
                           awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
261
                           awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
262
                           awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
263
    -- Create a taglist widget
264
    mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
265
266
    -- Create a tasklist widget
267
    mytasklist[s] = awful.widget.tasklist(function(c)
268
                                              return awful.widget.tasklist.label.currenttags(c, s)
269
                                          end, mytasklist.buttons)
270
271
    -- Create the wibox
272
    mywibox[s] = awful.wibox({ position = "top", screen = s })
273
    -- Add widgets to the wibox - order matters
274
275
		if s == 2 or screen.count() == 1 then
276
    mywibox[s].widgets = {
277
        {
278
            mylauncher,
279
            mytaglist[s],
280
            mypromptbox[s],
281
            layout = awful.widget.layout.horizontal.leftright
282
        },
283
        mylayoutbox[s],
284
				myseparator, myspacer,
285
        mysystray,
286
        mytextclock, myseparator, -- clock
287
        volwidget, volwidgettext, volicon, -- vol
288
        memwidget, memwidgettext, memicon, -- mem
289
        cpuwidget, cpuicon, -- cpu
290
        tempwidget, tempwidgettext, tempicon, -- temp
291
        batwidget, batwidgettext, baticon, -- bat
292
        mytasklist[s],
293
        layout = awful.widget.layout.horizontal.rightleft
294
    }
295
		else
296
    mywibox[s].widgets = {
297
        {
298
            mylauncher,
299
            mytaglist[s],
300
            mypromptbox[s],
301
            layout = awful.widget.layout.horizontal.leftright
302
        },
303
        mylayoutbox[s],
304
        mysystray,
305
        mytasklist[s],
306
        layout = awful.widget.layout.horizontal.rightleft
307
    }
308
		end
309
end
310
-- }}}
311
312
-- {{{ Mouse bindings
313
root.buttons(awful.util.table.join(
314
    awful.button({ }, 3, function () mymainmenu:toggle() end),
315
    awful.button({ }, 4, awful.tag.viewnext),
316
    awful.button({ }, 5, awful.tag.viewprev)
317
))
318
-- }}}
319
320
-- {{{ Key bindings
321
globalkeys = awful.util.table.join(
322
    awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
323
    awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
324
    awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
325
326
    awful.key({ modkey,           }, "j",
327
        function ()
328
            awful.client.focus.byidx( 1)
329
            if client.focus then client.focus:raise() end
330
        end),
331
    awful.key({ modkey,           }, "k",
332
        function ()
333
            awful.client.focus.byidx(-1)
334
            if client.focus then client.focus:raise() end
335
        end),
336
    awful.key({ modkey,           }, "w", function () mymainmenu:show({keygrabber=true}) end),
337
338
    -- Layout manipulation
339
    awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx(  1)    end),
340
    awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx( -1)    end),
341
    awful.key({ modkey, "Control" }, "j", function () awful.screen.focus_relative( 1) end),
342
    awful.key({ modkey, "Control" }, "k", function () awful.screen.focus_relative(-1) end),
343
    awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
344
    awful.key({ modkey,           }, "Tab",
345
        function ()
346
            awful.client.focus.history.previous()
347
            if client.focus then
348
                client.focus:raise()
349
            end
350
        end),
351
352
    -- Standard program
353
    awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
354
    awful.key({ modkey, "Control" }, "r", awesome.restart),
355
    awful.key({ modkey, "Shift"   }, "q", awesome.quit),
356
357
    awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
358
    awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
359
    awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
360
    awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
361
    awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
362
    awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
363
    awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
364
    awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
365
366
    -- Prompt
367
    awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
368
369
    awful.key({ modkey }, "x",
370
              function ()
371
                  awful.prompt.run({ prompt = "Run Lua code: " },
372
                  mypromptbox[mouse.screen].widget,
373
                  awful.util.eval, nil,
374
                  awful.util.getdir("cache") .. "/history_eval")
375
              end)
376
)
377
378
clientkeys = awful.util.table.join(
379
    awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
380
    awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
381
    awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
382
    awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
383
    awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
384
    awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
385
    awful.key({ modkey,           }, "t",      function (c) c.ontop = not c.ontop            end),
386
    awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
387
    awful.key({ modkey,           }, "m",
388
        function (c)
389
            c.maximized_horizontal = not c.maximized_horizontal
390
            c.maximized_vertical   = not c.maximized_vertical
391
        end)
392
)
393
394
-- Compute the maximum number of digit we need, limited to 9
395
keynumber = 0
396
for s = 1, screen.count() do
397
   keynumber = math.min(9, math.max(#tags[s], keynumber));
398
end
399
400
-- Bind all key numbers to tags.
401
-- Be careful: we use keycodes to make it works on any keyboard layout.
402
-- This should map on the top row of your keyboard, usually 1 to 9.
403
for i = 1, keynumber do
404
    globalkeys = awful.util.table.join(globalkeys,
405
        awful.key({ modkey }, "#" .. i + 9,
406
                  function ()
407
                        local screen = mouse.screen
408
                        if tags[screen][i] then
409
                            awful.tag.viewonly(tags[screen][i])
410
                        end
411
                  end),
412
        awful.key({ modkey, "Control" }, "#" .. i + 9,
413
                  function ()
414
                      local screen = mouse.screen
415
                      if tags[screen][i] then
416
                          awful.tag.viewtoggle(tags[screen][i])
417
                      end
418
                  end),
419
        awful.key({ modkey, "Shift" }, "#" .. i + 9,
420
                  function ()
421
                      if client.focus and tags[client.focus.screen][i] then
422
                          awful.client.movetotag(tags[client.focus.screen][i])
423
                      end
424
                  end),
425
        awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
426
                  function ()
427
                      if client.focus and tags[client.focus.screen][i] then
428
                          awful.client.toggletag(tags[client.focus.screen][i])
429
                      end
430
                  end))
431
end
432
433
clientbuttons = awful.util.table.join(
434
    awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
435
    awful.button({ modkey }, 1, awful.mouse.client.move),
436
    awful.button({ modkey }, 3, awful.mouse.client.resize))
437
438
-- Set keys
439
root.keys(globalkeys)
440
-- }}}
441
442
-- {{{ Rules
443
awful.rules.rules = {
444
    -- All clients will match this rule.
445
    { rule = { },
446
      properties = { border_width = beautiful.border_width,
447
                     border_color = beautiful.border_normal,
448
                     focus = true,
449
                     keys = clientkeys,
450
                     buttons = clientbuttons } },
451
    { rule = { class = "MPlayer" },
452
      properties = { floating = true } },
453
    { rule = { class = "pinentry" },
454
      properties = { floating = true } },
455
    { rule = { class = "gimp" },
456
      properties = { floating = true } },
457
    -- Set Firefox to always map on tags number 2 of screen 1.
458
    -- { rule = { class = "Firefox" },
459
    --   properties = { tag = tags[1][2] } },
460
}
461
-- }}}
462
463
-- {{{ Signals
464
-- Signal function to execute when a new client appears.
465
client.add_signal("manage", function (c, startup)
466
    -- Add a titlebar
467
    -- awful.titlebar.add(c, { modkey = modkey })
468
469
    -- Enable sloppy focus
470
    c:add_signal("mouse::enter", function(c)
471
        if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
472
            and awful.client.focus.filter(c) then
473
            client.focus = c
474
        end
475
    end)
476
477
    if not startup then
478
        -- Set the windows at the slave,
479
        -- i.e. put it at the end of others instead of setting it master.
480
        -- awful.client.setslave(c)
481
482
        -- Put windows in a smart way, only if they does not set an initial position.
483
        if not c.size_hints.user_position and not c.size_hints.program_position then
484
            awful.placement.no_overlap(c)
485
            awful.placement.no_offscreen(c)
486
        end
487
    end
488
end)
489
490
client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
491
client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
492
-- }}}