2

I'd like to print on the LXDE Pannel (LXPanel) the IP address of my Raspberry Pi, so I can have a direct view about how to connect to the Pi from another computer when I reboot it, since its IP is defined dynamically and I have no keyboard nor mouse connected to the Pi

I'd like something like this :

enter image description here

I'm looking for a solution to print the output of a command, like in MATE, where a "command Applet" allows to print a command like :

ifconfig | grep inet | head -n 1 |  awk '{print $2}'

Some one has an idea to do the same for LXDE ?

  • you could query the router to see the IP that was given to the RPi – jsotola Jun 15 at 18:48
2

I have written a plugin which displays the hostname, which could be adapted. http://binnie.id.au/Downloads/hostname.tgz

You don't actually need to know the IP address hostname.local works in most circumstances.

See https://raspberrypi.stackexchange.com/a/92797/8697

hostname -I will return the IP address as a string.

If you replace the 2 lines in the source

fp = fopen("/etc/hostname", "r");
fgets(cIdBuf, LabelSize, fp);

with the following

fp = popen("hostname -I","r");  // Setup our pipe for reading and execute our command.
if(fp)  fgets(cIdBuf, LabelSize , fp);  // Get the data from the process execution

it will display IP.

I probably should make this a config option

  • Works perfectly fine, thanks! Indeed, a customizable command as a config option would be even better – Covich Jun 15 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.