Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-01-26 22:35:55

xfceuser872
Member
Registered: 2020-01-26
Posts: 2

[SOLVED] IP-Address in XFCE-Panel using xfce4-genmon-plugin

Hi,

I try to show my external IP-Adress in the XFCE-panel, which works fine using the plugin xfce4-genmon and a very simple script (curl -s https://api.ipify.org). If I understand this correct the plugin can only execute a script every x seconds and one could use the command "xfce4-panel --plugin-event=genmon-X:refresh:bool:true" to refresh the plugin.


From https://docs.xfce.org/panel-plugins/xfce4-genmon-plugin:

"The xfce4-genmon-plugin now supports xfce4-panel plugin-event functionality. Currently it only supports the “refresh” action which resets the timer and causes the associated command to execute again. You can use this command remotely or at the end of a script to force the panel plugin to refresh."

I want to put a script in "/etc/networkmanger/dispatcher.d" which triggers the plugin to show the IP. This method is better in my opinion because at home I have the same IP for several months, so no need to hit a "whats my ip site" ervery x seconds. I want the plugin to recognize, when i use my VPN for example and show the VPN-IP.

The problem: Scripts in "/etc/networkmanger/dispatcher.d" have to be owned by root and executed by root as well. So I cant use the command "xfce4-panel --plugin-event=genmon-X:refresh:bool:true" to refresh the plugin if my VPN comes up or down. I tried "sudo -u user xfce4-panel --plugin-event=genmon-X:refresh:bool:true" but always getting a DBUS error.

How can I achieve this? Or is there another solution to combine network-events with the xfce4-genmon-plugin?

Last edited by xfceuser872 (2020-01-27 18:41:23)

Offline

#2 2020-01-27 02:10:14

ToZ
Administrator
From: Canada
Registered: 2011-06-02
Posts: 11,489

Re: [SOLVED] IP-Address in XFCE-Panel using xfce4-genmon-plugin

Hello and welcome.

Scripts in /etc/networkmanger/dispatcher.d are run by root and root does not have access to your dbus session and display.  Add the following to your script:

declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
declare -x DISPLAY=":0.0"

...where:
   - DBUS_SESSION_BUS_ADDRESS from "env | grep DBUS"
   - DISPLAY from "env | grep DISPLAY".

Example start to script:

#!/bin/bash

declare -x DBUS_SESSION_BUS_ADDRESS="unix:path=/run/user/1000/bus"
declare -x DISPLAY=":0.0"

...your script stuffs

Please remember to mark your thread [SOLVED] to make it easier for others to find
--- How To Ask For Help | FAQ | Developer Wiki  |  Community | Contribute ---

Offline

#3 2020-01-27 18:40:08

xfceuser872
Member
Registered: 2020-01-26
Posts: 2

Re: [SOLVED] IP-Address in XFCE-Panel using xfce4-genmon-plugin

Thanks a lot for your fast reply and your example script! Now my script works as expected smile

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.008 seconds, 8 queries executed - Memory usage: 525.04 KiB (Peak: 525.88 KiB) ]