gluon-alfred: reduce usage of util.exec, improve table formatting
This commit is contained in:
		
							parent
							
								
									ea7774c0b6
								
							
						
					
					
						commit
						bc54f80dfd
					
				| @ -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')), | ||||||
| 	} | } | ||||||
|  | |||||||
| @ -1 +1 @@ | |||||||
| return tonumber(util.trim(util.exec("cut -d' ' -f2 /proc/uptime"))) | return tonumber(fs.readfile('/proc/uptime'):match('^[^ ]+ ([^ ]+)')) | ||||||
|  | |||||||
| @ -1 +1 @@ | |||||||
| return tonumber(util.trim(util.exec("cut -d' ' -f1 /proc/loadavg"))) | return tonumber(fs.readfile('/proc/loadavg'):match('^([^ ]+) ')) | ||||||
|  | |||||||
| @ -1 +1 @@ | |||||||
| return tonumber(util.trim(util.exec("cut -d' ' -f1 /proc/uptime"))) | return tonumber(fs.readfile('/proc/uptime'):match('^([^ ]+) ')) | ||||||
|  | |||||||
| @ -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 | ||||||
|  | |||||||
| @ -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 } | ||||||
|  | |||||||
| @ -7,9 +7,9 @@ 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'] | ||||||
|  | |||||||
| @ -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]+)'), | ||||||
| 	} | } | ||||||
|  | |||||||
| @ -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 | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user