Skip to content

Instantly share code, notes, and snippets.

@Nachtalb
Last active October 25, 2024 05:23
Show Gist options
  • Save Nachtalb/ec590dc974f6ba4674972d4937b230be to your computer and use it in GitHub Desktop.
Save Nachtalb/ec590dc974f6ba4674972d4937b230be to your computer and use it in GitHub Desktop.
Add multiple accounts in Telegram Desktop [Linux | MacOSX | Windows]

How to add multiple accounts to Telegram Desktop

‼️‼️ As of version 2.1.14 Telegram Desktop supports up to 3 multiple accounts inbuilt ‼️‼️

If you have more you can still use this method (3 accounts per instance)

⚠ This guide is for the app available here: https://desktop.telegram.org/ not the one in the Mac/Windows App Store. For the Mac App Store app this should work: https://gist.github.com/Nachtalb/ec590dc974f6ba4674972d4937b230be/#gistcomment-3611415

ATM of writing this, there is no way inside the Telegram Client to switch accounts (event though this feature exists in the offical mobile clients and there is a long running issue here: telegramdesktop/tdesktop#4261).

The Official Telegram Desktop client however has the feature to set the working directory with a command line argument -workdir. This enables the use of multiple accounts.

In this guide I will show you a way to use this feature on MacOSX, Linux and Windows. We will be working with the -workdir argument to create multiple instances for each Telegram account.

❗ Replace {{...}} thing with what is written in there. So eg. for me and my TG account @Nachtalb I replace {{MyUsername}} with Nachtalb.

  • Create a folder here ~/.local/share/TelegramDesktop/{{MyUsername}}
  • Create a new .desktop file here ~/.local/share/applications/telegramdesktop-{{myusername}}.desktop.
  • Put in your data in here

⚠️ In this example the Telegram binary resides in /opt/Telegram/Telegrm. This might be different in your case. If so then you have to adjust the path to the binary on the lines TryExec and Exec. ⚠️

[Desktop Entry]
Version=1.0
Name=Telegram {{MyUsername}}
Comment=Official desktop version of Telegram messaging service
TryExec=/opt/Telegram/Telegram
Exec=/opt/Telegram/Telegram -workdir /home/{{your_user}}/.local/share/TelegramDesktop/{{MyUsername}} -- %u
Icon=telegram
Terminal=false
StartupWMClass=TelegramDesktop
Type=Application
Categories=Network;InstantMessaging;Qt;
MimeType=x-scheme-handler/tg;
Keywords=tg;chat;im;messaging;messenger;sms;tdesktop;
X-GNOME-UsesNotifications=true
X-Desktop-File-Install-Version=0.23
  • Create a folder here: ~/.local/share/TelegramDesktop/{{MyUsername}}

  • Open Automator

  • Create a new Application

    https://user-images.githubusercontent.com/9467802/56354968-6875f500-61d5-11e9-9e61-32f87ba5502c.png
  • Add an apple script by drag & drop from the left-hand side

  • Add the following text:

do shell script "Applications/Telegram.app/Contents/MacOS/Telegram -workdir '/Users/{{your_user}}/.local/share/TelegramDesktop/{{MyUsername}}'"

https://user-images.githubusercontent.com/9467802/56354966-657b0480-61d5-11e9-8341-200ee72d1cb2.png

  • Save to /Applications/Telegram {{MyUsername}}.app
  • Now lastly if you want the have the same icon for your new app, open the file info of both apps (the original telegram and yours) with CMD + I and click on the icon in the top left of the original application. Hit copy CMD + C, click on yours and hit past CMD + V.
  • Create a folder here: C:\Users\{{your_user}}\AppData\Roaming\Telegram Desktop\{{MyUsername}}
  • Rightclick on your desktop and create a new shortcut
  • Put this in the location field
"C:\Users\{{your_user}}\AppData\Roaming\Telegram Desktop\Telegram.exe" -workdir "C:\Users\{{your_user}}\AppData\Roaming\Telegram Desktop\{{MyUsername}}"
  • Click next and type in a name for the shortcut, usually something like Telegram {{MyUsername}}
  • Lastly to find the application via the start menu you have to copy the link in here
@DJayparmar
Copy link

I'm using 2 accounts from last 1 year but method is little bit simple and unique...
1
Simply download telegram desktop official .exe file and install into other location not in default location.
2
Download another telegram app from Microsoft Store which creates 2nd telegram app
3 that's it u can use 2 accounts now simultaneously 😁

@Nachtalb
Copy link
Author

@DJayparmar

This seems more like a workaround instead of a good and solid solution. The --workdir parameter is specifically made for supporting multiple instances of Telegram with different users.
Your solution seems more like bloat. You have to install the whole thing multiple times (redundancy), always have to update each instance by its own and you'll have two "Telegram"s instead of a "Telegram Foo" and "Telegram Bar" and thus can't differentiate them in the start menu nor taskbar.

Also from the approaches I listed, I think that the windows one is the easiest and most robust of them all. (IMHO The one for Apple devices could be better but didn't find another good way to do it)

@Nachtalb
Copy link
Author

@pavelsr another user wrote to me with a similar problem. In his case the problem was just that the Telegram binary resided in another location. I have added a little notice to the instructions above for that.

⚠️ In this example the Telegram binary resides in /opt/Telegram/Telegrm. This might be different in your case. If so then you have to adjust the path to the binary on the lines TryExec and Exec. ⚠️

Maybe it was the same problem in your case.

@dev117uday
Copy link

For linux, no need to go through all these hassle, Install the telegram desktop app on linux via apt-get and then simply use another package manager like snap or flathub to download another telegram app.

@Nachtalb
Copy link
Author

@dev117uday as said here already. --workdir is an official solution provided by the app. Whereas installing multiple versions of Telegram is IMHO just bloat. Eg. when you install it with apt, flat and snap you have to update each by its own instead of just once, you need 3 times the disk space, all 3 apps have the same name in the start menu instead of own ones like Telegram Foo and Telegram Bar and more.

But now since the last versions we have multi-account support up to 3 accounts anyway 🤷. But if you need more than 3 accounts I'd still go the --workdir way.

@leoblum
Copy link

leoblum commented Nov 10, 2020

Any one try to modify TG client from sources to allow more than 3 account in same client?

I looking for macos telegram source code and find two lines which are responsible for it. But I never wrote on swift language. So I dont know how to check that.

@Nachtalb
Copy link
Author

Nachtalb commented Nov 11, 2020

@totalleo the Telegram Desktop app I am talking about above is not written in Swift but in C++: https://github.com/telegramdesktop/tdesktop

The line defining the max accounts per instance is defined here: https://github.com/telegramdesktop/tdesktop/blob/5cc7c2b6c6ecdce1ab4067549c4e7acd299dd5d5/Telegram/SourceFiles/main/main_domain.h#L33

You can find the build instructions for this client at the bottom of its readme: https://github.com/telegramdesktop/tdesktop#build-instructions

The Telegram app written in Swift would be this one https://github.com/overtake/TelegramSwift. I don't know if it supports more than 3 accounts as I have never used it.

@andrewkmin
Copy link

While this might go without saying, for anyone simply looking to create two separate windows of the Telegram Mac client, you can simply duplicate the app (via Applications --> rightclick/secondary click Telegram --> duplicate --> open duplicate and log into desired account

@Nachtalb
Copy link
Author

@andrewkmin wouldn't this then create the profiles at the same place and thus override each other?

@leoblum
Copy link

leoblum commented Jan 28, 2021

@totalleo the Telegram Desktop app I am talking about above is not written in Swift but in C++: https://github.com/telegramdesktop/tdesktop

The line defining the max accounts per instance is defined here: https://github.com/telegramdesktop/tdesktop/blob/5cc7c2b6c6ecdce1ab4067549c4e7acd299dd5d5/Telegram/SourceFiles/main/main_domain.h#L33

You can find the build instructions for this client at the bottom of its readme: https://github.com/telegramdesktop/tdesktop#build-instructions

The Telegram app written in Swift would be this one https://github.com/overtake/TelegramSwift. I don't know if it supports more than 3 accounts as I have never used it.

Thank for you comment.

I asked developers of Swift version how to use more than three accounts in one application instance. And it is possible!

To add more than three accounts, you need to click five times on the user pic, it will open a secret developer's menu through which you can add as many accounts as you want.

The same works for the iOS version. Enjoy =)

@andrewkmin
Copy link

@andrewkmin wouldn't this then create the profiles at the same place and thus override each other?

Nope, I've used two simultaneously. The caveat is that if one closes, you have to re-login to them

@Nachtalb
Copy link
Author

Nachtalb commented Feb 3, 2021

@andrewkmin wouldn't this then create the profiles at the same place and thus override each other?

Nope, I've used two simultaneously. The caveat is that if one closes, you have to re-login to them

This sounds like they do override each other, but it works as long as they are running because the app runs in RAM. I have the feeling that could lead to problems...

@Nachtalb
Copy link
Author

Nachtalb commented Feb 3, 2021

@totalleo

Thanks for the clarification, I referred to your comment at the start of the guide

@hardcore
Copy link

hardcore commented Mar 9, 2021

To add more than three accounts, you need to click five times on the user pic, it will open a secret developer's menu through which you can add as many accounts as you want.

THAT IS SO COOL THANKS A LOT!!!!!

@ngocnam544
Copy link

Work well on windows. Thank you very much.

@ihsansadn
Copy link

Thank you so much. Work well on LM Ulyssa.

@girifir
Copy link

girifir commented Jul 12, 2021

@totalleo the Telegram Desktop app I am talking about above is not written in Swift but in C++: https://github.com/telegramdesktop/tdesktop
The line defining the max accounts per instance is defined here: https://github.com/telegramdesktop/tdesktop/blob/5cc7c2b6c6ecdce1ab4067549c4e7acd299dd5d5/Telegram/SourceFiles/main/main_domain.h#L33
You can find the build instructions for this client at the bottom of its readme: https://github.com/telegramdesktop/tdesktop#build-instructions
The Telegram app written in Swift would be this one https://github.com/overtake/TelegramSwift. I don't know if it supports more than 3 accounts as I have never used it.

Thank for you comment.

I asked developers of Swift version how to use more than three accounts in one application instance. And it is possible!

To add more than three accounts, you need to click five times on the user pic, it will open a secret developer's menu through which you can add as many accounts as you want.

The same works for the iOS version. Enjoy =)

is this still applicable on the latest version of windows?

@Nachtalb
Copy link
Author

The content from the main article at the top still works. And from what i have heard the swift apps and so on also still have the same functionality as described in the comments.
All in all, as far as i know, nothing has changed @ararar13

@AJackTi
Copy link

AJackTi commented Oct 30, 2021

To add more than three accounts, you need to click five times on the user pic, it will open a secret developer's menu through which you can add as many accounts as you want.

THAT IS SO COOL THANKS A LOT!!!!!

Sorry I have a question. Could you please answer me? What is the user pic? Could you please share with me the screenshot?

@AJackTi
Copy link

AJackTi commented Oct 30, 2021

The content from the main article at the top still works. And from what i have heard the swift apps and so on also still have the same functionality as described in the comments. All in all, as far as i know, nothing has changed @ararar13

Sorry I have a question. Could you please answer me? What is the user pic? Could you please share with me the screenshot?

@Nachtalb
Copy link
Author

To add more than three accounts, you need to click five times on the user pic, it will open a secret developer's menu through which you can add as many accounts as you want.

THAT IS SO COOL THANKS A LOT!!!!!

Sorry I have a question. Could you please answer me? What is the user pic? Could you please share with me the screenshot?

I don't have access to a MacBook anymore so I can't test it myself but with "user pic" he probably meant your user profile picture (probably in the settings view). @AJackTi

CC/ @leoblum

@AJackTi
Copy link

AJackTi commented Oct 30, 2021

To add more than three accounts, you need to click five times on the user pic, it will open a secret developer's menu through which you can add as many accounts as you want.

THAT IS SO COOL THANKS A LOT!!!!!

Sorry I have a question. Could you please answer me? What is the user pic? Could you please share with me the screenshot?

I don't have access to a MacBook anymore so I can't test it myself but with "user pic" he probably meant your user profile picture (probably in the settings view). @AJackTi

CC/ @leoblum

Thank you so much for your help, but I can't open dev mode when clicking on the "user pic" as your instructions. Could you please upload the process when you click the image "user pic" in this your telegram by Window version?

Copy link

ghost commented Dec 2, 2021

@Nachtalb @AJackTi
user pic on the bottom right!
click five time!

2021-12-02 11 30 35

Source: https://github.com/overtake/TelegramSwift/blob/fa0bfbe4daa5caa837b48653b73fcd02e85c29c3/Telegram-Mac/AccountViewController.swift

        if let currentEvent = NSApp.currentEvent, currentEvent.clickCount == 5 {
            context.sharedContext.bindings.rootNavigation().push(DeveloperViewController(context: context))
        }
        

@Nachtalb
Copy link
Author

Nachtalb commented Dec 5, 2021

Thanks for the update @DebugNewWorld 👍

@AJackTi
Copy link

AJackTi commented Dec 10, 2021

Thank you so much @DebugNewWorld
But I want to know how many accounts can I add in this development mode?

@AJackTi
Copy link

AJackTi commented Dec 10, 2021

I had a crash before when adding too many accounts (more than 20 accounts), I still don't understand why I got such a crash? And how to fix this situation? @Nachtalb @DebugNewWorld

@Nachtalb
Copy link
Author

@AJackTi

I don't use the swift app myself nor do I have access to a MacBook anymore. The main topic of the instructions on this page is the official desktop app: https://desktop.telegram.org/ / https://github.com/telegramdesktop/tdesktop

For more in-depth questions for the Swift app about the max number of accounts, crashes etc. please refer to its repository here: https://github.com/overtake/TelegramSwift

@mrsafi02
Copy link

I cant seem to find the specific file path on mac for creating the file, what could I be doing wrong?

@Nachtalb
Copy link
Author

I cant seem to find the specific file path on mac for creating the file, what could I be doing wrong?

There are two different Telegram Apps for the Mac. One from the App Store and one from the website linked at the top of the instructions. If you don't have the folders as described in these instructions I guess you have the App Store one installed. I don't know if it's even possible with that one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment