7

Is it possible to show IP address on top bar near the time? I use ubuntu 17.10 and Xorg.

Here the Image:

enter image description here

3

3 Answers 3

4

Screenshot

indicator sysmonitor screenshot.png

Discover your current DCHP IP address

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

Install Sysmonitor Indicator

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:

indicator sysmonitor custom.png

Highlight the Custom option and click the Edit button:

indicator sysmonitor custom edit.png

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.

Create the script

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
1
  • Change the script to this #!/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
1

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.

0

You may use a GNOME shell extension called Show IP which does

Show IP addresses (private or public) in gnome-shell bar

enter image description here

Source: A comment by OP which should have been posted as an answer instead.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .