Display IP address on Panel in Xfce

Create a small shell script show_ip.sh :

#!/bin/bash

# Get all addresses from hostname -I
IP_ADDRESSES=$(hostname -I)

# Split into individual IP addresses
IFS=' ' read -r -a IP_ADDRS <<< "$IP_ADDRESSES"

# Find the first IPv4 address
for IP in "${IP_ADDRS[@]}"; do
  if [[ "$IP" =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
    echo "$IP"
    break
  fi
done
#!/bin/bash

ip -4 addr show scope global | grep -oP '(?<=inet\s)\d+(\.\d+){3}'

 

chmod +x show_ip.sh

Add a generic monitor:

image.png

That's it.


Revision #3
Created 18 October 2024 11:29:13 by Admin
Updated 21 February 2025 15:04:29 by Admin