0

I'm using kdocker (I'm using GNOME though) for thunderbird and that works great. Now I've found this really nice desktop client for whatsapp and would like to start it at startup. There are 2 problems though: it's a snap app, so it takes ages to load and thus doesn't work well with kdocker (kdocker gives a timeout error and after that whatsdesk opens not minimized in the tray). The second issue is that it already has it's own icon in the system tray so kdocker adds a duplicate in any case.

As a workaround for now I'm running this script on startup:

#!/bin/bash
snap run whatsdesk &
sleep 10
wmctrl -c "Whatsdesk"

I was wondering though if there was a better way to do this, instead of opening the window and then killing the application (it minimizes in the tray even after being killed like this).

2 Answers 2

2

Yes, there is a better way to do this, it's still kind of dirty, but at least it works. Just put the code below in a file without extension and select the script to be run at system start /log in. You also have to set Whatsdesk to be started at boot. Then it should just work fine. :)

I was actually insprired by your script, so it's just a kind of extension to your's:

#!/bin/bash
i=0                             #set "counting var" to 0
while true; do                  #do as long as I say
i=$(echo $i + 1)                #add 1 to i
wmctrl -F -c "WhatsDesk"        #close window with exact title "WhatsDesk"
    if [ $? -eq 0 ]; then       #if close window command was successful, do:
    break                       #end "while"
    else
        if (( $i == 40 ))       #if "counting var" = x, do:
        then
        break                   #end "while"
        else
        sleep 0.25              #pause "while" for x seconds
        fi
    fi
done

The -F option forces wmctrl to be case sensitive and it has to be the full name of the window title. So... as long as you don't have another window with the exact same name, you are fine. Every 0.25 seconds will be searched for a matching window. To change that, just change the "0.25" to something else (in seconds). Also, after 10 seconds, this script does end itself when no matching window was found. To change that, change the "40" to something else (wanted seconds x (1 / 0.25)) <- replace with your wanted value.

I hope that helps you. (works for me at least ;D) :)

0
  1. Install the gnome extension for Firefox
  2. Switch on the tray icon extension for Gnome

After that, you can view the whatsdesk tray icon on the taskbar

2
  • 1
    Welcome to Ask Ubuntu! ;-) Could you please review my edits and also review the editing help to improve the readability of your questions in the future... ;-)
    – Fabby
    Jun 18, 2019 at 22:05
  • 1
    I may have missed something, but ubuntu already provides tray icons by default. My question was to how autostart the application in the background.
    – dsSTORM
    Jun 20, 2019 at 5:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.