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 ea7774c0b6
commit bc54f80dfd
9 changed files with 24 additions and 24 deletions

View File

@ -1,4 +1,4 @@
return
{ base = 'gluon-' .. util.trim(fs.readfile('/lib/gluon/gluon-version'))
, release = util.trim(fs.readfile('/lib/gluon/release'))
}
return {
base = 'gluon-' .. util.trim(fs.readfile('/lib/gluon/gluon-version')),
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')
if autoupdater then
return
{ branch = autoupdater['branch']
, enabled = uci:get_bool('autoupdater', 'settings', 'enabled')
}
return {
branch = autoupdater['branch'],
enabled = uci:get_bool('autoupdater', 'settings', 'enabled'),
}
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 }

View File

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

View File

@ -1,4 +1,4 @@
return
{ enabled = uci:get_bool('fastd', 'mesh_vpn', 'enabled')
, version = util.trim(util.exec("fastd -v | cut -d' ' -f2"))
}
return {
enabled = uci:get_bool('fastd', 'mesh_vpn', 'enabled'),
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
return
{ latitude = tonumber(uci:get_first('gluon-node-info', 'location', 'latitude'))
, longitude = tonumber(uci:get_first('gluon-node-info', 'location', 'longitude'))
}
return {
latitude = tonumber(uci:get_first('gluon-node-info', 'location', 'latitude')),
longitude = tonumber(uci:get_first('gluon-node-info', 'location', 'longitude')),
}
end