Xfce Forum

Sub domains
 

You are not logged in.

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

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

(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)


PGP: 4198 58E4 F9E8 AC05 FDEA A303 F083 6D52 5A2D 8356

Find my email where you get good encryption keys.

Offline

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

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

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.


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-09-07 14:49:53

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

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)


PGP: 4198 58E4 F9E8 AC05 FDEA A303 F083 6D52 5A2D 8356

Find my email where you get good encryption keys.

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, 7 queries executed - Memory usage: 541.94 KiB (Peak: 550.64 KiB) ]