How to config polybar to show local IP address

I would like to have my local ip address listed next to network connected icon on the polybar.

I was not able to get the wired-network module working in my original installation.

I’ve added the network.sh script to my polybar config (~/.config/polybar/network.sh) and it seems to be working fine after I edited the relevant section ([module/wired-network]) in modules.conf.

Before this the label-connected icon displayed but not the %local_ip% part.

I used ip link to look up my interface and changed that also.

Any tips on getting this to display would be appreciated.

Also. Great distribution.

That option is working for me, can you post your the wired-network section of your modules.conf? Might be some simple fix like a typo.

If you can’t get that working, adding a custom command to give your local ip would be an option.

Sure. I was thinking that could be the problem.

[module/wired-network]
type = internal/network
interface = enp2s0
format-connected = <label-connected>
format-disconnected = <label-disconnected>
label-connected =  %local_ip%
label-disconnected = no connection
format-connected-foreground = ${colors.purple}

Sorry, should have specified - the %local_ip% works on my Void Linux system. On ArchLabs, it doesn’t.

I started polybar from a terminal and got this error:

error: Disabling module “wired-network” (reason: No built-in support for ‘internal/network’)

So the Arch build of polybar doesn’t have internal/network support. Maybe the maintainer sees that as a security flaw.

I guess your options would be:

  1. Custom command for local ip
  2. Recompile polybar with internal network support.

The cusotm command for local ip should be easy enough to set up; like the network module but call a different script/command.

something like:

ip route get 1 | awk ‘{print $7}’

adjust the “print $7” for your system.

Thanks @PackRat. That answers my question.

To summarize:

Local ip did was not showing, but that was by design because internal/network module support not built into archlabs polybar.

I went with option 1. And created my own (meaning I edited script from @Dobbie03) custom/script for the modules.conf using your example of ip route.

1 Like