Software & AppsOperating SystemLinux

How To Display Your IP Address on Your Desktop Using Conky

Ubuntu 13

In this article, we will guide you through the process of displaying your IP address on your desktop using Conky, a lightweight system monitor for X that is excellent for displaying system information directly on your desktop.

Quick Answer

To display your IP address on your desktop using Conky, you can either use the curl command to fetch your public IP address from an API or create a script using the wget command to retrieve the IP address. Both methods require editing the ~/.conkyrc file and restarting Conky to see the IP address displayed on your desktop.

Prerequisites

Before we start, you need to have Conky installed on your system. If you haven’t installed it yet, you can do so by running the following command in your terminal:

sudo apt-get install conky-all

This command uses sudo for root privileges, apt-get as the package installer, and install to indicate that we want to install a package. conky-all is the package we want to install.

Displaying Your IP Address with Conky

Once Conky is installed, you can configure it to display the IP address by editing the ~/.conkyrc file. This is a hidden file in your home directory that Conky reads every time it starts up. The changes you make in this file will determine what Conky displays on your desktop.

Using the curl command

The curl command is a tool to transfer data from or to a server, using one of the supported protocols. In this case, we will use it to get our public IP address from www.icanhazip.com, a simple IP address API.

Open the ~/.conkyrc file in a text editor with the command:

nano ~/.conkyrc

Add the following line to the file:

Public IP: ${exec curl -s www.icanhazip.com}

The ${exec} command in Conky is used to execute shell commands. curl -s www.icanhazip.com fetches your public IP address. The -s option is used to silence curl’s progress output.

Save the file and exit the text editor. Restart Conky to see the IP address displayed on your desktop.

Using a script

Another way to display your IP address is by using a script. Here’s how to do it:

First, create a new file in your home directory and name it ip.sh:

touch ~/ip.sh

Open the ip.sh file in a text editor:

nano ~/ip.sh

Add the following line to the file:

wget http://ipinfo.io/ip -qO -

The wget command is a free utility for non-interactive download of files from the web. The -q option turns off wget’s output, -O - writes the documents to standard output.

Save the file and exit the text editor. Make the script executable with the following command:

chmod +x ~/ip.sh

Open the ~/.conkyrc file in a text editor:

nano ~/.conkyrc

Add the following line to the file:

Public IP: ${exec sh ~/ip.sh}

Save the file and exit the text editor. Restart Conky to see the IP address displayed on your desktop.

Customizing Conky

Remember to customize the Conky configuration file according to your preferences, such as font size, color, and position on the desktop. You can find more information about customizing Conky in the Conky GitHub repository.

Conclusion

Displaying your IP address on your desktop using Conky can be a handy way to keep track of your network status. Whether you prefer to use the curl command or a script, the process is straightforward and customizable. Happy monitoring!

How do I install Conky on my system?

To install Conky on your system, you can use the sudo apt-get install conky-all command in your terminal. This command will install Conky and all its dependencies.

What is the `~/.conkyrc` file?

The ~/.conkyrc file is a hidden file in your home directory that Conky reads every time it starts up. It contains the configuration settings for Conky, and any changes you make in this file will determine what Conky displays on your desktop.

How can I display my IP address using Conky?

There are two methods you can use to display your IP address with Conky. The first method is by using the curl command to fetch your public IP address from www.icanhazip.com. The second method is by creating a script that uses the wget command to retrieve your IP address from http://ipinfo.io/ip.

How do I customize the Conky configuration file?

To customize the Conky configuration file, you can open the ~/.conkyrc file in a text editor and modify the settings according to your preferences. You can change the font size, color, and position of Conky on your desktop. For more information on customizing Conky, you can refer to the Conky GitHub repository.

Leave a Comment

Your email address will not be published. Required fields are marked *