]> git.madduck.net Git - etc/awesome.git/blob - .config/awesome/rc.lua

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

updates
[etc/awesome.git] / .config / awesome / rc.lua
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("vicious")
11
12 -- Load Debian menu entries
13 require("debian.menu")
14
15 -- {{{ Variable definitions
16 -- Themes define colours, icons, and wallpapers
17 -- The default is a dark theme
18 theme_path = "/usr/share/awesome/themes/default/theme.lua"
19 -- Uncommment this for a lighter theme
20 -- theme_path = "/usr/share/awesome/themes/sky/theme.lua"
21
22 -- Actually load theme
23 beautiful.init(theme_path)
24
25 -- This is used later as the default terminal and editor to run.
26 terminal = "x-terminal-emulator"
27 editor = os.getenv("EDITOR") or "editor"
28 editor_cmd = terminal .. " -e " .. editor
29
30 -- Default modkey.
31 -- Usually, Mod4 is the key with a logo between Control and Alt.
32 -- If you do not like this or do not have such a key,
33 -- I suggest you to remap Mod4 to another key using xmodmap or other tools.
34 -- However, you can use another modifier like Mod1, but it may interact with others.
35 modkey = "Mod4"
36
37 -- Table of layouts to cover with awful.layout.inc, order matters.
38 layouts =
39 {
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     awful.layout.suit.floating
52 }
53
54 ---- Table of clients that should be set floating. The index may be either
55 ---- the application class or instance. The instance is useful when running
56 ---- a console app in a terminal like (Music on Console)
57 ----    xterm -name mocp -e mocp
58 ---- OVERRULED BY TILEDAPPS BELOW
59 --floatapps =
60 --{
61 --    -- by class
62 --    ["MPlayer"] = true,
63 --    ["pinentry"] = true,
64 --    ["GIMP"] = true,
65 --    ["twinkle"] = true,
66 --    ["Add-ons"] = true,
67 --    ["Play stream"] = true,
68 --    ["gscan2pdf"] = true,
69 --}
70 --
71 ---- Applications that should never float, assuming everything else floats
72 ---- (by instance)
73 --tiledapps =
74 --{
75 --    ["urxvt"] = true,
76 --}
77 --
78 ---- Applications that should be maximised
79 ---- (by instance)
80 --maxapps =
81 --{
82 --    ["Navigator"] = true,
83 --    -- jpilot is -v
84 --    ["-v"] = true,
85 --    ["Xpdf"] = true,
86 --    ["gscan2pdf"] = true
87 --}
88 --
89 ---- Applications to be moved to a pre-defined tag by class or instance.
90 ---- Use the screen and tags indices.
91 --apptags =
92 --{
93 --    ["Navigator"] = { screen = 1, tag = 9 },
94 --    -- jpilot is -v
95 --    ["-v"] = { screen = 1, tag = 8 },
96 --}
97
98 -- Define if we want to use titlebar on all applications.
99 use_titlebar = false
100 -- }}}
101
102 -- {{{ Tags
103 tags = {}
104 tags.settings = {
105     { name = "1", layout = layouts[1] },
106     { name = "2", layout = layouts[1] },
107     { name = "3", layout = layouts[1] },
108     { name = "4", layout = layouts[1] },
109     { name = "5", layout = layouts[1] },
110     { name = "6", layout = layouts[5] },
111     { name = "7", layout = layouts[5] },
112     { name = "8", layout = layouts[3] },
113     { name = "9", layout = layouts[3] },
114 }
115
116 -- Define a tag table which hold all screen tags.
117 for s = 1, screen.count() do
118     tags[s] = {}
119     for i, v in ipairs(tags.settings) do
120         tags[s][i] = tag({ name = v.name })
121         tags[s][i].screen = s
122         awful.tag.setproperty(tags[s][i], "layout", v.layout)
123         awful.tag.setproperty(tags[s][i], "mwfact", v.mwfact)
124         awful.tag.setproperty(tags[s][i], "hide",   v.hide)
125     end
126     tags[s][1].selected = true
127 end
128 -- }}}
129
130 -- {{{ Menu
131 -- Create a laucher widget and a main menu
132 myawesomemenu = {
133    { "manual", terminal .. " -e man awesome" },
134    { "edit config", editor_cmd .. " " .. awful.util.getdir("config") .. "/rc.lua" },
135    { "restart", awesome.restart },
136    { "quit", awesome.quit }
137 }
138
139 mymainmenu = awful.menu({ items = { { "awesome", myawesomemenu, beautiful.awesome_icon },
140                                     { "Debian", debian.menu.Debian_menu.Debian },
141                                     { "open terminal", terminal }
142                                   }
143                         })
144
145 mylauncher = awful.widget.launcher({ image = image(beautiful.awesome_icon),
146                                      menu = mymainmenu })
147 -- }}}
148
149 -- {{{ Wibox
150
151 -- {{{ Reusable separators
152 spacer         = widget({ type = "textbox", name = "spacer" })
153 separator      = widget({ type = "textbox", name = "separator" })
154 spacer.text    = " "
155 separator.text = "٭"
156 -- }}}
157
158 ---- {{{ CPU usage and temperature
159 ---- Widget icon
160 --cpuicon        = widget({ type = "imagebox", name = "cpuicon" })
161 --cpuicon.image  = image(beautiful.widget_cpu)
162 ---- Initialize widgets
163 --thermalwidget  = widget({ type = "textbox", name = "thermalwidget" })
164 --cpuwidget      = awful.widget.graph({ layout = awful.widget.layout.horizontal.rightleft })
165 ---- Graph properties
166 --cpuwidget:set_width(50)
167 ----cpuwidget:set_scale(false)
168 --cpuwidget:set_max_value(100)
169 --cpuwidget:set_background_color(beautiful.fg_off_widget)
170 --cpuwidget:set_border_color(beautiful.border_widget)
171 --cpuwidget:set_color(beautiful.fg_end_widget)
172 --cpuwidget:set_gradient_angle(0)
173 --cpuwidget:set_gradient_colors({
174 --    beautiful.fg_end_widget,
175 --    beautiful.fg_center_widget,
176 --    beautiful.fg_widget })
177 ---- Register widgets
178 --vicious.register(cpuwidget, vicious.widgets.cpu, "$1")
179 --vicious.register(thermalwidget, vicious.widgets.thermal, "CPU: $1°C", 19, "hwmon0")
180 ---- }}}
181
182 -- Battery widget
183 --batterywidget = widget({ type = 'progressbar', name = 'batterywidget' })
184 --batterywidget.width = 100
185 --batterywidget.height = 0.8
186 --batterywidget.gap = 1
187 --batterywidget.border_padding = 1
188 --batterywidget.border_width = 1
189 --batterywidget.ticks_count = 10
190 --batterywidget.ticks_gap = 1
191 --batterywidget.vertical = false
192 --batterywidget:bar_properties_set('bat', {
193 --  bg = 'black',
194 --  fg = 'blue4',
195 --  fg_off = 'red',
196 --  reverse = false,
197 --  min_value = 0,
198 --  max_value = 100
199 --})
200
201 -- Create a textclock widget
202 mytextclock = awful.widget.textclock({ align = "right" }, "%a %d %b %H:%M:%S", 1)
203
204 -- Create a systray
205 mysystray = widget({ type = "systray", align = "right" })
206
207 mybatterybox = widget({ type = "textbox", name = "mybatterybox", align = "right" })
208
209 -- Create a wibox for each screen and add it
210 mywibox = {}
211 mypromptbox = {}
212 mylayoutbox = {}
213 mytaglist = {}
214 mytaglist.buttons = awful.util.table.join(
215                     awful.button({ }, 1, awful.tag.viewonly),
216                     awful.button({ modkey }, 1, awful.client.movetotag),
217                     awful.button({ }, 3, awful.tag.viewtoggle),
218                     awful.button({ modkey }, 3, awful.client.toggletag),
219                     awful.button({ }, 4, awful.tag.viewnext),
220                     awful.button({ }, 5, awful.tag.viewprev)
221                     )
222 mytasklist = {}
223 mytasklist.buttons = awful.util.table.join(
224                      awful.button({ }, 1, function (c)
225                                               if not c:isvisible() then
226                                                   awful.tag.viewonly(c:tags()[1])
227                                               end
228                                               client.focus = c
229                                               c:raise()
230                                           end),
231                      awful.button({ }, 3, function ()
232                                               if instance then
233                                                   instance:hide()
234                                                   instance = nil
235                                               else
236                                                   instance = awful.menu.clients({ width=250 })
237                                               end
238                                           end),
239                      awful.button({ }, 4, function ()
240                                               awful.client.focus.byidx(1)
241                                               if client.focus then client.focus:raise() end
242                                           end),
243                      awful.button({ }, 5, function ()
244                                               awful.client.focus.byidx(-1)
245                                               if client.focus then client.focus:raise() end
246                                           end))
247
248 for s = 1, screen.count() do
249     -- Create a promptbox for each screen
250     mypromptbox[s] = awful.widget.prompt({ layout = awful.widget.layout.horizontal.leftright })
251     -- Create an imagebox widget which will contains an icon indicating which layout we're using.
252     -- We need one layoutbox per screen.
253     mylayoutbox[s] = awful.widget.layoutbox(s)
254     mylayoutbox[s]:buttons(awful.util.table.join(
255                            awful.button({ }, 1, function () awful.layout.inc(layouts, 1) end),
256                            awful.button({ }, 3, function () awful.layout.inc(layouts, -1) end),
257                            awful.button({ }, 4, function () awful.layout.inc(layouts, 1) end),
258                            awful.button({ }, 5, function () awful.layout.inc(layouts, -1) end)))
259     -- Create a taglist widget
260     mytaglist[s] = awful.widget.taglist(s, awful.widget.taglist.label.all, mytaglist.buttons)
261
262     -- Create a tasklist widget
263     mytasklist[s] = awful.widget.tasklist(function(c)
264                                               return awful.widget.tasklist.label.currenttags(c, s)
265                                           end, mytasklist.buttons)
266
267     -- Create the wibox
268     mywibox[s] = awful.wibox({ position = "top", screen = s })
269     -- Add widgets to the wibox - order matters
270     mywibox[s].widgets = {
271         {
272 --            mylauncher,
273             mytaglist[s],
274             mypromptbox[s],
275             layout = awful.widget.layout.horizontal.leftright
276         },
277         mylayoutbox[s],
278         spacer,
279         mytextclock,
280         spacer, separator, spacer,
281         mybatterybox,
282 --        batterywidget,
283 --        spacer, separator, spacer,
284 --        cpuwidget.widget,
285 --        spacer, separator, spacer,
286 --        thermalwidget.widget,
287         spacer,
288         s == screen.count() and mysystray or nil,
289         mytasklist[s],
290         layout = awful.widget.layout.horizontal.rightleft
291     }
292 end
293
294 -- }}}
295
296 -- {{{ Mouse bindings
297 root.buttons(awful.util.table.join(
298     awful.button({ }, 3, function () mymainmenu:toggle() end),
299     awful.button({ }, 4, awful.tag.viewnext),
300     awful.button({ }, 5, awful.tag.viewprev)
301 ))
302 -- }}}
303
304 -- {{{ Key bindings
305 globalkeys = awful.util.table.join(
306     awful.key({ modkey,           }, "Left",   awful.tag.viewprev       ),
307     awful.key({ modkey,           }, "Right",  awful.tag.viewnext       ),
308     awful.key({ modkey,           }, "Escape", awful.tag.history.restore),
309     awful.key({ modkey, "Shift"   }, "Right", function () awful.screen.focus( 1)       end),
310     awful.key({ modkey, "Shift"   }, "Left", function () awful.screen.focus(-1)       end),
311     awful.key({ modkey, "Shift"   }, "h",   awful.tag.viewprev       ),
312     awful.key({ modkey, "Shift"   }, "l",  awful.tag.viewnext       ),
313
314     awful.key({ modkey,           }, "k",
315         function ()
316             awful.client.focus.byidx( 1)
317             if client.focus then client.focus:raise() end
318         end),
319     awful.key({ modkey,           }, "j",
320         function ()
321             awful.client.focus.byidx(-1)
322             if client.focus then client.focus:raise() end
323         end),
324     awful.key({ modkey,           }, "w", function () mymainmenu:show(true)        end),
325
326     -- Layout manipulation
327     awful.key({ modkey, "Shift"   }, "k", function () awful.client.swap.byidx(  1) end),
328     awful.key({ modkey, "Shift"   }, "j", function () awful.client.swap.byidx( -1) end),
329     awful.key({ modkey, "Control" }, "k", function () awful.screen.focus( 1)       end),
330     awful.key({ modkey, "Control" }, "j", function () awful.screen.focus(-1)       end),
331     awful.key({ modkey,           }, "u", awful.client.urgent.jumpto),
332     awful.key({ modkey,           }, "Tab",
333         function ()
334             awful.client.focus.history.previous()
335             if client.focus then
336                 client.focus:raise()
337             end
338         end),
339
340     -- Standard program
341     awful.key({ modkey,           }, "Return", function () awful.util.spawn(terminal) end),
342     awful.key({ modkey, "Control" }, "r", awesome.restart),
343     awful.key({ modkey, "Shift"   }, "q", awesome.quit),
344
345     awful.key({ modkey,           }, "l",     function () awful.tag.incmwfact( 0.05)    end),
346     awful.key({ modkey,           }, "h",     function () awful.tag.incmwfact(-0.05)    end),
347     awful.key({ modkey, "Shift"   }, "h",     function () awful.tag.incnmaster( 1)      end),
348     awful.key({ modkey, "Shift"   }, "l",     function () awful.tag.incnmaster(-1)      end),
349     awful.key({ modkey, "Control" }, "h",     function () awful.tag.incncol( 1)         end),
350     awful.key({ modkey, "Control" }, "l",     function () awful.tag.incncol(-1)         end),
351     awful.key({ modkey,           }, "space", function () awful.layout.inc(layouts,  1) end),
352     awful.key({ modkey, "Shift"   }, "space", function () awful.layout.inc(layouts, -1) end),
353
354     -- Prompt
355     awful.key({ modkey },            "r",     function () mypromptbox[mouse.screen]:run() end),
356
357     awful.key({ modkey }, "x",
358               function ()
359                   awful.prompt.run({ prompt = "Run Lua code: " },
360                   mypromptbox[mouse.screen].widget,
361                   awful.util.eval, nil,
362                   awful.util.getdir("cache") .. "/history_eval")
363               end)
364 )
365
366 clientkeys = awful.util.table.join(
367     awful.key({ modkey,           }, "f",      function (c) c.fullscreen = not c.fullscreen  end),
368     awful.key({ modkey, "Shift"   }, "c",      function (c) c:kill()                         end),
369     awful.key({ modkey, "Control" }, "space",  awful.client.floating.toggle                     ),
370     awful.key({ modkey, "Control" }, "Return", function (c) c:swap(awful.client.getmaster()) end),
371     awful.key({ modkey,           }, "o",      awful.client.movetoscreen                        ),
372     awful.key({ modkey, "Shift"   }, "r",      function (c) c:redraw()                       end),
373     awful.key({ modkey            }, "t",      awful.client.togglemarked                        ),
374     awful.key({ modkey,           }, "n",      function (c) c.minimized = not c.minimized    end),
375     awful.key({ modkey,           }, "m",
376         function (c)
377             c.maximized_horizontal = not c.maximized_horizontal
378             c.maximized_vertical   = not c.maximized_vertical
379         end)
380 )
381
382 -- Compute the maximum number of digit we need, limited to 9
383 keynumber = 0
384 for s = 1, screen.count() do
385    keynumber = math.min(9, math.max(#tags[s], keynumber));
386 end
387
388 -- Bind all key numbers to tags.
389 -- Be careful: we use keycodes to make it works on any keyboard layout.
390 -- This should map on the top row of your keyboard, usually 1 to 9.
391 for i = 1, keynumber do
392     globalkeys = awful.util.table.join(globalkeys,
393         awful.key({ modkey }, "#" .. i + 9,
394                   function ()
395                         local screen = mouse.screen
396                         if tags[screen][i] then
397                             awful.tag.viewonly(tags[screen][i])
398                         end
399                   end),
400         awful.key({ modkey, "Control" }, "#" .. i + 9,
401                   function ()
402                       local screen = mouse.screen
403                       if tags[screen][i] then
404                           awful.tag.viewtoggle(tags[screen][i])
405                       end
406                   end),
407         awful.key({ modkey, "Shift" }, "#" .. i + 9,
408                   function ()
409                       if client.focus and tags[client.focus.screen][i] then
410                           awful.client.movetotag(tags[client.focus.screen][i])
411                       end
412                   end),
413         awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
414                   function ()
415                       if client.focus and tags[client.focus.screen][i] then
416                           awful.client.toggletag(tags[client.focus.screen][i])
417                       end
418                   end))
419 end
420
421 clientbuttons = awful.util.table.join(
422     awful.button({ }, 1, function (c) client.focus = c; c:raise() end),
423     awful.button({ modkey }, 1, awful.mouse.client.move),
424     awful.button({ modkey }, 3, awful.mouse.client.resize))
425
426 cmdmodkey = "Mod3"
427
428 -- xmms2 & sound
429 globalkeys = awful.util.table.join(globalkeys,
430   awful.key({ cmdmodkey }, "Prior", function () awful.util.spawn("amixer set Master 2+") end),
431   awful.key({ cmdmodkey }, "Next", function () awful.util.spawn("amixer set Master 2-") end),
432   awful.key({ cmdmodkey }, "Up", function () awful.util.spawn("amixer set PCM 2+") end),
433   awful.key({ cmdmodkey }, "Down", function () awful.util.spawn("amixer set PCM 2-") end),
434   awful.key({ cmdmodkey }, "Home", function () awful.util.spawn("amixer set Mic toggle") end),
435   awful.key({ cmdmodkey }, "End", function () awful.util.spawn("amixer set Master toggle") end),
436   awful.key({ cmdmodkey }, "Left", function () awful.util.spawn("xmms2 prev") end),
437   awful.key({ cmdmodkey }, "Right", function () awful.util.spawn("xmms2 next") end),
438   awful.key({ cmdmodkey }, "space", function () awful.util.spawn("xmms2 toggleplay") end),
439   awful.key({ cmdmodkey }, "backslash", function ()
440     local f = io.popen('xmms2 current', 'r')
441     naughty.notify({ title = "Now playing", text = f:read(), timeout = 5 })
442     f:close()
443   end),
444   awful.key({ cmdmodkey, "Shift" }, "backslash", function ()
445     local f = io.popen('xmms2 list', 'r')
446     naughty.notify({ title = "Playlist", text = f:read(), timeout = 15 })
447     f:close()
448   end)
449 )
450
451 -- misc apps
452 globalkeys = awful.util.table.join(globalkeys,
453   awful.key({ cmdmodkey }, "n", function () awful.util.spawn("sensible-browser") end),
454   awful.key({ cmdmodkey }, "m", function () awful.util.spawn(terminal .. " -e mutt -f =store") end),
455   awful.key({ cmdmodkey }, "t", function () awful.util.spawn(terminal) end),
456   awful.key({ cmdmodkey }, "c", function () awful.util.spawn(terminal .. " -e python") end),
457   awful.key({ cmdmodkey }, "r", function () mypromptbox[mouse.screen]:run() end),
458   awful.key({ cmdmodkey }, "j", function () awful.util.spawn("jpilot") end),
459   awful.key({ cmdmodkey }, "x", function () awful.util.spawn_with_shell("/sbin/start-stop-daemon --start --background --exec /usr/bin/xscreensaver; xscreensaver-command -lock") end),
460   awful.key({ cmdmodkey, "Shift" }, "x", function () awful.util.spawn("xscreensaver-command -exit") end),
461   awful.key(nil, "XF86ScreenSaver", function () awful.util.spawn("xset dpms force off") end)
462 )
463
464 -- Set keys
465 root.keys(globalkeys)
466 -- }}}
467
468 -- {{{ Rules
469 awful.rules.rules = {
470     -- All clients will match this rule.
471     { rule = { },
472       properties = { border_width = beautiful.border_width,
473                      border_color = beautiful.border_normal,
474                      focus = true,
475                      keys = clientkeys,
476                      buttons = clientbuttons } },
477     { rule = { class = "MPlayer" },
478       properties = { floating = true } },
479     { rule = { class = "pinentry" },
480       properties = { floating = true } },
481     { rule = { class = "gimp" },
482       properties = { floating = true } },
483     { rule = { class = "twinkle" },
484       properties = { floating = true } },
485     { rule = { class = "Play stream" },
486       properties = { floating = true } },
487     { rule = { class = "gscan2pdf" },
488       properties = { floating = true } },
489     { rule = { class = "Add-ons" },
490       properties = { floating = true } },
491     { rule = { class = "Iceweasel" },
492       properties = { tag = tags[1][screen.count()>1 and 1 or 9], switchtotag = false } },
493     { rule = { class = "Iceweasel", role = "Manager" },
494       properties = { floating = true } },
495     { rule = { class = "-v" },
496       properties = { tag = screen.count()>1 and tags[3][2] or tags[1][8], switchtotag = false } },
497 }
498 -- }}}
499
500 -- {{{ Signals
501 -- Signal function to execute when a new client appears.
502 client.add_signal("manage", function (c, startup)
503     -- Add a titlebar
504     -- awful.titlebar.add(c, { modkey = modkey })
505
506     -- Enable sloppy focus
507     c:add_signal("mouse::enter", function(c)
508         if awful.layout.get(c.screen) ~= awful.layout.suit.magnifier
509             and awful.client.focus.filter(c) then
510             client.focus = c
511         end
512     end)
513
514     if not startup then
515         -- Set the windows at the slave,
516         -- i.e. put it at the end of others instead of setting it master.
517         -- awful.client.setslave(c)
518
519         -- Put windows in a smart way, only if they does not set an initial position.
520         if not c.size_hints.user_position and not c.size_hints.program_position then
521             awful.placement.no_overlap(c)
522             awful.placement.no_offscreen(c)
523         end
524     end
525 end)
526
527 client.add_signal("focus", function(c) c.border_color = beautiful.border_focus end)
528 client.add_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
529
530 -- Hook called every sixty seconds
531 function hook_battery()
532     mybatterybox.text = " " .. get_acpibatt() .. " "
533 end
534 -- }}}
535
536 -- {{{ Statusbar battery
537 --
538 function get_acpibatt()
539     local f = io.popen('acpi -b', 'r')
540     if not f then
541       return "acpi -b failed"
542     end
543
544     local s = f:read('*l')
545     f:close()
546     if not s then
547       return '-';
548     end
549
550     -- Battery 0: Discharging, 89%, 00:02:14 remaining
551     -- Battery 0: Charging, 58%, 00:02:14 until charged
552     -- Battery 0: Full, 100%
553     -- so find the first bit first and then go look for the time
554     local st, en, status, percent = string.find(s, '%a+%s%d:%s(%a+),%s(%d+%%)');
555     local st, en, time = string.find(s, ',%s(%d+:%d+):%d+%s%a+', en);
556
557     if not status or not percent then -- time can be empty if we're full
558       return "couldn't parse line " .. s
559     end
560
561     if not time then
562       return percent
563     end
564
565     if status == 'Charging' then
566       return '↑ ' .. percent;
567     elseif status == 'Discharging' then
568       return '↓ '.. time;
569     else
570       return '';
571     end
572 end
573 t = timer({ timeout = 20 })
574 t:add_signal('timeout', hook_battery)
575 t:start()
576 hook_battery()
577 -- }}}
578
579 --{{{ batt hook
580 local function get_bat()
581   local a = io.open("/sys/class/power_supply/BAT1/charge_full")
582   for line in a:lines() do
583     full = line
584   end
585   a:close()
586   local b = io.open("/sys/class/power_supply/BAT1/charge_now")
587   for line in b:lines() do
588     now = line
589   end
590   b:close()
591   batt=math.floor(now*100/full)
592   batterywidget:bar_data_add("bat",batt )
593 end
594 -- awful.hooks.timer.register(5, get_bat)
595 --}}}