Is it possible to show IP address on top bar near the time? I use ubuntu 17.10 and Xorg.
Here the Image:
Is it possible to show IP address on top bar near the time? I use ubuntu 17.10 and Xorg.
Here the Image:
This answer should work for most Ubuntu distributions. The first step is discovering your current IP address. According to this Linux & Unix answer it isn't stored on disk in the same location across distributions. For a portable solution you need to use:
default_interface=$(route -n | awk '$1 == "0.0.0.0" {print $8; exit}')
ip_address=$(ifconfig "$default_interface" | awk 'sub(/.* inet addr:/, "") {print $1}')
echo $ip_address
192.168.1.66
You now need an Application Indicator that to let's you pick and choose the information to display in the Systray / Application Notification Area. I use Sysmonitor Indicator. To summarize the installation instructions in the link:
sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor
sudo apt-get update
sudo apt-get install indicator-sysmonitor
You need to configure the name of the bash script that is called and the update interval in the Advanced
tab of the Preferences
panel:
Highlight the Custom
option and click the Edit
button:
Here's a complaint I have to the developer the input field for the command is abnormally small. You can't see the whole command you are typing all at once and need arrow keys to scroll through it. Anyway assign the bash script filename. I used:
~/bin/indicator-sysmonitor-display
I already have a main bash script so I created an abbreviated version for this answer.
Using the code from the first section create the file ~/bin/indicator-sysmonitor-display
containing:
#!/bin/bash
default_interface=$(route -n | awk '$1 == "0.0.0.0" {print $8; exit}')
systray=$(ifconfig "$default_interface" | awk 'sub(/.* inet addr:/, "") {print $1}')
echo "$systray" # sysmon-indidicator will put echo string into systray for us.
exit 0
#!/bin/bash default_interface=$(route -n | awk '$1 == "0.0.0.0" {print $8; exit}') systray=$(ifconfig "$default_interface" | awk 'sub(/.* inet /, "") {print $1}') echo "$systray" # sysmon-indidicator will put echo string into systray for us. exit 0
Jul 21, 2022 at 11:13
Provided that you want to see your Local IP address (not public IP), the Gnome Shell Extension LAN IP Address should meet your needs. Unlike the Show IP extension, this one is actively supported (as of 2022).
Full disclosure, I am the author of this extension.
You may use a GNOME shell extension called Show IP which does
Show IP addresses (private or public) in gnome-shell bar
Source: A comment by OP which should have been posted as an answer instead.