A script that shows your public IP address (if available) and your VPN status.
- Attempts to retrieve your public IP address and country of origin from the free but limited
ipinfo.io
service. - If that fails, it will retrieve it from
ifconfig.co
instead. A failure may happen when you've reached your monthly threshold of free API requests. - Finally, if that also fails, it will print your local IP address. Furthermore, assuming a tunnel is always created for a VPN connection, it will tell you whether you're currently connected to a VPN service or not:
If there is no Internet connection, it will show a broken link accordingly:
sudo apt install -y curl jq iproute2
To display the icons properly, you'll need Font Awesome which you must also refer to in your [bar/...]
module, e.g,:
font-0 = ...
font-1 = Font Awesome 5 Free:style=Solid:pixelsize=9; 2
font-2 = Font Awesome 5 Free:style=Regular:pixelsize=9; 2
font-3 = Font Awesome 5 Brands:pixelsize=9; 2
font-4 = Font Awesome 5 Free:style=Solid:pixelsize=7; 2
[module/network]
type = custom/script
exec = ~/.config/polybar/ipfinder.sh
tail = true
Replace exec
value with the path of this script. I usually store them in a ~/.config/scripts
directory, but I've seen a lot of people use ~/.config/polybar
instead. Remember to make it executable.
I encourage you to add a click-left
event if you're using a VPN service. For example, I use Mullvad VPN:
...
tail = true
click-left = '/opt/Mullvad VPN/mullvad-vpn' &