1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
diff --git a/Telegram/SourceFiles/platform/linux/specific_linux.cpp b/Telegram/SourceFiles/platform/linux/specific_linux.cpp
index 68d07a55b..762d04ca6 100644
--- a/Telegram/SourceFiles/platform/linux/specific_linux.cpp
+++ b/Telegram/SourceFiles/platform/linux/specific_linux.cpp
@@ -393,6 +393,55 @@ bool psShowOpenWithMenu(int x, int y, const QString &file) {
}
void psAutoStart(bool start, bool silent) {
+ auto home = getHomeDir();
+ if (home.isEmpty() || cAlphaVersion() || cExeName().isEmpty()) return;
+
+ if(start) {
+ DEBUG_LOG(("App Info: placing autostart .desktop file"));
+ if (QDir(home + qsl(".config/")).exists()) {
+ QString autostart = home + qsl(".config/autostart/");
+ if (!QDir(autostart).exists()) QDir().mkpath(autostart);
+
+ QString autostartFilePath = cExeDir() + qsl("../share/") + QCoreApplication::instance()->applicationName() + qsl("/autostart/kotatogramdesktop.desktop");
+ if (QFile(autostartFilePath).exists()) {
+ if (RunShellCommand("desktop-file-install --dir=" + EscapeShell(QFile::encodeName(home + qsl(".config/autostart"))) + " " + EscapeShell(QFile::encodeName(autostartFilePath)))) {
+ RunShellCommand("update-desktop-database " + EscapeShell(QFile::encodeName(home + qsl(".config/autostart"))));
+ }
+ } else {
+ QString path = cWorkingDir() + qsl("tdata/"), file = path + qsl("kotatogramdesktop.desktop");
+ QDir().mkpath(path);
+ QFile f(file);
+ if (f.open(QIODevice::WriteOnly)) {
+ QTextStream s(&f);
+ s.setCodec("UTF-8");
+ s << "[Desktop Entry]\n";
+ s << "Version=1.0\n";
+ s << "Name=" << str_const_toString(AppName) << "\n";
+ s << "Comment=Experimental Telegram Desktop fork\n";
+ s << "TryExec=" << EscapeShell(QFile::encodeName(cExeDir() + cExeName())) << "\n";
+ s << "Exec=" << EscapeShell(QFile::encodeName(cExeDir() + cExeName())) << " -autostart\n";
+ s << "Icon=kotatogram\n";
+ s << "Terminal=false\n";
+ s << "StartupWMClass=" << QCoreApplication::instance()->applicationName() << "\n";
+ s << "Type=Application\n";
+ s << "Categories=Network;InstantMessaging;Qt;\n";
+ s << "MimeType=x-scheme-handler/tg;\n";
+ s << "Keywords=tg;chat;im;messaging;messenger;sms;tdesktop;\n";
+ s << "X-GNOME-UsesNotifications=true\n";
+ f.close();
+
+
+ if (RunShellCommand("desktop-file-install --dir=" + EscapeShell(QFile::encodeName(home + qsl(".config/autostart"))) + " --delete-original " + EscapeShell(QFile::encodeName(file)))) {
+ RunShellCommand("update-desktop-database " + EscapeShell(QFile::encodeName(home + qsl(".config/autostart"))));
+ }
+ } else {
+ LOG(("App Error: Could not open '%1' for write").arg(file));
+ }
+ }
+ }
+ } else {
+ QFile::remove(home + qsl(".config/autostart/kotatogramdesktop.desktop"));
+ }
}
void psSendToMenu(bool send, bool silent) {
diff --git a/Telegram/SourceFiles/settings/settings_advanced.cpp b/Telegram/SourceFiles/settings/settings_advanced.cpp
index 0a41abef7..529be612e 100644
--- a/Telegram/SourceFiles/settings/settings_advanced.cpp
+++ b/Telegram/SourceFiles/settings/settings_advanced.cpp
@@ -354,7 +354,7 @@ void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
}
#ifndef OS_WIN_STORE
- if (Platform::IsWindows()) {
+ if (Platform::IsWindows() || Platform::IsLinux()) {
const auto minimizedToggled = [] {
return cStartMinimized() && !Global::LocalPasscode();
};
@@ -365,9 +365,6 @@ void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
const auto minimized = addSlidingCheckbox(
tr::lng_settings_start_min(tr::now),
minimizedToggled());
- const auto sendto = addCheckbox(
- tr::ktg_settings_add_sendto(tr::now),
- cSendToMenu());
autostart->checkedChanges(
) | rpl::filter([](bool checked) {
@@ -404,6 +401,12 @@ void SetupTrayContent(not_null<Ui::VerticalLayout*> container) {
) | rpl::start_with_next([=] {
minimized->entity()->setChecked(minimizedToggled());
}, minimized->lifetime());
+ }
+
+ if (Platform::IsWindows()) {
+ const auto sendto = addCheckbox(
+ tr::ktg_settings_add_sendto(tr::now),
+ cSendToMenu());
sendto->checkedChanges(
) | rpl::filter([](bool checked) {
|