summaryrefslogtreecommitdiff
path: root/awesome
diff options
context:
space:
mode:
Diffstat (limited to 'awesome')
-rw-r--r--awesome/rc.lua101
1 files changed, 52 insertions, 49 deletions
diff --git a/awesome/rc.lua b/awesome/rc.lua
index 192b1eb..f43a08c 100644
--- a/awesome/rc.lua
+++ b/awesome/rc.lua
@@ -127,53 +127,54 @@ for bat = 0, 1 do
local batpath = '/sys/class/power_supply/BAT' .. bat
local batexists = io.open(batpath)
if batexists~=nil then
- io.close(batexists)
- --batwidget = widget({ type = 'textbox', name = 'batwidget', align = 'right' })
- batwidget = wibox.widget.textbox()
- function batstate()
- local fcur = io.open(batpath .. '/charge_now')
- if not fcur then fcur = io.open(batpath .. '/energy_now') end
- local ffull = io.open(batpath .. '/charge_full')
- if not ffull then ffull = io.open(batpath .. '/energy_full') end
- local acstate = io.open('/sys/class/power_supply/AC0/online')
- if not acstate then acstate = io.open('/sys/class/power_supply/ACAD/online') end
- if not acstate then acstate = io.open('/sys/class/power_supply/AC/online') end
-
- local cur = fcur:read()
- local full = ffull:read()
- local ac = acstate:read()
- fcur:close()
- ffull:close()
- acstate:close()
-
- if ac:match("1") then
- acwidget.visible = true
- elseif ac:match("0") then
- acwidget.visible = false
- end
- local battery = math.floor(cur*100/full)
- return {battery}
- end
- vicious.register(batwidget, batstate, ' Bat:$1% ', 60)
+ io.close(batexists)
+ batwidget = wibox.widget.textbox()
+ function batstate()
+ local fcur = io.open(batpath .. '/charge_now')
+ if not fcur then fcur = io.open(batpath .. '/energy_now') end
+
+ local ffull = io.open(batpath .. '/charge_full')
+ if not ffull then ffull = io.open(batpath .. '/energy_full') end
+
+ local acstate = io.open('/sys/class/power_supply/AC0/online')
+ if not acstate then acstate = io.open('/sys/class/power_supply/ACAD/online') end
+ if not acstate then acstate = io.open('/sys/class/power_supply/AC/online') end
+
+ local cur = fcur:read()
+ local full = ffull:read()
+ local ac = acstate:read()
+ fcur:close()
+ ffull:close()
+ acstate:close()
+
+ if ac:match("1") then
+ acwidget.visible = true
+ elseif ac:match("0") then
+ acwidget.visible = false
+ end
+ local battery = math.floor(cur*100/full)
+ return {battery}
+ end
+ vicious.register(batwidget, batstate, ' Bat:$1% ', 60)
end
end
function cpu_string()
- local f = io.open("/proc/cpuinfo", "r")
- local n = 2
- local result = " CPU:$2%"
- if f then
- f:read() -- skip first line/processor
- for line in f:lines() do
- m = string.match(line, "processor\t*: %d+")
- if m then
- n = n + 1
- result = result .. "/$" .. n .. "%"
- end
- end
- f:close()
- end
- return result .. " "
+ local f = io.open("/proc/cpuinfo", "r")
+ local n = 2
+ local result = " CPU:$2%"
+ if f then
+ f:read() -- skip first line/processor
+ for line in f:lines() do
+ m = string.match(line, "processor\t*: %d+")
+ if m then
+ n = n + 1
+ result = result .. "/$" .. n .. "%"
+ end
+ end
+ f:close()
+ end
+ return result .. " "
end
--cpuwidget = widget({ type = 'textbox', name = 'cpuwidget', align = 'right' })
@@ -258,9 +259,9 @@ for s = 1, screen.count() do
-- Widgets that are aligned to the right
local right_layout = wibox.layout.fixed.horizontal()
- right_layout:add(cpuwidget)
- if batwidget then right_layout:add(batwidget) end
- --right_layout:add(acwidget)
+ right_layout:add(cpuwidget)
+ if batwidget then right_layout:add(batwidget) end
+ --right_layout:add(acwidget)
right_layout:add(mylayoutbox[s])
if s == 1 then right_layout:add(wibox.widget.systray()) end
right_layout:add(mytextclock)
@@ -349,9 +350,9 @@ globalkeys = awful.util.table.join(
-- Prompt
-- awful.key({ modkey }, "r", function () mypromptbox[mouse.screen]:run() end),
- awful.key({ modkey }, "r", function ()
- awful.util.spawn("dmenu_run -i -p 'Run command:' -nb '" .. beautiful.bg_normal .. "' -nf '" .. beautiful.fg_normal .. "' -sb '" .. beautiful.bg_focus .. "' -sf '" .. beautiful.fg_focus .. "'")
- end),
+ awful.key({ modkey }, "r", function ()
+ awful.util.spawn("dmenu_run -i -p 'Run command:' -nb '" .. beautiful.bg_normal .. "' -nf '" .. beautiful.fg_normal .. "' -sb '" .. beautiful.bg_focus .. "' -sf '" .. beautiful.fg_focus .. "'")
+ end),
awful.key({ modkey }, "x",
function ()
@@ -539,3 +540,5 @@ end)
client.connect_signal("focus", function(c) c.border_color = beautiful.border_focus end)
client.connect_signal("unfocus", function(c) c.border_color = beautiful.border_normal end)
-- }}}
+
+-- vim: set et:sw=4:sts=4