How can I add a custom item to the Sound Indicator (and make it clickable more than once)?
Posted
by
con-f-use
on Ask Ubuntu
See other posts from Ask Ubuntu
or by con-f-use
Published on 2012-08-28T19:38:07Z
Indexed on
2012/08/29
21:51 UTC
Read the original article
Hit count: 305
The original question
One of the strength of Unity are the various standardized indicators. I want to customize the sound indicator with an additional menu entry that runs a small shell script. I'm not afraid of a little Python code and I hope someone can point me to the right subroutine in the right file. I suspect that will be fairly easy but all the indicators are just so bloated that I can't look through their code in a reasonable time.
Any help is appreciated. I know it is possible as the marvelous Skype-Wrapper does it.
Edit 2 - Now a dirty DBus hack
The one click problem from one edit before has now turned into a DBus problem. Basically we have to tell the sound indicator that our bogus player has terminated now. A dirty hack navigates around that problem:
#!/bin/bash
# This is '/home/confus/bin/toggleSpeaker.sh'
notify-send "Toggle Speaker" "$(date)"
qdbus \
com.canonical.indicator.sound \
/org/ayatana/indicator/service \
org.ayatana.indicator.service.Shutdown
exit 0
Help from the community is appreciated as I don't have experience any with DBus whatsoever.
Edit 1 - Takkat found a solution but only clickable once?
For some reason the solution proposed by Takkat has the drawback that the resulting entry in indicator sound can only be clicked once per session. If someone has a fix for, than please comment or answer, you will be upvoted. Here you can see the result:
I strongly suspect the issue is related to the .desktop-file in /home/confus/.local/share/application/toggleSpeaker.desktop
, which is this:
[Desktop Entry]
Type=Application
Name=toggleSpeaker
GenericName=Toggle Speaker
Icon=gstreamer-properties
Exec=/home/confus/bin/toggleSpeaker.sh
Terminal=false
And here is a minimal example of the script in /home/confus/bin/toggleSpeaker.sh
for your consideration:
#!/bin/bash
# This is '/home/confus/bin/toggleSpeaker.sh'
notify-send "Toggle Speaker" "$(date)"
exit 0
© Ask Ubuntu or respective owner