D4koon / WhatsappTray

Minimize Whatsapp Desktop-Client to Tray
GNU General Public License v3.0
387 stars 32 forks source link

Any way to support multiple user accounts? #62

Closed InteXX closed 3 years ago

InteXX commented 3 years ago

I maintain two user accounts on my computer—one for work and one for home. I have WhatsApp installed for each profile, and I'd like to use WhatsAppTray for them both.

The appData.ini file in the central C:\Program Files (x86)\WhatsappTray directory appears to support only one profile per machine, but I could be mistaken:

WHATSAPP_STARTPATH=C:\Users\Work\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\WhatsApp\WhatsApp.lnk
WHATSAPP_ROAMING_DIRECTORY=C:\Users\Work\AppData\Roaming

I'd like to be able to add multiple profiles to this configuration, e.g.:

WHATSAPP_STARTPATH=C:\Users\Home\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\WhatsApp\WhatsApp.lnk
WHATSAPP_ROAMING_DIRECTORY=C:\Users\Home\AppData\Roaming

Could there be a way to do so?

D4koon commented 3 years ago

I made a debug verison for that. It supports the variable %userStartmenuePrograms% which then is translated at runtime of WhatsappTray: WHATSAPP_STARTPATH=%userStartmenuePrograms%\WhatsApp\WhatsApp.lnk

Plese give feedback if it is working.

WhatsappTrayV1.5.0.3.zip

InteXX commented 3 years ago

Plese give feedback if it is working

  1. WAT runs
  2. An error manifests under the second profile, just before WA starts
  3. WA starts
  4. 'Close to tray' works
  5. WA seems to operate normally

image

What would you think about just using %AppData%?

  1. It works 'out of the box'
  2. WHATSAPP_ROAMING_DIRECTORY would be supported as well
  3. It'd mean one less variable for the user to create and maintain

e.g.

WHATSAPP_STARTPATH=%AppData%\Microsoft\Windows\Start Menu\Programs\WhatsApp\WhatsApp.lnk
WHATSAPP_ROAMING_DIRECTORY=%AppData%
D4koon commented 3 years ago

I forgot about WHATSAPP_ROAMING_DIRECTORY

I added now an resolver for %appdata% for both settings, but still keep %userStartmenuePrograms% as the default to be more generic Note that appdata needs to be lowercase

WhatsappTrayV1.5.0.5.zip

Thank you for your feedback

InteXX commented 3 years ago

Works great. Good job, thanks. If I had a request for that, it'd be to allow the variable name to be case-insensitive. But if that's a lot of trouble, never mind.

Now the tricky part: making the settings per-profile as well.

Could something like this work?

  1. Parse the value of %AppData% to get the profile name (e.g. Home)
  2. Scan appData.ini for a section by that name (case-insensitive, just in case)
  3. If one is found, use those settings
  4. If not, create the section with the settings at their default values

Now you've got full multi-user support.

InteXX commented 3 years ago

Thank you for your feedback

YW

D4koon commented 3 years ago

Included in WhatsappTray V1.6.0