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 ?

Covich
  • 123
  • 4

1 Answers1

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

Milliways
  • 59,890
  • 31
  • 101
  • 209
  • Works perfectly fine, thanks! Indeed, a customizable command as a config option would be even better – Covich Jun 15 '19 at 07:48