I have a shell script that replaces a favicon used as an image for a xfce4-panel launcher. I'm looking for a solution to refresh the launcher's icon without restarting xfce4-panel.
Restarting xfce4-panel as root could cause various issues, such as errors when trying to restart the server through the CentOS UI, as the session is launched by another user. I attempted to restart xfce4-panel using commands like "sudo -u USER xfce4-panel --replace," but the issue still persists.
After differents days of searching, i have discovered a solution to force xfce4-panel to refresh icons without restarting it. The solution involves editing the configuration file of the xfce4-panel launcher. By modifying the file, xfce4-panel recognizes that changes have been made and refreshes the launcher, including the associated icon.
So the code that i have integrated in my script is the following :
Upon reading this solution, it's natural to find yourself asking some questions :
The reason is that the folders of the launchers are named "launcher-N" where "N" represents the number of the launcher, possibly indicating the order of creation for each launcher. To ensure accuracy, i chose to iterate over each configuration file that contains the name of the launcher i wanted to update, in order to locate the corresponding configuration file.
In my particular case, the file "favicon.ico" is replaced just before in the first script. Therefore, the workaround i employed was simply to edit the file and trigger the refreshing of the launcher's image by xfce4-panel. In your case, you can utilize the path or name of the new image.
Other informations :
Before this solution, i attempted to use
touch configuration_filecommand to update the file's date and force a refresh, but it did not work.