This thing is based on the YAD package. You must install this one first. I worked hard to make things as simple as possible. I tested and re-tested it all on both LM MATE (18.3) and Cinnamon (20.1). There are 2 scripts:
- yad-notification0: This is the launcher. You can replace
--command="./yad-toggle"
with any command you want, like your--command="./cytoggle"
for instance. - yad-toggle: This just for a quick demonstration. You can replace this script with your cytoggle. In your script, where you want the tray icon to be changed, put this:
echo "icon:/PATH/TO/ICON.SVG" > $HOME/.var/yad-pipe
/path/to/icon
, not just the icon name.For a quick test, you can copy all these into some simple text editor, save them with their filenames displayed here, put them all in the same directory, and make sure both scripts are executable (File Properties > Permissions > Allow executing...). But i will probably make it easier to download this whole package some time later this week-end...
yad-notification0 (launcher with status icon)
Code: Select all
#!/bin/bash
mkdir -p $HOME/.var; rm -f $HOME/.var/yad-toggle
PIPE=$HOME/.var/yad-pipe; rm -f $PIPE
# Create a FIFO file, used to manage the I/O redirection from shell
mkfifo $PIPE
# Attach a file descriptor to the file
exec 3<> $PIPE
# Create the notification icon (default icon-size=16)
yad --notification --listen --no-middle \
--image="./yad-icon-off.svg" \
--icon-size=24 --text="Toggle ON/OFF" \
--command="./yad-toggle" <&3
# If you need to QUIT, open your Terminal and type: echo "quit" > $HOME/.var/yad-pipe
Code: Select all
#!/bin/bash
TOGGLE=$HOME/.var/yad-toggle
if [ ! -e $TOGGLE ]; then
touch $TOGGLE
echo "icon:./yad-icon-on.svg" > $HOME/.var/yad-pipe
else
rm $TOGGLE
echo "icon:./yad-icon-off.svg" > $HOME/.var/yad-pipe
fi
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg8"
version="1.1"
viewBox="0 0 12.7 12.7"
height="48"
width="48">
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<circle
style="opacity:1;fill:#ff1a2c;fill-opacity:1;stroke:none;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none"
id="path833"
cx="6.3499999"
cy="6.3499999"
r="6.3499999" />
<circle
style="opacity:1;fill:none;fill-opacity:1;stroke:#ffffff;stroke-width:1.5875;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="circle873"
cx="6.3500004"
cy="6.3500004"
r="4.2333336" />
</g>
</svg>
Code: Select all
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
id="svg8"
version="1.1"
viewBox="0 0 12.7 12.7"
height="48"
width="48">
<defs
id="defs2" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1">
<circle
style="opacity:1;fill:#0088ff;fill-opacity:1;stroke:none;stroke-width:0;stroke-miterlimit:4;stroke-dasharray:none"
id="path833"
cx="6.3499999"
cy="6.3499999"
r="6.3499999" />
<path
style="fill:none;stroke:#ffffff;stroke-width:2.11666667;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
d="M 6.3499997,2.1166667 V 10.583333"
id="path853" />
</g>
</svg>