Displaying Local/Global IP using Shortcut Key for KDE.

Ethical hackers, I know how it feels whenever you create a payload and suddenly need to know your Local/Global IP from another terminal. This happens to me a lot.

Not only IP but any command output, you can show it as a popup using the shortcut. Here we are going to take the help of small tool zenity.

Zenity: Create Graphical (GTK+) Dialog Box in Command-line and Shell Scripts

Command

$ zenity --title IP --info --text="$(ifconfig [Your Network Name] | grep "inet " | cut -b 9- | cut -d" " -f2)"

Once you execute the above command, you will get a dialog box with your local IP, which we did with the help of zenity.

Displaying IP using Shortcut Key
Displaying IP using Shortcut Key

Let’s break down what we did above in the command step by step.

zenity –title IP –info –text=”Your Message”: Here, we took the help of the zenity info dialog box, and in place of Your Message, we executed another command to fetch our local IP.

ifconfig [Your Network Name]: Network name can be anything depending upon your internet connection. For Ethernet users, it can be eth0, and for wireless users, it can be wlan0.

grep “inet “: With the help grep command, we can easily extract specific lines which contain our inet or, in simple words, our IP address.

cut -b 9-: This command helps us remove nine whitespaces from the beginning of the inet.

cut -d” ” -f2: Finally, we are changing sentences into columns with the help of space (-d” “) and generally, IP is located at two fields, which we specified in (-f2).

Once you understand how it’s working, you can easily modify it to your own need. But let’s see how we can trigger this command with the help of a shortcut key.

Set Command to Shortcut Key

Open your system setting and go to shortcut.

System Settings
System Settings

Now go to Custom Shortcuts and click on Edit -> New -> Global Shortcuts -> Command/URL like shown below.

Custom Shortcut
Creating Custom Shortcut

Then it will create a new custom shortcut; name it what you want. In my case, it’s Show IP and then go to the trigger option to set a custom shortcut.

Set Custom Shortcut
Set Custom Shortcut

Now go to the Action tab, set the execution command we discussed at the beginning of this article, and click on apply.

Apply Command and Setting
Apply Command and Setting

Now use your shortcut key to popup your IP or another command you have set.

Final Thought

I hope you enjoyed this way of showing custom commands using a shortcut key. If you face difficulty or any issues, let us know in the comment section.

Leave a Reply