Xfce Forum

Sub domains
 

You are not logged in.

#1 2020-09-07 10:31:03

julian
Member
Registered: 2020-09-07
Posts: 28

(SOLVED) How to refresh Panel to show changes in Desktop Entry file

Hi all,

I'm hoping to develop a tiny (ultimately open-source) script that can be triggered by clicking a Launcher, but because it also changes the state of a privileged program, I don't just want to run those scripts, I also want to change the Name and Icon in the .desktop file, and therefore in the Launcher too. But when I change the .desktop the Launcher doesn't change. I tried

xfce4-panel -r

as specified in another forum post here. That caused the desktop isons and panel to visibly disappear and reappear but the Launcher did not refresh/update. Same name and icon.

An example of the intended changes

BEFORE CLICK the .desktop file in usr/share/applications/ contains (among other things):

Name=(OKAY) Switch your state
Icon=unobtrusive-papirus-icon

AFTER click

Name=(STATE A) Switch your state
Icon=AAA-papirus-icon

AFTER ANOTHER click

Name=(STATE B) Switch your state
Icon=BBB-papirus-icon

AFTER ANOTHER we go back to BEFORE CLICK state

I realize that I'm probably doing something odd here, and another method might be better, but if we are able to put that aside for a moment... What is the way to refresh keeping in mind the above needs.

If there is actually a much better and easier way to do this, then please point me in that direction. Thanks for reading.

Last edited by julian (2020-09-07 14:58:00)

Offline

#2 2020-09-07 11:59:53

ToZ
Moderator
From: Canada
Registered: 2011-06-02
Posts: 6,979

Re: (SOLVED) How to refresh Panel to show changes in Desktop Entry file

Hello and welcome.

Every launcher plugin creates a corresponding .desktop file in the ~/.config/xfce4/panel directory inside of "launcher-xx" directories where xx is the widget ID. If you change the icon, name or executable in this desktop file they will be automatically updated by the panel.

The challenge will be programmatically finding the correct directory/desktop file for the launcher.

Offline

#3 2020-09-07 14:49:53

julian
Member
Registered: 2020-09-07
Posts: 28

Re: (SOLVED) How to refresh Panel to show changes in Desktop Entry file

Thanks ToZ!!

Yes. That's the trick!

In terms of the challenge that you've outlined, I've taken a quick look at the corresponding .desktop file and found that Xfce rather neatly adds a relationship to the original .desktop file via an extra line, specifically:

X-XFCE-Source=file:///usr/share/applications/onion.domain.SwitchYourState.desktop

So I'll iterate through every file for that string, and when I find one, edit the file(s) that correspond. I like that I might not need to edit the original .desktop file at all smile It all sounds easy enough but bash is not my strong suit these days, lol. Thanks again and wish me luck.

Last edited by julian (2020-09-07 14:52:39)

Offline

Board footer

Powered by FluxBB