IP on Polybar


#1

I added these modules to my .config/polybar/modules.conf file.

;;;Public IP;;;
[module/ip]
type = custom/script
exec = curl -s https://www.icanhazip.com
label-padding = 1
format = <label>

;;;Local IP;;
[module/ipl]
type = custom/script
exec = ifconfig wlpXx | grep 'inet ' | awk '{ print $2 }'
label-padding = 1
format = <label>

This command:

exec = ifconfig wlpXx | grep 'inet ' | awk '{ print $2 }'

(Edited)Simplified in:

exec = ifconfig wlpXx | awk '/inet /{print $2}'

#2

awk can search as well:

exec = ifconfig wlpXx | awk '/inet /{print $2}'

#3

Thanks @Head_on_a_Stick!