kde, docking an app in systray

inspired from https://github.com/user-none/KDocker/issues/42

not all app are able to minimize in systray.

how to minimize such an app ?

i illustrate this tutorial by docking in systray “Android Messages”

install kdocker:

to see what is the last revision number

https://github.com/user-none/KDocker/releases

search the package here https://software.opensuse.org with key “kdocker”

search opensuse leap 15.0

click on “display community packages”

search the last version

run a “one click installation”

in kde settings > start up and shutdown > desktop session > on login > applications to be excluded from sessions
fill with text “kdocker”

in ~/bin/
create dock_messages.sh then check the file property “executable”

put in


#!/bin/bash
#
sleep 2m
/opt/google/chrome/google-chrome --app=https://messages.android.com && sleep 5s && WID="$(wmctrl -lx | grep Messages)"; kdocker -qw "${WID%% *}"


in kde settings > start up and shutdown > desktop session > autostart
add the script and select run on “startup”

to get the right icon for “Android Messages”

create a desktop launcher of “Android Messages”

launch “Android Messages”

launch kdocker

the mouse cursor becomes a kdocker cursor

put the cursor to the window of “Android Messages” then left click

“Android Messages” is minimized in the systray

right click on “Android Messages” icon

go to “options” > set icon

go to .local/share/icons/hicolor/32x32/apps/

select “Android Messages” icon

that’s all

enjoy

Some explanations

>> in kde settings > start up and shutdown > desktop session > on login > applications to be excluded from sessions
fill with text “kdocker”

kdocker is an app if you close a kde session and an app is running at the next kde opening session then kde launch kdocker. we don’t want that because kdocker does not record the docked apps.

>> sleep 2m

opening a kde session => during about 2 mn baloo indexer slows all task startup => script kdocker statement fails

launching “Android Messages” before or during “Google Hangouts” startup => randomly this leads to 2 google chrome and 2 google hangouts instances and fails concerning chrome , hangouts and “Android Messages”

>>
WID="$(wmctrl -lx | grep Messages)"

instead of “Messages” you can put any word from your app window title or the whole title

>> create a desktop launcher of “Android Messages”

with chrome go to messages.android.com
then
in the menu go to “more tools” > create a desktop launcher" <<<< not sure of the English terms

this also adds icons for “Android Messages”

i forgot this:

right click the icon of the minimized “Android Messages”
go to "options
check “skip taskbar”

explanation:

after using “Android Messages” you minimize the window then the app is minimized but stay in task bar. another bug of kdocker.

>> another bug of kdocker.

no it’s not a bug. kdocker can’t avoid this problem. it just can supply a workaround.

i forgot this:

after checking “skip taskbar” you must record this property.

right click the icon then go to “options” > save settings then left click on " save Google-chrome only"

to avoid conflict with the window “Kontact Messages” i change “Messages” by “Messages pour le Web” <<<< this is the french window title you must use the title which is displayed in your language
to avoid "manualy checking “skip taskbar” " i change “qw” by “qtw”

then the new script is :


#!/bin/bash
#
sleep 2m
/opt/google/chrome/google-chrome --app=https://messages.android.com && sleep 5s && WID="$(wmctrl -lx | grep "Messages pour le Web")"; kdocker -qtw "${WID%% *}"


If you use kdeconnect then in kdeconnect-android you must uncheck “send SMS” according to receive only sms notification from desktop android messages.

  • sometime problem with WID then app is not minimize in the systray

i changed
/opt/google/chrome/google-chrome --app=https://messages.android.com

by

bash -c ‘/opt/google/chrome/google-chrome --app=https://messages.android.com &’

then

the new script


#!/bin/bash
#
sleep 1m 45s
bash -c '/opt/google/chrome/google-chrome --app=https://messages.android.com &' && sleep 5s && WID="$(wmctrl -lx | grep "Messages pour le Web")"; kdocker -qtw "${WID%% *}"

  • if you dock in systray several apps then they got the same icon

you must add the pathname to the icon for each app

then

the new script


#!/bin/bash
#
sleep 1m 45s
bash -c '/opt/google/chrome/google-chrome --app=https://messages.android.com &' && sleep 5s && WID="$(wmctrl -lx | grep "Messages pour le Web")"; kdocker -qtw "${WID%% *}" -i ~/.local/share/icons/hicolor/32x32/apps/chrome-nngjipgjhfkaeimbhgmodlbhligdflei-Default.png


finally with the help from https://github.com/user-none/KDocker/issues/42

to avoid problem due to:

  • slow or fast launch of app
  • conflict between several apps docked in systray with kdocker
  • icon problem

here is the final script


#!/bin/bash
bash -c '/opt/google/chrome/google-chrome --app=https://messages.android.com &'
while  true ]
do
   sleep 5
   status=$(wmctrl -l | grep "Messages pour le Web")
   if  "$status" != "" ] ; then
      break
   fi
done
WID="$(wmctrl -lx | grep "Messages pour le Web")"; kdocker -qtw "${WID%% *}" -i ~/.local/share/icons/hicolor/32x32/apps/chrome-nngjipgjhfkaeimbhgmodlbhligdflei-Default.png