Author Topic: Using multiple icons in the tray or panel  (Read 789 times)

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10690
  • MLUs Forever!
Using multiple icons in the tray or panel
« on: June 17, 2012, 03:37:59 AM »
There is something that has rather intrigued me for a wee while ....  how is the use of multiple icons achieved for displaying the status of a particular application, in the tray or panel (KDE)?

Is it difficult to achieve?
Where is it set?

In its simplest form let's say I want to show an icon that indicates if something is switched on or off.
It doesn't matter what the 'something' is ...  but I have devised an example, given below.

This example toggles on & off some loopback devices of Pulse Audio, to provide a mixer.
The script is simply launching the PA modules when going on and killing them when turning off.

An icon in the panel can be clicked to toggle the mixer on and off.

But ....  it would be nice if the icon in the panel could change to indicate which state the mixer is in ... something like a green tinged icon for on and a red tinged one for off ......  you get the idea hopefully.

So the question is, can this be done in a simple manner, or is it more complicated and not really worth the effort for such an application.

BTW ...  in the example below, the state of the mixer can be seen on the PA Volume Control Recording tab with "All Streams" selected to display.

*****

PA Mixer .desktop file ....  I am using a Veromix icon in this example, and have added a directory under /usr/bin  to hold my experimental files.

Code: [Select]
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=PulseAudio Mixer
GenericName=Toggle Mixer Devices On/Off
Comment=Set up loopback devices for mixing
Exec=/usr/bin/user/PA-Mix.sh
Icon=/usr/share/kde4/apps/plasma/plasmoids/veromix-plasmoid/contents/icons/veromix-plasmoid-128.png
StartupNotify=true
Type=Application
Categories=AudioVideo;Audio;Mixer;GTK;X-MandrivaLinux-Multimedia-Sound;
X-Desktop-File-Install-Version=0.11

The PA-Mix.sh script ...  told ye it was simple  :D

Code: [Select]
#!/bin/bash

### This script sets up two loopback virtual devices and a null sink
### which can then be used to mix inputs and record the result.
### It requires a functioning PulseAudio installation and also
### PulseAudio Volume Control to manage the streams.
# License: GPL 2 or later
# Author: clareoldie
# Date: June 1st 2012


set -x
unload-modules () {
### First detect then unload loopback devices
for i in $(pactl list | grep -B 1 'Name: module-loopback' | grep 'Module #' | cut -d '#' -f 2-)
do
pactl unload-module $i
done
### Next detect and unload the Null-Sink device/s
for i in $(pactl list | grep -B 1 'Name: module-null-sink' | grep 'Module #' | cut -d '#' -f 2-)
do
pactl unload-module $i
done
}

load-modules () {
### Load required modules
pactl load-module module-null-sink sink_name=MySink
pactl load-module module-loopback sink=MySink
pactl load-module module-loopback sink=MySink
}

test-modules () {
## If the modules exist 0$?=0 then unload them, else load them.
pactl list | grep -B 1 'Name: module-loopback'
if [ "$?" = "0" ]
then
unload-modules
exit 0
fi
pactl list | grep -B 1 'Name: module-null-sink'
if [ "$?" = "0" ]
then
unload-modules
exit 0
else
load-modules
fi
}

### Main Programme
test-modules

If you have any ideas on this please post ......  thanks  ;)

MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10690
  • MLUs Forever!
Re: Using multiple icons in the tray or panel
« Reply #1 on: June 25, 2012, 05:15:09 PM »
No ideas yet, I see  :(

I am still hopeful  ;)

MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Archie

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8590
  • Aurum nostrum non est aurum vulgi.
Re: Using multiple icons in the tray or panel
« Reply #2 on: June 25, 2012, 11:24:59 PM »
I'm a little bit daft this morning, but are you looking for ksystraycmd?
Since 2006 | LiCo 401868 | Bare Metal | What is necessary is never unwise. --Sarek, 2258.42


Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10690
  • MLUs Forever!
Re: Using multiple icons in the tray or panel
« Reply #3 on: June 26, 2012, 02:33:04 AM »
I'm a little bit daft this morning, but are you looking for ksystraycmd?

I don't know  :(   If it can answer the question posed then yes .........  but I don't think it does; but I am not very familiar with ksystraycmd

Quote
how is the use of multiple icons achieved for displaying the status of a particular application?

Behaviour like
Net applet ....  connected = green tick; not connected = red X

=>   two icons for the one app, each icon denoting the status at a particular time

« Last Edit: June 26, 2012, 04:14:38 AM by Just18 »
MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline sir_herrbatka

  • Full Member
  • ***
  • Posts: 238
Re: Using multiple icons in the tray or panel
« Reply #4 on: June 26, 2012, 03:11:47 AM »
Code: [Select]
def updateIcon(self):
        # Note: I'm not sure why, but the font shows up much nicer at small sizes when the size is set to larger than the
        #       plasmoid (using a multiple of 2 here)
        loader = KIconLoader()
        size = min(self.icon.size().width(),self.icon.size().height())*2
      if self.TotalCount == 0:
            pix = KIconLoader.loadIcon(loader, self.settings["iconnone"], KIconLoader.NoGroup, size)
        else:
            pix = KIconLoader.loadIcon(loader, self.settings["icon"], KIconLoader.NoGroup, size)
        
        paint = QPainter(pix)
        paint.setRenderHint(QPainter.SmoothPixmapTransform)
        paint.setRenderHint(QPainter.Antialiasing)

Code: [Select]
       self.settings["icon"] = self.fixType(gc.readEntry("icon", self.package().path() + "contents/icons/gmail-plasmoid.svg"))
        self.settings["iconnone"] = self.fixType(gc.readEntry("iconnone", self.package().path() + "contents/icons/gmail-plasmoid-gray.svg"))

from gmail plasmoid.

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10690
  • MLUs Forever!
Re: Using multiple icons in the tray or panel
« Reply #5 on: June 26, 2012, 04:17:27 AM »
Thanks sir_herrbatka .......  but can the same behaviour of choosing one of two icons be achieved - simply - when using a script and a .desktop launcher .....  so that the launcher icon on the desktop or in the panel changes?

If not, then OK, it cannot be done .....  but if yes I would like to know how.

Thanks for the responses  ;)

MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline sir_herrbatka

  • Full Member
  • ***
  • Posts: 238
Re: Using multiple icons in the tray or panel
« Reply #6 on: June 26, 2012, 04:32:05 AM »
I'm afraid that no. And I don't think that universal solution works.

Online Just17

  • PCLinuxOS Tester
  • Super Villain
  • *******
  • Posts: 10690
  • MLUs Forever!
Re: Using multiple icons in the tray or panel
« Reply #7 on: June 26, 2012, 04:35:08 AM »
I'm afraid that no. And I don't think that universal solution works.

Thanks again.

Well if anyone has further suggestions I am all ears  ;)
MLUs rule the roost!

Linux XPS 3.4.38-pclos1.bfs  64 bit
Intel Core2 Quad CPU Q9450 @ 2.66GHz
4 GB RAM
MCP51 High Def Audio
GeForce GTX 550 Ti
PHILIPS  ‎DVD+-RW DVD8701
‎Logitech ‎BT Mini-Receiver
Afatech DTT

Offline Yankee

  • Hero Member
  • *****
  • Posts: 1490
  • In theory, theory=practice, in practice ???
Re: Using multiple icons in the tray or panel
« Reply #8 on: July 20, 2012, 05:37:34 PM »
/usr/share/pixmaps has a number of radio tray icons
for various radio tray statuses.

The program or it's script may be able to be read and
copied and altered for that purpose elsewhere.
ASUS EeePc 900HA netbook  1.6 Ghz Atom CPU  1GB RAM
160 GB internal HD    Seagate 250 GB USB portable drive 
Intel ‎Mobile 945GSE Integrated Graphics Controller
Atheros AR242x/AR542x Wireless Network Adapter
Intel (N10/ICH7 Family) High Definition Audio
Dynex 5-Button Wired Optical Mouse
LXDE