I have a conky object, and I want to pass it as parameter of a bash
/ lua
script. How do I do it?
Example:
conky object: ${tcp_portmon 1 61000 lport 0}
i.e the port of the first tcp
connection
script: $ lsof -i :<PORT> | sed -n 2p | awk '{print $1}'
i.e finds the process with that port
What I tried (unsuccessfully):
${exec lsof -i :${tcp_portmon 1 61000 lport 0} | sed -n 2p | awk '{print $1}'}
${exec echo $(lsof -i :${tcp_portmon 1 61000 lport 0} | sed -n 2p | awk '{print $1}')}
${lua conky_proc_port ${tcp_portmon 1 61000 lport 0}}
, whereconky_proc_port
simply outputs the parameter
How do I do it?
PS: for reference, here is the link to the Github issue
The best way to pass the conky object to a lua function is... by not passing the object.
Instead, use the lua API function
conky_parse
within the lua function to evaluate the string'${tcp_portmon 1 61000 lport 0}'
and then process the result as desired.Alternativly, rather than hardcoding the string, you could pass the string
'${tcp_portmon 1 61000 lport 0}'
to the lua function and then useconky_parse
on the passed string.See the "LUA API" section of
man conky
for more info.