Unique icons for multiple instance of programs
by Turbocapitalist from LinuxQuestions.org on (#50R0P)
I would appreciate feedback on the process below and especially the short script in the middle here. Where or how can it be improved?
I have scripted ways to have unique icons in the desktop environment's task switcher. The backgroud is that depending on what I am doing, I can have too many instances of the same program open at the same time to be able to tell them apart easily when hitting alt-tab. If the programs are able to run separately, a script can easily choose which icon to assign the process.
First, make or choose a base icon in SVG format for one application. Then make n copies, where each copy has an additional object such as a star, dot, circle, dash, or whatever to make it visually unique.
Then make a script to check for the first available number. Here is a script to launch the XFCE4-Terminal which gives each running instance its own unique icon, up to six instances:
Code:#!/bin/sh
PATH=/usr/bin:/bin
set -e
pp=$(ps -o pid,args -p $(pgrep xfce4-terminal))
for t in $(seq 1 6); do
if ! echo $pp | grep -q -w "title=Terminal $t"; then
break
fi
done
if test $t -le 6; then
xfce4-terminal --title="Terminal $t" \
--icon=/home/tc/Icons/terminal.$t.svg \
--geometry 80x24 --disable-server &
fi
exit 0The script is would be similar for other applications. But is the loop efficient or just clumsy?
Then make a .desktop file pointing to the base icon and set to lauch the script.
The result is that each time the icon is launched the new process gets a new icon until they run out.


I have scripted ways to have unique icons in the desktop environment's task switcher. The backgroud is that depending on what I am doing, I can have too many instances of the same program open at the same time to be able to tell them apart easily when hitting alt-tab. If the programs are able to run separately, a script can easily choose which icon to assign the process.
First, make or choose a base icon in SVG format for one application. Then make n copies, where each copy has an additional object such as a star, dot, circle, dash, or whatever to make it visually unique.
Then make a script to check for the first available number. Here is a script to launch the XFCE4-Terminal which gives each running instance its own unique icon, up to six instances:
Code:#!/bin/sh
PATH=/usr/bin:/bin
set -e
pp=$(ps -o pid,args -p $(pgrep xfce4-terminal))
for t in $(seq 1 6); do
if ! echo $pp | grep -q -w "title=Terminal $t"; then
break
fi
done
if test $t -le 6; then
xfce4-terminal --title="Terminal $t" \
--icon=/home/tc/Icons/terminal.$t.svg \
--geometry 80x24 --disable-server &
fi
exit 0The script is would be similar for other applications. But is the loop efficient or just clumsy?
Then make a .desktop file pointing to the base icon and set to lauch the script.
The result is that each time the icon is launched the new process gets a new icon until they run out.