New year means New Epic Linux Desktop customization.
Useless therefore essential.
This is the way.
Soooo… time for a yearly post of pretty useless shell commands!
On XFCE, I was using the epic Ubo icons to customize the desktop panel.
I faced two issues when setting up the Firefox button :
- If an existing Firefox instance is running but not activated (minimized or behind other windows), I want to activate it instead of creating a new one.
- While the launcher icon is OK, the running app icon is still showing the default app icon.
Here’s an example of how I dealt with the issue, using wmctrl and xseticon.
!/bin/bash
APP_CLASS="Navigator.firefox"
APP_PATH="firefox"
ICON_PATH="/path/to/icon.png"
# wmctrl can display various info on running windows (PID, class, etc)
RUNNING_WINDOWS=`wmctrl -l -x | grep ${APP_CLASS}`
if [ -n "${RUNNING_WINDOWS}" ]; then
# Activate any window matching given pattern
wmctrl -x -a ${APP_CLASS}
else
${APP_PATH} &
fi
sleep 1
# Get window PIDs (1st column of wmctrl returned strings).
# There can be multiple matches !
# In this case, we use the xargs command :
# by using '-I %', we tell that any occurence of the '%' character
# will be replaced by input.
wmctrl -l -x | grep ${APP_CLASS} | cut -d ' ' -f 1 \
| xargs -I % xseticon -id % $ICON_PATH
It was fun but it’s rather incomplete.
Anytime a new Firefox window will be created by user, the default app icon will be displayed until xseticon command is called again.
Well…Next year.
Maybe.