Reputation: 121
I have a conky object, and I want to pass it as parameter of a bash
/ lua
script. How do I do it?
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
${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}}
, where conky_proc_port
simply outputs the parameterHow do I do it?
PS: for reference, here is the link to the Github issue
Upvotes: 0
Views: 399
Reputation: 620
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 use conky_parse
on the passed string.
See the "LUA API" section of man conky
for more info.
Upvotes: 1