gluon-alfred: reduce usage of util.exec, improve table formatting

This commit is contained in:
Matthias Schiffer 2014-06-10 15:44:35 +02:00
parent 3608f0a0a2
commit 0db81c1293
9 changed files with 24 additions and 24 deletions

View File

@ -1,4 +1,4 @@
return return {
{ base = 'gluon-' .. util.trim(fs.readfile('/lib/gluon/gluon-version')) base = 'gluon-' .. util.trim(fs.readfile('/lib/gluon/gluon-version')),
, release = util.trim(fs.readfile('/lib/gluon/release')) release = util.trim(fs.readfile('/lib/gluon/release')),
} }

View File

@ -1 +1 @@
return tonumber(util.trim(util.exec("cut -d' ' -f2 /proc/uptime"))) return tonumber(fs.readfile('/proc/uptime'):match('^[^ ]+ ([^ ]+)'))

View File

@ -1 +1 @@
return tonumber(util.trim(util.exec("cut -d' ' -f1 /proc/loadavg"))) return tonumber(fs.readfile('/proc/loadavg'):match('^([^ ]+) '))

View File

@ -1 +1 @@
return tonumber(util.trim(util.exec("cut -d' ' -f1 /proc/uptime"))) return tonumber(fs.readfile('/proc/uptime'):match('^([^ ]+) '))

View File

@ -1,7 +1,7 @@
local autoupdater = uci:get_all('autoupdater', 'settings') local autoupdater = uci:get_all('autoupdater', 'settings')
if autoupdater then if autoupdater then
return return {
{ branch = autoupdater['branch'] branch = autoupdater['branch'],
, enabled = uci:get_bool('autoupdater', 'settings', 'enabled') enabled = uci:get_bool('autoupdater', 'settings', 'enabled'),
} }
end end

View File

@ -1,3 +1,3 @@
local version = util.exec('batctl -v'):match('%[batman%-adv: ([^%]]+)%]') local version = util.trim(fs.readfile('/sys/module/batman_adv/version'))
return { version = version } return { version = version }

View File

@ -7,10 +7,10 @@ end
local traffic = {} local traffic = {}
for _, class in ipairs({'rx', 'tx', 'forward', 'mgmt_rx', 'mgmt_tx'}) do for _, class in ipairs({'rx', 'tx', 'forward', 'mgmt_rx', 'mgmt_tx'}) do
traffic[class] = traffic[class] = {
{ bytes = fields[class .. '_bytes'] bytes = fields[class .. '_bytes'],
, packets = fields[class] packets = fields[class],
} }
end end
traffic['tx']['dropped'] = fields['tx_dropped'] traffic['tx']['dropped'] = fields['tx_dropped']

View File

@ -1,4 +1,4 @@
return return {
{ enabled = uci:get_bool('fastd', 'mesh_vpn', 'enabled') enabled = uci:get_bool('fastd', 'mesh_vpn', 'enabled'),
, version = util.trim(util.exec("fastd -v | cut -d' ' -f2")) version = util.exec('fastd -v'):match('^[^%s]+%s+([^\n]+)'),
} }

View File

@ -1,6 +1,6 @@
if uci:get_first('gluon-node-info', 'location', 'share_location', false) then if uci:get_first('gluon-node-info', 'location', 'share_location', false) then
return return {
{ latitude = tonumber(uci:get_first('gluon-node-info', 'location', 'latitude')) latitude = tonumber(uci:get_first('gluon-node-info', 'location', 'latitude')),
, longitude = tonumber(uci:get_first('gluon-node-info', 'location', 'longitude')) longitude = tonumber(uci:get_first('gluon-node-info', 'location', 'longitude')),
} }
end end