Re: [Solved] 4.8 Panel question/suggestion

Not sure if the functionality exists in xfce, but I use wmctrl and a helper script to start a program if its not running and/or raise it to the front, for a couple of apps (namely decibel-audio-player and chromium-browser). I create a copy of this helper script for each app that I want to manage this way and assign the helper script to the launcher. Here is the code:

Re: [Solved] 4.8 Panel question/suggestion

ToZ wrote:

Not sure if the functionality exists in xfce, but I use wmctrl and a helper script to start a program if its not running and/or raise it to the front, for a couple of apps (namely decibel-audio-player and chromium-browser). I create a copy of this helper script for each app that I want to manage this way and assign the helper script to the launcher. Here is the code:

APPNAME=$(basename $(cat /proc/$PPID/cmdline))
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD/$HOME/~} $APPNAME\007"'
;;
*)
;;
esac

Re: [Solved] 4.8 Panel question/suggestion

Ok. Changed the script around a bit. First, I made the script take a parameter (the executable name), so that you only need one launcher script. Usage is like:

launcher pcmanfm

I also found that it wasn't a good idea to grep on ps-ef (especially in a multi-user environment) and it was better to grep on class name using only the wmctrl-managed windows (wmctrl -lx) so to avoid issues where the same phrase is on multiple windows (ie. pcmanfm and firefox open to a page about pcmanfm) and focus only on the current graphical login environment (hope that makes sense). Anyways, here is the new code that works with pcmanfm and a bunch of others that I tested:

Re: [Solved] 4.8 Panel question/suggestion

ToZ wrote:

Ok. Changed the script around a bit. First, I made the script take a parameter (the executable name), so that you only need one launcher script. Usage is like:

launcher pcmanfm

I also found that it wasn't a good idea to grep on ps-ef (especially in a multi-user environment) and it was better to grep on class name using only the wmctrl-managed windows (wmctrl -lx) so to avoid issues where the same phrase is on multiple windows (ie. pcmanfm and firefox open to a page about pcmanfm) and focus only on the current graphical login environment (hope that makes sense). Anyways, here is the new code that works with pcmanfm and a bunch of others that I tested:

Re: [Solved] 4.8 Panel question/suggestion

And, in case you're interested, here is the code if you want to raise and bring forward all windows of the same class/executable (ie. if you have multiple pcmanfm windows open, they will all be raised and brought to the front)

Re: [Solved] 4.8 Panel question/suggestion

I guess you could copy the launcher script to /usr/local/bin so that it is available for all users. Then edit all of the .desktop files in /usr/share/applications and ~/.local/share/applications so that the exec section is preceeded by launcher like:

launcher mousepad

A couple of problems/issues:1. you would have to manually edit all of the .desktop files (tedious)2. some of the .desktop files have parameters to the main executable (ie. mousepad.desktop -> Exec=mousepad %f). This would have to be accounted for with some extra code (doable).

(cracks open a beer and thinks.....)

Ok. If you don't mind manually editing all of the .desktop files, try this:

Then edit all of your .desktop files replacing the string "Exec=" with "Exec=launch ". (This part is clumsy and tedious but I can't think of an easier way to do it - short of changing the xfce code itself.)

Re: [Solved] 4.8 Panel question/suggestion

Unfortunately, wmctrl -k is an all or nothing command. If my understanding above is correct, we would need to use a tool such as xdotool to selectively minimize an app. The complication would be aligning wmctrl window ids with xdotool window ids.