Xfce Forum

Sub domains
 

You are not logged in.

#1 2019-02-20 09:09:34

xfce42
Member
Registered: 2019-02-20
Posts: 1

[SOLVED] [UPDATE] change panel icon with bash script

Hello everyone smile

I already searched a while but cant find an answer online yet.

Is it possible to change a panel icon with a bash script?
I am running Linux mint 19.1 with Xfce 4.12.3


Example:

In my panel i put a custom icon that runs a bash script to switch on and off the touchpad of my notebook.
Everything works fine so far. But now i also like to change the icon of the custom script so it can show the status of the touchpad also.

if switch on touchpad succeed then show normal touchpad icon in the panel
if switch off  touchpad succeed then show shaded or gray touchpad icon  in the panel

so just changing the custom icon in the panel  (and maybe reload the panel?) by the script would do the trick.

Is it possible?

Thanks for any help

xfce42 smile


P.S.
i just found something here that maybe give me a pointer in the right direction
https://forum.xfce.org/viewtopic.php?id=8619


[SOLVED]

i changed the config file in ~/.config/xfce4/panel/launcher-xx/0815424242.desktop
with sed to the new filename of the icon
no panel restart necessary!

Thanks! smile

Sources:

sed -i 's/original/new/g' file.txt

Explanation:

    sed = Stream EDitor
    -i = in-place (i.e. save back to the original file)

    The command string:
        s = the substitute command
        original = a regular expression describing the word to replace (or just the word itself)
        new = the text to replace it with
        g = global (i.e. replace all and not just the first occurrence)

    file.txt = the file name

https://askubuntu.com/questions/20414/f … g-commands

[UPDATE]

Better than hardcode the filename of the panel entry is to find it automatic smile

For example:

Your icon picture has the (unique!) name touchpad.png and you want to find it in the config directories for ALL the panels you have!
So you can search it with grep and put the filename in a variable for further processing

result=$(grep -l -r "touchpad.png" ~/.config/xfce4/panel/)

$result holds the filename now

Explanation of the grep options:

-l, --files-with-matches
    Suppress normal output; instead print the name of each input file from which output would normally have been printed.
   The scanning will stop on the first match. (-l is specified by POSIX .)

-R, -r, --recursive
    Read all files under each directory, recursively; this is equivalent to the -d recurse option.

Exchange it with sed now like this

  sed -i 's/touchpad.png/notouch.png/g' $result

Last edited by xfce42 (2019-02-25 09:21:51)

Offline

#2 2019-02-20 10:50:34

alcornoqui
Member
Registered: 2014-07-28
Posts: 832

Re: [SOLVED] [UPDATE] change panel icon with bash script

Thanks for the detailed explanation, welcome to the forum!

Offline

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

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.012 seconds, 7 queries executed - Memory usage: 522.87 KiB (Peak: 531.42 KiB) ]