]>
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 (parent:
8c2e1df )
20 files changed:
abase.timer = helpers.newtimer(cmd, timeout, abase.update, nostart, stoppable)
abase.timer = helpers.newtimer(cmd, timeout, abase.update, nostart, stoppable)
- return setmetatable(abase, { __index = abase.widget })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
helpers.newtimer(string.format("alsa-%s-%s", alsa.cmd, alsa.channel), timeout, alsa.update)
helpers.newtimer(string.format("alsa-%s-%s", alsa.cmd, alsa.channel), timeout, alsa.update)
- return setmetatable(alsa, { __index = alsa.widget })
end
return setmetatable(alsa, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(alsa, { __call = function(_, ...) return worker(...) end })
local cmd = args.cmd or ""
local settings = args.settings or function() end
local cmd = args.cmd or ""
local settings = args.settings or function() end
- base.widget = wibox.widget.textbox()
-
function base.update()
output = helpers.read_pipe(cmd)
if output ~= base.prev then
function base.update()
output = helpers.read_pipe(cmd)
if output ~= base.prev then
base.timer = helpers.newtimer(cmd, timeout, base.update, nostart, stoppable)
base.timer = helpers.newtimer(cmd, timeout, base.update, nostart, stoppable)
- return setmetatable(base, { __index = base.widget })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
newtimer("batteries", timeout, bat.update)
newtimer("batteries", timeout, bat.update)
- return setmetatable(bat, { __index = bat.widget })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
-- Google Play Music Desktop infos
-- lain.widget.contrib.gpmdp
-- Google Play Music Desktop infos
-- lain.widget.contrib.gpmdp
+local gpmdp = helpers.make_widget_textbox()
local function worker(args)
local args = args or {}
local function worker(args)
local args = args or {}
os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json"
local settings = args.settings or function() end
os.getenv("HOME") .. "/.config/Google Play Music Desktop Player/json_store/playback.json"
local settings = args.settings or function() end
- gpmdp.widget = wibox.widget.textbox('')
-
gpmdp_notification_preset = {
title = "Now playing",
timeout = 6
gpmdp_notification_preset = {
title = "Now playing",
timeout = 6
gpmdp.timer = helpers.newtimer("gpmdp", timeout, gpmdp.update, true, true)
gpmdp.timer = helpers.newtimer("gpmdp", timeout, gpmdp.update, true, true)
- return setmetatable(gpmdp, { __index = gpmdp.widget })
end
return setmetatable(gpmdp, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(gpmdp, { __call = function(_, ...) return worker(...) end })
helpers.newtimer("kbdlayout", timeout, kbdlayout.update)
helpers.newtimer("kbdlayout", timeout, kbdlayout.update)
- return setmetatable(kbdlayout, { __index = kbdlayout.widget })
end
return setmetatable({}, { __call = function (_, ...) return worker(...) end })
end
return setmetatable({}, { __call = function (_, ...) return worker(...) end })
moc.timer = helpers.newtimer("moc", timeout, moc.update, true, true)
moc.timer = helpers.newtimer("moc", timeout, moc.update, true, true)
- return setmetatable(moc, { __index = moc.widget })
end
return setmetatable(moc, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(moc, { __call = function(_, ...) return worker(...) end })
local first_line = require("lain.helpers").first_line
local naughty = require("naughty")
local wibox = require("wibox")
local first_line = require("lain.helpers").first_line
local naughty = require("naughty")
local wibox = require("wibox")
local string = { format = string.format }
local math = { floor = math.floor }
local tostring = tostring
local setmetatable = setmetatable
local string = { format = string.format }
local math = { floor = math.floor }
local tostring = tostring
local setmetatable = setmetatable
package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .. "?.lua;" .. package.path
local smapi = require("smapi")
-- ThinkPad SMAPI-enabled battery info widget
-- lain.widgets.contrib.tpbat
local tpbat = { }
package.path = debug.getinfo(1,"S").source:match[[^@?(.*[\/])[^\/]-$]] .. "?.lua;" .. package.path
local smapi = require("smapi")
-- ThinkPad SMAPI-enabled battery info widget
-- lain.widgets.contrib.tpbat
local tpbat = { }
-local tpbat_notification = nil
function tpbat.hide()
if not tpbat.notification then return end
function tpbat.hide()
if not tpbat.notification then return end
local str = string.format("%s : %s %s (%s)\n", bat.name, mfgr, model, chem)
.. string.format("\n%s \t\t\t %s", status:upper(), msg)
local str = string.format("%s : %s %s (%s)\n", bat.name, mfgr, model, chem)
.. string.format("\n%s \t\t\t %s", status:upper(), msg)
- tpbat_ notification = naughty.notify({
+ tpbat. notification = naughty.notify({
preset = naughty.config.defaults,
text = str,
timeout = t_out,
preset = naughty.config.defaults,
text = str,
timeout = t_out,
tpbat.bat = smapi:battery(battery) -- Create a new battery
local bat = tpbat.bat
tpbat.bat = smapi:battery(battery) -- Create a new battery
local bat = tpbat.bat
- tpbat.widget = wibox.widget.textbox('' )
+ tpbat.widget = wibox.widget.textbox()
bat_notification_low_preset = {
title = "Battery low",
bat_notification_low_preset = {
title = "Battery low",
-local lines_match = require("lain.helpers").lines_match
-local newtimer = require("lain.helpers").newtimer
+local helpers = require("lain.helpers")
local wibox = require("wibox")
local math = { ceil = math.ceil }
local string = { format = string.format,
local wibox = require("wibox")
local math = { ceil = math.ceil }
local string = { format = string.format,
-- CPU usage
-- lain.widgets.cpu
-- CPU usage
-- lain.widgets.cpu
-local cpu = { core = {} }
+local cpu = helpers.make_widget_textbox()
local function worker(args)
local args = args or {}
local timeout = args.timeout or 2
local settings = args.settings or function() end
local function worker(args)
local args = args or {}
local timeout = args.timeout or 2
local settings = args.settings or function() end
- cpu.widget = wibox.widget.textbox()
function update()
-- 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.
function update()
-- 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.
- local times = lines_match("cpu","/proc/stat")
+ local times = helpers. lines_match("cpu","/proc/stat")
for index,time in pairs(times) do
local coreid = index - 1
for index,time in pairs(times) do
local coreid = index - 1
- newtimer("cpu", timeout, update)
+ helpers. newtimer("cpu", timeout, update)
- return setmetatable(cpu, { __index = cpu.widget })
end
return setmetatable(cpu, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(cpu, { __call = function(_, ...) return worker(...) end })
helpers.newtimer(partition, timeout, fs.update)
helpers.newtimer(partition, timeout, fs.update)
- return setmetatable(fs, { __index = fs.widget })
end
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(fs, { __call = function(_, ...) return worker(...) end })
-- Mail IMAP check
-- lain.widgets.imap
-- Mail IMAP check
-- lain.widgets.imap
-local function worker(args )
+local function worker(args)
local imap = helpers.make_widget_textbox()
local args = args or {}
local server = args.server
local imap = helpers.make_widget_textbox()
local args = args or {}
local server = args.server
imap.timer = helpers.newtimer(mail, timeout, update, true, true)
imap.timer = helpers.newtimer(mail, timeout, update, true, true)
- return setmetatable(imap, { __index = imap.widget })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
-- Maildir check (synchronous)
-- lain.widgets.maildir
-- Maildir check (synchronous)
-- lain.widgets.maildir
+local maildir = helpers.make_widget_textbox()
local function worker(args)
local args = args or {}
local function worker(args)
local args = args or {}
local mailpath = args.mailpath or os.getenv("HOME") .. "/Mail"
local ignore_boxes = args.ignore_boxes or {}
local settings = args.settings or function() end
local mailpath = args.mailpath or os.getenv("HOME") .. "/Mail"
local ignore_boxes = args.ignore_boxes or {}
local settings = args.settings or function() end
- local ext_mail_cmd = args.external_mail_cmd
-
- maildir.widget = wibox.widget.textbox()
function maildir.update()
function maildir.update()
- if ext_mail_cmd then awful.spawn(ext_mail_cm d) end
+ if cmd then helpers.async({ awful.util.shell, "-c", cmd }, function() en d) end
-- Find pathes to mailboxes.
local p = io.popen(string.format("find %s -mindepth 1 -maxdepth 2 -type d -not -name .git", mailpath))
-- Find pathes to mailboxes.
local p = io.popen(string.format("find %s -mindepth 1 -maxdepth 2 -type d -not -name .git", mailpath))
maildir.timer = helpers.newtimer(mailpath, timeout, maildir.update, true, true)
maildir.timer = helpers.newtimer(mailpath, timeout, maildir.update, true, true)
- return setmetatable(maildir, { __index = maildir.widget })
end
return setmetatable(maildir, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(maildir, { __call = function(_, ...) return worker(...) end })
-local newtimer = require("lain.helpers").newtimer
+local helpers = require("lain.helpers")
local wibox = require("wibox")
local gmatch = string.gmatch
local lines = io.lines
local wibox = require("wibox")
local gmatch = string.gmatch
local lines = io.lines
-- Memory usage (ignoring caches)
-- lain.widgets.mem
-- Memory usage (ignoring caches)
-- lain.widgets.mem
+local mem = helpers.make_widget_textbox()
local function worker(args)
local args = args or {}
local timeout = args.timeout or 2
local settings = args.settings or function() end
local function worker(args)
local args = args or {}
local timeout = args.timeout or 2
local settings = args.settings or function() end
- mem.widget = wibox.widget.textbox()
-
function update()
mem_now = {}
for line in lines("/proc/meminfo") do
function update()
mem_now = {}
for line in lines("/proc/meminfo") do
- newtimer("mem", timeout, update)
+ helpers. newtimer("mem", timeout, update)
- return setmetatable(mem, { __index = mem.widget })
end
return setmetatable(mem, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(mem, { __call = function(_, ...) return worker(...) end })
mpd.timer = helpers.newtimer("mpd", timeout, mpd.update, true, true)
mpd.timer = helpers.newtimer("mpd", timeout, mpd.update, true, true)
- return setmetatable(mpd, { __index = mpd.widget })
end
return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(mpd, { __call = function(_, ...) return worker(...) end })
helpers.newtimer("network", timeout, update)
helpers.newtimer("network", timeout, update)
- return setmetatable(net, { __index = net.widget })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
-- PulseAudio volume
-- lain.widgets.pulseaudio
-- PulseAudio volume
-- lain.widgets.pulseaudio
+local pulseaudio = helpers.make_widget_textbox()
local function worker(args)
local args = args or {}
local function worker(args)
local args = args or {}
local scallback = args.scallback
pulseaudio.cmd = args.cmd or "pacmd list-sinks | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
local scallback = args.scallback
pulseaudio.cmd = args.cmd or "pacmd list-sinks | sed -n -e '0,/*/d' -e '/base volume/d' -e '/volume:/p' -e '/muted:/p' -e '/device\\.string/p'"
- pulseaudio.widget = wibox.widget.textbox()
function pulseaudio.update()
if scallback then pulseaudio.cmd = scallback() end
function pulseaudio.update()
if scallback then pulseaudio.cmd = scallback() end
helpers.newtimer("pulseaudio", timeout, pulseaudio.update)
helpers.newtimer("pulseaudio", timeout, pulseaudio.update)
- return setmetatable(pulseaudio, { __index = pulseaudio.widget })
end
return setmetatable(pulseaudio, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(pulseaudio, { __call = function(_, ...) return worker(...) end })
-local newtimer = require("lain.helpers").newtimer
+local helpers = require("lain.helpers")
local wibox = require("wibox")
local io = { open = io.open }
local string = { match = string.match }
local wibox = require("wibox")
local io = { open = io.open }
local string = { match = string.match }
-- System load
-- lain.widgets.sysload
-- System load
-- lain.widgets.sysload
+local sysload = helpers.make_widget_textbox()
local function worker(args)
local function worker(args)
- local args = args or {}
- local timeout = args.timeout or 2
+ local args = args or {}
+ local timeout = args.timeout or 2
local settings = args.settings or function() end
local settings = args.settings or function() end
- sysload.widget = wibox.widget.textbox()
-
function update()
local f = io.open("/proc/loadavg")
local ret = f:read("*all")
function update()
local f = io.open("/proc/loadavg")
local ret = f:read("*all")
- newtimer("sysload", timeout, update)
+ helpers. newtimer("sysload", timeout, update)
- return setmetatable(sysload, { __index = sysload.widget })
end
return setmetatable(sysload, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(sysload, { __call = function(_, ...) return worker(...) end })
-local newtimer = require("lain.helpers").newtimer
+local helpers = require("lain.helpers")
local wibox = require("wibox")
local io = { open = io.open }
local tonumber = tonumber
local wibox = require("wibox")
local io = { open = io.open }
local tonumber = tonumber
-- coretemp
-- lain.widgets.temp
-- coretemp
-- lain.widgets.temp
+local temp = helpers.make_widget_textbox()
local function worker(args)
local args = args or {}
local function worker(args)
local args = args or {}
local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
local settings = args.settings or function() end
local tempfile = args.tempfile or "/sys/class/thermal/thermal_zone0/temp"
local settings = args.settings or function() end
- temp.widget = wibox.widget.textbox()
-
function update()
local f = io.open(tempfile)
if f then
function update()
local f = io.open(tempfile)
if f then
- newtimer("coretemp", timeout, update)
+ helpers. newtimer("coretemp", timeout, update)
- return setmetatable(temp, { __index = temp.widget })
end
return setmetatable(temp, { __call = function(_, ...) return worker(...) end })
end
return setmetatable(temp, { __call = function(_, ...) return worker(...) end })
-local async = require("lain.helpers").async
-local newtimer = require("lain.helpers").newtimer
-local lain_icons = require("lain.helpers").icons_dir
+local helpers = require("lain.helpers")
local json = require("lain.util").dkjson
local focused = require("awful.screen").focused
local naughty = require("naughty")
local json = require("lain.util").dkjson
local focused = require("awful.screen").focused
local naughty = require("naughty")
-- lain.widgets.weather
local function worker(args)
-- lain.widgets.weather
local function worker(args)
+ local weather = helpers.make_widget_textbox()
local args = args or {}
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
local timeout = args.timeout or 900 -- 15 min
local args = args or {}
local APPID = args.APPID or "3e321f9414eaedbfab34983bda77a66e" -- lain default
local timeout = args.timeout or 900 -- 15 min
local lang = args.lang or "en"
local cnt = args.cnt or 5
local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'"
local lang = args.lang or "en"
local cnt = args.cnt or 5
local date_cmd = args.date_cmd or "date -u -d @%d +'%%a %%d'"
- local icons_path = args.icons_path or lain_icons .. "openweathermap/"
+ local icons_path = args.icons_path or helpers.icons_dir .. "openweathermap/"
local notification_preset = args.notification_preset or {}
local notification_text_fun = args.notification_text_fun or
function (wn)
local notification_preset = args.notification_preset or {}
local notification_text_fun = args.notification_text_fun or
function (wn)
local followtag = args.followtag or false
local settings = args.settings or function() end
local followtag = args.followtag or false
local settings = args.settings or function() end
- weather.widget = wibox.widget.textbox (weather_na_markup)
+ weather.widget:set_markup (weather_na_markup)
weather.icon_path = icons_path .. "na.png"
weather.icon_path = icons_path .. "na.png"
- weather.icon = wibox.widget.imagebox(weather.icon_path)
+ weather.icon = wibox.widget.imagebox(weather.icon_path)
function weather.show(t_out)
weather.hide()
function weather.show(t_out)
weather.hide()
function weather.forecast_update()
local cmd = string.format(forecast_call, city_id, units, lang, cnt, APPID)
function weather.forecast_update()
local cmd = string.format(forecast_call, city_id, units, lang, cnt, APPID)
+ helpers. async(cmd, function(f)
local pos, err
weather_now, pos, err = json.decode(f, 1, nil)
local pos, err
weather_now, pos, err = json.decode(f, 1, nil)
function weather.update()
local cmd = string.format(current_call, city_id, units, lang, APPID)
function weather.update()
local cmd = string.format(current_call, city_id, units, lang, APPID)
+ helpers. async(cmd, function(f)
local pos, err, icon
weather_now, pos, err = json.decode(f, 1, nil)
local pos, err, icon
weather_now, pos, err = json.decode(f, 1, nil)
weather.attach(weather.widget)
weather.attach(weather.widget)
- weather.timer = newtimer("weather-" .. city_id, timeout, weather.update, false, true)
- weather.timer_forecast = newtimer("weather_forecast-" .. city_id, timeout, weather.forecast_update, false, true)
+ weather.timer = helpers. newtimer("weather-" .. city_id, timeout, weather.update, false, true)
+ weather.timer_forecast = helpers. newtimer("weather_forecast-" .. city_id, timeout, weather.forecast_update, false, true)
- return setmetatable(weather, { __index = weather.widget })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
end
return setmetatable({}, { __call = function(_, ...) return worker(...) end })
-Subproject commit 7e4865822c669a86007d88bf6ae846a95c5eed5f
+Subproject commit 6d6fb0eb073e204c154e4d94b60472d858fc870d