]>
git.madduck.net Git - etc/awesome.git/commitdiff
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:
summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
bc57461 )
14 files changed:
--]]
local debug = require("debug")
--]]
local debug = require("debug")
+
+local capi = { timer = timer }
local io = { open = io.open }
local io = { open = io.open }
-- Lain helper functions for internal use
-- lain.helpers
-- Lain helper functions for internal use
-- lain.helpers
helpers.timer_table = {}
function helpers.newtimer(name, timeout, fun, nostart)
helpers.timer_table = {}
function helpers.newtimer(name, timeout, fun, nostart)
- helpers.timer_table[name] = timer({ timeout = timeout })
+ helpers.timer_table[name] = capi. timer({ timeout = timeout })
helpers.timer_table[name]:connect_signal("timeout", fun)
helpers.timer_table[name]:start()
if not nostart then
helpers.timer_table[name]:connect_signal("timeout", fun)
helpers.timer_table[name]:start()
if not nostart then
alsa.widget = wibox.widget.textbox('')
function alsa.update()
alsa.widget = wibox.widget.textbox('')
function alsa.update()
- local f = io.popen('amixer get ' .. channel )
+ local f = assert(io.popen('amixer get ' .. channel) )
local mixer = f:read("*all")
f:close()
local mixer = f:read("*all")
f:close()
- volume.level, volume .status = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
+ volume_now.level, volume_now .status = string.match(mixer, "([%d]+)%%.*%[([%l]*)")
+ if volume_now .level == nil
- volume.level = 0
- volume.status = "off"
+ volume_now.level = "0"
+ volume_now .status = "off"
+ if volume_now .status == ""
+ if volume_now.level == "0"
+ volume_now .status = "off"
+ volume_now .status = "on"
bat.widget = wibox.widget.textbox('')
bat.widget = wibox.widget.textbox('')
- status = "n ot present",
+ status = "N ot present",
perc = "N/A",
time = "N/A",
watt = "N/A"
perc = "N/A",
time = "N/A",
watt = "N/A"
- newtimer("bat", timeout, bat. update)
+ newtimer("bat", timeout, update)
-- Calendar notification
-- lain.widgets.calendar
local calendar = {}
-- Calendar notification
-- lain.widgets.calendar
local calendar = {}
-local notification = nil
+local cal_ notification = nil
- if notification ~= nil then
- naughty.destroy(notification)
- notification = nil
+ if cal_ notification ~= nil then
+ naughty.destroy(cal_ notification)
+ cal_ notification = nil
.. "</span></tt>"
f:close()
.. "</span></tt>"
f:close()
- notification = naughty.notify({ text = c_text,
- icon = calendar.notify_icon,
- position = calendar.position,
- fg = calendar.fg,
- bg = calendar.bg,
- timeout = tims })
+ cal_ notification = naughty.notify({ text = c_text,
+ icon = calendar.notify_icon,
+ position = calendar.position,
+ fg = calendar.fg,
+ bg = calendar.bg,
+ timeout = tims })
end
function calendar:attach(widget, args)
end
function calendar:attach(widget, args)
cpu.widget = wibox.widget.textbox('')
cpu.widget = wibox.widget.textbox('')
-- Read the amount of time the CPUs have spent performing
-- different kinds of work. Read the first line of /proc/stat
-- which is the sum of all CPUs.
-- Read the amount of time the CPUs have spent performing
-- different kinds of work. Read the first line of /proc/stat
-- which is the sum of all CPUs.
cpu.last_total = total
end
cpu.last_total = total
end
- newtimer("cpu", timeout, cpu. update)
+ newtimer("cpu", timeout, update)
local fs = {}
local notification = nil
local fs = {}
local notification = nil
-notification_preset = { fg = beautiful.fg_normal }
+fs_ notification_preset = { fg = beautiful.fg_normal }
function fs:hide()
if notification ~= nil then
function fs:hide()
if notification ~= nil then
f:close()
notification = naughty.notify({
f:close()
notification = naughty.notify({
- preset = notification_preset,
+ preset = fs_ notification_preset,
text = ws,
timeout = t_out
})
text = ws,
timeout = t_out
})
helpers.set_map("fs", false)
helpers.set_map("fs", false)
fs_info = {}
local f = io.popen("LC_ALL=C df -kP")
fs_info = {}
local f = io.popen("LC_ALL=C df -kP")
- helpers.newtimer(partition, timeout, fs. update)
+ helpers.newtimer(partition, timeout, update)
widget:connect_signal('mouse::enter', function () fs:show(0) end)
widget:connect_signal('mouse::leave', function () fs:hide() end)
widget:connect_signal('mouse::enter', function () fs:show(0) end)
widget:connect_signal('mouse::leave', function () fs:hide() end)
- output = {
- widget = fs.widget,
- show = function(t_out)
- fs.update()
- fs:show(t_out)
- end
- }
-
- return setmetatable(output, { __index = output.widget })
+ return setmetatable(fs, { __index = fs.widget })
end
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
imap.widget = wibox.widget.textbox('')
imap.widget = wibox.widget.textbox('')
- function imap. update()
- notification_preset = {
+ function update()
+ mail_ notification_preset = {
icon = helpers.icons_dir .. "mail.png",
position = "top_left"
}
icon = helpers.icons_dir .. "mail.png",
position = "top_left"
}
else
nt = mail .. " has <b>" .. mailcount .. "</b> new messages"
end
else
nt = mail .. " has <b>" .. mailcount .. "</b> new messages"
end
- naughty.notify({ preset = notification_preset, text = nt })
+ naughty.notify({ preset = mail_ notification_preset, text = nt })
end
helpers.set_map(mail, mailcount)
end
end
helpers.set_map(mail, mailcount)
end
- helpers.newtimer(mail, timeout, imap. update, true)
+ helpers.newtimer(mail, timeout, update, true)
maildir.widget = wibox.widget.textbox('')
maildir.widget = wibox.widget.textbox('')
- function maildir. update()
-- Find pathes to mailboxes.
local p = io.popen("find " .. mailpath ..
" -mindepth 1 -maxdepth 1 -type d" ..
-- Find pathes to mailboxes.
local p = io.popen("find " .. mailpath ..
" -mindepth 1 -maxdepth 1 -type d" ..
- newtimer(mailpath, timeout, maildir.update, true)
-
+ newtimer(mailpath, timeout, update, true)
return maildir.widget
end
return maildir.widget
end
-
- Licensed under GNU General Public License v2
- * (c) 2013, Luke Bonham
- * (c) 2010-2012, Peter Hofmann
- * (c) 2010, Adrian C. <anrxc@sysphere.org>
- * (c) 2009, Lucas de Vries <lucas@glacicle.com>
-
+
+ Licensed under GNU General Public License v2
+ * (c) 2013, Luke Bonham
+ * (c) 2010-2012, Peter Hofmann
+
--]]
local newtimer = require("lain.helpers").newtimer
--]]
local newtimer = require("lain.helpers").newtimer
mem.widget = wibox.widget.textbox('')
mem.widget = wibox.widget.textbox('')
- function mem. update()
- mem = {}
+ function update()
+ mem_now = {}
for line in io.lines("/proc/meminfo")
do
for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+")
do
for line in io.lines("/proc/meminfo")
do
for k, v in string.gmatch(line, "([%a]+):[%s]+([%d]+).+")
do
- if k == "MemTotal" then mem.total = math.floor(v / 1024)
- elseif k == "MemFree" then mem.free = math.floor(v / 1024)
- elseif k == "Buffers" then mem.buf = math.floor(v / 1024)
- elseif k == "Cached" then mem.cache = math.floor(v / 1024)
- elseif k == "SwapTotal" then mem.swap = math.floor(v / 1024)
- elseif k == "SwapFree" then mem.swapf = math.floor(v / 1024)
+ if k == "MemTotal" then mem_now .total = math.floor(v / 1024)
+ elseif k == "MemFree" then mem_now .free = math.floor(v / 1024)
+ elseif k == "Buffers" then mem_now .buf = math.floor(v / 1024)
+ elseif k == "Cached" then mem_now .cache = math.floor(v / 1024)
+ elseif k == "SwapTotal" then mem_now .swap = math.floor(v / 1024)
+ elseif k == "SwapFree" then mem_now .swapf = math.floor(v / 1024)
- used = mem.total - (mem.free + mem.buf + mem .cache)
- swapused = mem.swap - mem .swapf
+ mem_now.used = mem_now.total - (mem_now.free + mem_now.buf + mem_now .cache)
+ mem_now.swapused = mem_now.swap - mem_now .swapf
widget = mem.widget
settings()
end
widget = mem.widget
settings()
end
- newtimer("mem", timeout, mem. update)
+ newtimer("mem", timeout, update)
mpd.widget = wibox.widget.textbox('')
mpd.widget = wibox.widget.textbox('')
- notification_preset = {
+ mpd_ notification_preset = {
title = "Now playing",
timeout = 6
}
title = "Now playing",
timeout = 6
}
- notification_preset.text = string.format("%s (%s) - %s\n%s", mpd_now.artist,
- mpd_now.album, mpd_now.date, mpd_now.title)
+ mpd_ notification_preset.text = string.format("%s (%s) - %s\n%s", mpd_now.artist,
+ mpd_now.album, mpd_now.date, mpd_now.title)
widget = mpd.widget
settings()
widget = mpd.widget
settings()
os.execute(string.format("%s %q %q", mpdcover, music_dir, mpd_now.file))
mpd.id = naughty.notify({
os.execute(string.format("%s %q %q", mpdcover, music_dir, mpd_now.file))
mpd.id = naughty.notify({
- preset = notification_preset,
+ preset = mpd_ notification_preset,
icon = "/tmp/mpdcover.png",
replaces_id = mpd.id
}).id
icon = "/tmp/mpdcover.png",
replaces_id = mpd.id
}).id
helpers.set_map(iface, true)
helpers.set_map(iface, true)
+ function update()
+ net_now = {}
+
if iface == "" then iface = net.get_device() end
if iface == "" then iface = net.get_device() end
- carrier = helpers.first_line('/sys/class/net/' .. iface ..
+ net_now. carrier = helpers.first_line('/sys/class/net/' .. iface ..
- state = helpers.first_line('/sys/class/net/' .. iface ..
+ net_now. state = helpers.first_line('/sys/class/net/' .. iface ..
'/operstate') or "down"
local now_t = helpers.first_line('/sys/class/net/' .. iface ..
'/statistics/tx_bytes') or 0
local now_r = helpers.first_line('/sys/class/net/' .. iface ..
'/statistics/rx_bytes') or 0
'/operstate') or "down"
local now_t = helpers.first_line('/sys/class/net/' .. iface ..
'/statistics/tx_bytes') or 0
local now_r = helpers.first_line('/sys/class/net/' .. iface ..
'/statistics/rx_bytes') or 0
- sent = tostring((now_t - net.last_t) / timeout / units)
- sent = string.gsub(string.format('%.1f', sent), ",", ".")
+ net_now. sent = tostring((now_t - net.last_t) / timeout / units)
+ net_now.sent = string.gsub(string.format('%.1f', net_now. sent), ",", ".")
- received = tostring((now_r - net.last_r) / timeout / units)
- received = string.gsub(string.format('%.1f', received), ",", ".")
+ net_now. received = tostring((now_r - net.last_r) / timeout / units)
+ net_now.received = string.gsub(string.format('%.1f', net_now. received), ",", ".")
widget = net.widget
settings()
widget = net.widget
settings()
net.last_t = now_t
net.last_r = now_r
net.last_t = now_t
net.last_r = now_r
+ if net_now. carrier ~= "1"
then
if helpers.get_map(iface)
then
then
if helpers.get_map(iface)
then
- helpers.newtimer(iface, timeout, net.update)
-
+ helpers.newtimer(iface, timeout, update)
sysload.widget = wibox.widget.textbox('')
sysload.widget = wibox.widget.textbox('')
- function sysload. update()
local f = io.open("/proc/loadavg")
local ret = f:read("*all")
f:close()
local f = io.open("/proc/loadavg")
local ret = f:read("*all")
f:close()
- a, b, c = string.match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
+ load_1, load_5, load_15 = string.match(ret, "([^%s]+) ([^%s]+) ([^%s]+)")
widget = sysload.widget
settings()
end
widget = sysload.widget
settings()
end
- newtimer("sysload", timeout, sysload.update)
-
+ newtimer("sysload", timeout, update)
return sysload.widget
end
return sysload.widget
end
temp.widget = wibox.widget.textbox('')
temp.widget = wibox.widget.textbox('')
local f = io.open("/sys/class/thermal/thermal_zone0/temp")
coretemp_now = tonumber(f:read("*all")) / 1000
f:close()
local f = io.open("/sys/class/thermal/thermal_zone0/temp")
coretemp_now = tonumber(f:read("*all")) / 1000
f:close()
- newtimer("coretemp", timeout, temp.update)
-
+ newtimer("coretemp", timeout, update)
local sky = nil
local settings = function() end
local sky = nil
local settings = function() end
-notification_preset = {}
+yawn_ notification_preset = {}
local function fetch_weather()
local url = api_url .. units_set .. city_id
local function fetch_weather()
local url = api_url .. units_set .. city_id
-- widgets won't display
if text == "" or text:match("City not found")
then
-- widgets won't display
if text == "" or text:match("City not found")
then
+ yawn.icon:set_image(icon_path .. "na.png")
if text == "" then
weather_data = "Service not available at the moment."
yawn.widget:set_text("N/A")
if text == "" then
weather_data = "Service not available at the moment."
yawn.widget:set_text("N/A")
yawn.hide()
notification = naughty.notify({
yawn.hide()
notification = naughty.notify({
- preset = notification_preset,
+ preset = yawn_ notification_preset,
text = weather_data,
icon = sky,
timeout = t_out
text = weather_data,
icon = sky,
timeout = t_out