fix(linux): own icon stays, install to ~/.local/share/rusty-teams, update dialog reopens
- no Teams icon download from Microsoft's CDN, ADR 0013 dropped - binary installs to ~/.local/share/rusty-teams, menu icon written on install - update dialog opens again after the main window was closed - move falls back to copy without failing, % escaped in Exec Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@@ -89,7 +89,7 @@
89
89
| Platform | State |
90
90
|---|---|
91
91
| 🪟 Windows | Main target. Login through an embedded WebView2 |
92
| 🐧 Linux | Starts Google Chrome or Chromium on its own (debug port 9222, own profile in the XDG data folder) and keeps it headless in the background. When Teams asks for a login, the Chrome window shows itself and goes back to the background once you are signed in. `--endpoint` connects to a Chrome you started yourself instead. Color emoji use a bundled bitmap Noto Color Emoji font; a system COLRv1 face of the same name is left out of the font list. The window id is `rusty-teams`. On start the app offers to install itself to `~/.local/share/applications/teams/teams` (moved, or copied when started from a cargo `target` folder) and writes `~/.local/share/applications/rusty-teams.desktop`; starting a newer build offers to replace the installed one, and Settings > General can install, replace, remove or bring the question back. The installed copy of a release build looks for new GitHub releases (Settings > General > Automatic updates) and asks before it downloads and restarts. The Microsoft Teams icon is downloaded from Microsoft's CDN into `~/.local/share/icons/hicolor` instead of being shipped. Tray icon through StatusNotifierItem (KDE Plasma natively, GNOME with the AppIndicator extension); with "Close to tray" the window closes and the app keeps running in the tray, which opens a new window. Built-in login without Chrome is planned |
92
| 🐧 Linux | Starts Google Chrome or Chromium on its own (debug port 9222, own profile in the XDG data folder) and keeps it headless in the background. When Teams asks for a login, the Chrome window shows itself and goes back to the background once you are signed in. `--endpoint` connects to a Chrome you started yourself instead. Color emoji use a bundled bitmap Noto Color Emoji font; a system COLRv1 face of the same name is left out of the font list. The window id is `rusty-teams`. On start the app offers to install itself to `~/.local/share/rusty-teams/teams` (moved, or copied when started from a cargo `target` folder) and writes `~/.local/share/applications/rusty-teams.desktop`; starting a newer build offers to replace the installed one, and Settings > General can install, replace, remove or bring the question back. The installed copy of a release build looks for new GitHub releases (Settings > General > Automatic updates) and asks before it downloads and restarts. Tray icon through StatusNotifierItem (KDE Plasma natively, GNOME with the AppIndicator extension); with "Close to tray" the window closes and the app keeps running in the tray, which opens a new window. Built-in login without Chrome is planned |
93
93
| 🍎 macOS | Starts Google Chrome or Chromium on its own (debug port 9222, own profile under Application Support) and keeps it headless in the background. When Teams asks for a login, the Chrome window shows itself and goes back to the background once you are signed in. `--endpoint` connects to a Chrome you started yourself instead. Universal arm64 + x86_64 `.app` bundle. Screen share uses the ScreenCaptureKit system dialog |
94
94
95
95
The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).
@@ -89,7 +89,7 @@89
| Platform | State |89
| Platform | State |90
|---|---|90
|---|---|91
| 🪟 Windows | Main target. Login through an embedded WebView2 |91
| 🪟 Windows | Main target. Login through an embedded WebView2 |92
| 🐧 Linux | Starts Google Chrome or Chromium on its own (debug port 9222, own profile in the XDG data folder) and keeps it headless in the background. When Teams asks for a login, the Chrome window shows itself and goes back to the background once you are signed in. `--endpoint` connects to a Chrome you started yourself instead. Color emoji use a bundled bitmap Noto Color Emoji font; a system COLRv1 face of the same name is left out of the font list. The window id is `rusty-teams`. On start the app offers to install itself to `~/.local/share/applications/teams/teams` (moved, or copied when started from a cargo `target` folder) and writes `~/.local/share/applications/rusty-teams.desktop`; starting a newer build offers to replace the installed one, and Settings > General can install, replace, remove or bring the question back. The installed copy of a release build looks for new GitHub releases (Settings > General > Automatic updates) and asks before it downloads and restarts. The Microsoft Teams icon is downloaded from Microsoft's CDN into `~/.local/share/icons/hicolor` instead of being shipped. Tray icon through StatusNotifierItem (KDE Plasma natively, GNOME with the AppIndicator extension); with "Close to tray" the window closes and the app keeps running in the tray, which opens a new window. Built-in login without Chrome is planned |92
| 🐧 Linux | Starts Google Chrome or Chromium on its own (debug port 9222, own profile in the XDG data folder) and keeps it headless in the background. When Teams asks for a login, the Chrome window shows itself and goes back to the background once you are signed in. `--endpoint` connects to a Chrome you started yourself instead. Color emoji use a bundled bitmap Noto Color Emoji font; a system COLRv1 face of the same name is left out of the font list. The window id is `rusty-teams`. On start the app offers to install itself to `~/.local/share/rusty-teams/teams` (moved, or copied when started from a cargo `target` folder) and writes `~/.local/share/applications/rusty-teams.desktop`; starting a newer build offers to replace the installed one, and Settings > General can install, replace, remove or bring the question back. The installed copy of a release build looks for new GitHub releases (Settings > General > Automatic updates) and asks before it downloads and restarts. Tray icon through StatusNotifierItem (KDE Plasma natively, GNOME with the AppIndicator extension); with "Close to tray" the window closes and the app keeps running in the tray, which opens a new window. Built-in login without Chrome is planned |93
| 🍎 macOS | Starts Google Chrome or Chromium on its own (debug port 9222, own profile under Application Support) and keeps it headless in the background. When Teams asks for a login, the Chrome window shows itself and goes back to the background once you are signed in. `--endpoint` connects to a Chrome you started yourself instead. Universal arm64 + x86_64 `.app` bundle. Screen share uses the ScreenCaptureKit system dialog |93
| 🍎 macOS | Starts Google Chrome or Chromium on its own (debug port 9222, own profile under Application Support) and keeps it headless in the background. When Teams asks for a login, the Chrome window shows itself and goes back to the background once you are signed in. `--endpoint` connects to a Chrome you started yourself instead. Universal arm64 + x86_64 `.app` bundle. Screen share uses the ScreenCaptureKit system dialog |94
94
95
The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).95
The remaining gaps are planned, see [ROADMAP.md](ROADMAP.md).@@ -35,7 +35,7 @@ Feature parity with the Microsoft Teams desktop client.
35
35
| Start from the local cache, no spinner | Done | |
36
36
| Self-update | Done | |
37
37
| Tray icon, close to tray | Done | Linux: StatusNotifierItem tray (KDE, GNOME with AppIndicator); close really closes the window and the tray opens a new one, since GPUI cannot hide a Wayland window |
38
| Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/applications/teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |
38
| Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |
39
39
| Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |
40
40
| Single instance, second start brings the window to front | Done | |
41
41
| Sign in on macOS without starting Chrome by hand | Done | Same managed Chrome as on Linux, profile in Application Support |
@@ -35,7 +35,7 @@ Feature parity with the Microsoft Teams desktop client.35
| Start from the local cache, no spinner | Done | |35
| Start from the local cache, no spinner | Done | |36
| Self-update | Done | |36
| Self-update | Done | |37
| Tray icon, close to tray | Done | Linux: StatusNotifierItem tray (KDE, GNOME with AppIndicator); close really closes the window and the tray opens a new one, since GPUI cannot hide a Wayland window |37
| Tray icon, close to tray | Done | Linux: StatusNotifierItem tray (KDE, GNOME with AppIndicator); close really closes the window and the tray opens a new one, since GPUI cannot hide a Wayland window |38
| Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/applications/teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |38
| Linux install, menu entry and self-update | Done | Offers to install itself to `~/.local/share/rusty-teams` with a `.desktop` entry (Settings > General to install, replace, remove or ask again); the installed release build offers new GitHub releases in a dialog (download with progress, then Restart now); the Teams icon is downloaded from Microsoft, not shipped |39
| Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |39
| Sign in on Linux without starting Chrome by hand | Done | The app starts Chrome or Chromium headless with its own profile, shows the window for the login and hides it again afterwards; a watchdog restarts a dead or hung Chrome |40
| Single instance, second start brings the window to front | Done | |40
| Single instance, second start brings the window to front | Done | |41
| Sign in on macOS without starting Chrome by hand | Done | Same managed Chrome as on Linux, profile in Application Support |41
| Sign in on macOS without starting Chrome by hand | Done | Same managed Chrome as on Linux, profile in Application Support |@@ -12,29 +12,16 @@ pub const ZOOM_STEPS: [f32; 14] = [
12
12
];
13
13
pub const DEFAULT_ZOOM: f32 = 1.;
14
14
const RUSTY_TEAMS_ICON_PNG: &[u8] = include_bytes!("../../app/assets/icon/teams-fast-256.png");
15
// Linux builds leave the Microsoft logo out; the app downloads it from Microsoft
16
// on first start (see `linux_desktop`).
17
#[cfg(not(target_os = "linux"))]
18
15
const MICROSOFT_TEAMS_ICON_PNG: &[u8] =
19
16
include_bytes!("../../app/assets/icon/microsoft-teams-256.png");
20
17
21
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
18
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
22
19
pub enum AppIcon {
20
#[default]
23
21
RustyTeams,
24
22
MicrosoftTeams,
25
23
}
26
24
27
impl Default for AppIcon {
28
/// On Linux the downloaded Teams icon is the default once it is there.
29
fn default() -> Self {
30
#[cfg(target_os = "linux")]
31
if crate::linux_desktop::teams_icon().is_some() {
32
return AppIcon::MicrosoftTeams;
33
}
34
AppIcon::RustyTeams
35
}
36
}
37
38
25
impl AppIcon {
39
26
pub const ALL: [AppIcon; 2] = [AppIcon::RustyTeams, AppIcon::MicrosoftTeams];
40
27
@@ -59,12 +46,7 @@ impl AppIcon {
59
46
pub fn png(self) -> &'static [u8] {
60
47
match self {
61
48
AppIcon::RustyTeams => RUSTY_TEAMS_ICON_PNG,
62
#[cfg(not(target_os = "linux"))]
63
49
AppIcon::MicrosoftTeams => MICROSOFT_TEAMS_ICON_PNG,
64
#[cfg(target_os = "linux")]
65
AppIcon::MicrosoftTeams => {
66
crate::linux_desktop::teams_icon().unwrap_or(RUSTY_TEAMS_ICON_PNG)
67
}
68
50
}
69
51
}
70
52
}
@@ -208,16 +190,6 @@ pub fn load(store: &Store) -> AppearanceSettings {
208
190
.unwrap_or_default()
209
191
}
210
192
211
/// Whether an icon was ever saved, by the user or by an earlier default.
212
pub fn icon_saved(store: &Store) -> bool {
213
store.meta(META_KEY).ok().flatten().is_some_and(|text| {
214
text.lines().any(|line| {
215
line.split_once('=')
216
.is_some_and(|(key, _)| key == APP_ICON_KEY)
217
})
218
})
219
}
220
221
193
pub fn save(store: &Store, settings: &AppearanceSettings) {
222
194
let _ = store.set_meta(META_KEY, &serialize(settings));
223
195
}
@@ -12,29 +12,16 @@ pub const ZOOM_STEPS: [f32; 14] = [12
];12
];13
pub const DEFAULT_ZOOM: f32 = 1.;13
pub const DEFAULT_ZOOM: f32 = 1.;14
const RUSTY_TEAMS_ICON_PNG: &[u8] = include_bytes!("../../app/assets/icon/teams-fast-256.png");14
const RUSTY_TEAMS_ICON_PNG: &[u8] = include_bytes!("../../app/assets/icon/teams-fast-256.png");15
// Linux builds leave the Microsoft logo out; the app downloads it from Microsoft16
// on first start (see `linux_desktop`).17
#[cfg(not(target_os = "linux"))]18
const MICROSOFT_TEAMS_ICON_PNG: &[u8] =15
const MICROSOFT_TEAMS_ICON_PNG: &[u8] =19
include_bytes!("../../app/assets/icon/microsoft-teams-256.png");16
include_bytes!("../../app/assets/icon/microsoft-teams-256.png");20
17
21
#[derive(Debug, Clone, Copy, PartialEq, Eq)]18
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]22
pub enum AppIcon {19
pub enum AppIcon {20
#[default]23
RustyTeams,21
RustyTeams,24
MicrosoftTeams,22
MicrosoftTeams,25
}23
}26
24
27
impl Default for AppIcon {28
/// On Linux the downloaded Teams icon is the default once it is there.29
fn default() -> Self {30
#[cfg(target_os = "linux")]31
if crate::linux_desktop::teams_icon().is_some() {32
return AppIcon::MicrosoftTeams;33
}34
AppIcon::RustyTeams35
}36
}37
38
impl AppIcon {25
impl AppIcon {39
pub const ALL: [AppIcon; 2] = [AppIcon::RustyTeams, AppIcon::MicrosoftTeams];26
pub const ALL: [AppIcon; 2] = [AppIcon::RustyTeams, AppIcon::MicrosoftTeams];40
27
@@ -59,12 +46,7 @@ impl AppIcon {59
pub fn png(self) -> &'static [u8] {46
pub fn png(self) -> &'static [u8] {60
match self {47
match self {61
AppIcon::RustyTeams => RUSTY_TEAMS_ICON_PNG,48
AppIcon::RustyTeams => RUSTY_TEAMS_ICON_PNG,62
#[cfg(not(target_os = "linux"))]63
AppIcon::MicrosoftTeams => MICROSOFT_TEAMS_ICON_PNG,49
AppIcon::MicrosoftTeams => MICROSOFT_TEAMS_ICON_PNG,64
#[cfg(target_os = "linux")]65
AppIcon::MicrosoftTeams => {66
crate::linux_desktop::teams_icon().unwrap_or(RUSTY_TEAMS_ICON_PNG)67
}68
}50
}69
}51
}70
}52
}@@ -208,16 +190,6 @@ pub fn load(store: &Store) -> AppearanceSettings {208
.unwrap_or_default()190
.unwrap_or_default()209
}191
}210
192
211
/// Whether an icon was ever saved, by the user or by an earlier default.212
pub fn icon_saved(store: &Store) -> bool {213
store.meta(META_KEY).ok().flatten().is_some_and(|text| {214
text.lines().any(|line| {215
line.split_once('=')216
.is_some_and(|(key, _)| key == APP_ICON_KEY)217
})218
})219
}220
221
pub fn save(store: &Store, settings: &AppearanceSettings) {193
pub fn save(store: &Store, settings: &AppearanceSettings) {222
let _ = store.set_meta(META_KEY, &serialize(settings));194
let _ = store.set_meta(META_KEY, &serialize(settings));223
}195
}@@ -1,28 +1,18 @@
1
//! Desktop integration on Linux: the install folder
2
//! (`~/.local/share/applications/teams`), the `.desktop` entry and the Teams icon,
3
//! which is downloaded from Microsoft instead of shipped.
1
//! Desktop integration on Linux: the install folder (`~/.local/share/rusty-teams`),
2
//! the `.desktop` entry and the menu icon.
4
3
5
4
use std::fs;
6
5
use std::io;
7
6
use std::path::{Path, PathBuf};
8
use std::sync::RwLock;
9
10
use futures_util::AsyncReadExt as _;
11
use gpui_kit::{App, Task};
12
7
13
8
/// Matches the window's app id, so KDE pairs the window with the entry.
14
9
pub const DESKTOP_ID: &str = "rusty-teams";
15
10
/// Name the `.desktop` entry, the tray and `hicolor` use for the icon.
16
11
pub const ICON_NAME: &str = "rusty-teams";
17
12
pub const BINARY_FILE_NAME: &str = "teams";
18
/// Same icon the Teams web page shows in its tab.
19
pub const TEAMS_ICON_URL: &str = "https://teams.public.onecdn.static.microsoft/evergreen-assets/icons/microsoft_teams_logo_refresh_v2025.ico";
20
/// Fallback when [`TEAMS_ICON_URL`] moves: the page names its current favicon.
21
pub const TEAMS_PAGE_URL: &str = "https://teams.cloud.microsoft/";
22
13
pub const ICON_SIZES: [u32; 5] = [256, 128, 64, 48, 32];
23
const INSTALL_FOLDER: &str = "teams";
14
const INSTALL_FOLDER: &str = "rusty-teams";
24
15
const DONT_ASK_META_KEY: &str = "linux.install.dont_ask";
25
const FAVICON_ID: &str = "id=\"teams-favicon\"";
26
16
27
17
/// Cargo marks its target folder with `CACHEDIR.TAG`; a binary in
28
18
/// `target/<profile>/` is build output and is copied, not moved, on install.
@@ -55,7 +45,7 @@ impl Layout {
55
45
}
56
46
57
47
pub fn install_dir(&self) -> PathBuf {
58
self.applications_dir().join(INSTALL_FOLDER)
48
self.data_dir.join(INSTALL_FOLDER)
59
49
}
60
50
61
51
pub fn installed_binary(&self) -> PathBuf {
@@ -108,8 +98,8 @@ pub fn ask_again(store: &store::Store) {
108
98
let _ = store.set_meta(DONT_ASK_META_KEY, "0");
109
99
}
110
100
111
/// Removes the menu entry and the installed binary (with a staged update). Sign-in,
112
/// cache and the downloaded icon stay. A running installed copy keeps running.
101
/// Removes the menu entry and the installed binary (with a staged update). Sign-in
102
/// and cache stay. A running installed copy keeps running.
113
103
pub fn uninstall(layout: &Layout) -> io::Result<()> {
114
104
let remove = |path: PathBuf| match fs::remove_file(&path) {
115
105
Err(error) if error.kind() != io::ErrorKind::NotFound => Err(error),
@@ -142,6 +132,7 @@ pub fn install_binary(executable: &Path, layout: &Layout) -> io::Result<PathBuf>
142
132
}
143
133
}
144
134
make_executable(&target)?;
135
install_icon(layout, crate::appearance::AppIcon::RustyTeams.png()).map_err(io::Error::other)?;
145
136
write_desktop_entry(layout, &target)?;
146
137
refresh_desktop_caches(layout);
147
138
Ok(target)
@@ -153,7 +144,8 @@ fn move_file(from: &Path, to: &Path) -> io::Result<()> {
153
144
return Ok(());
154
145
}
155
146
copy_file(from, to)?;
156
fs::remove_file(from)
147
let _ = fs::remove_file(from);
148
Ok(())
157
149
}
158
150
159
151
/// Copies through a temporary file and renames it into place, so a running older
@@ -180,6 +172,9 @@ fn exec_quoted(path: &Path) -> String {
180
172
if matches!(character, '"' | '`' | '$' | '\\') {
181
173
quoted.push('\\');
182
174
}
175
if character == '%' {
176
quoted.push('%');
177
}
183
178
quoted.push(character);
184
179
}
185
180
quoted.push('"');
@@ -235,8 +230,7 @@ pub fn refresh_desktop_caches(layout: &Layout) {
235
230
});
236
231
}
237
232
238
/// Writes the Teams icon into `hicolor` in every size of [`ICON_SIZES`].
239
/// `bytes` is an `.ico` or a `.png`.
233
/// Writes the menu icon into `hicolor` in every size of [`ICON_SIZES`].
240
234
pub fn install_icon(layout: &Layout, bytes: &[u8]) -> Result<(), String> {
241
235
let decoded = image::load_from_memory(bytes).map_err(|error| error.to_string())?;
242
236
for size in ICON_SIZES {
@@ -256,87 +250,6 @@ pub fn install_icon(layout: &Layout, bytes: &[u8]) -> Result<(), String> {
256
250
Ok(())
257
251
}
258
252
259
pub fn has_icon(layout: &Layout) -> bool {
260
layout.largest_icon().is_file()
261
}
262
263
/// The `href` of `<link id="teams-favicon" ...>` in the Teams page.
264
pub fn favicon_url(html: &str) -> Option<String> {
265
let start = html.find(FAVICON_ID)?;
266
let tag_start = html[..start].rfind('<')?;
267
let tag_end = start + html[start..].find('>')?;
268
let tag = &html[tag_start..tag_end];
269
let href = tag.find("href=\"")? + "href=\"".len();
270
let length = tag[href..].find('"')?;
271
let url = &tag[href..href + length];
272
url.starts_with("https://").then(|| url.to_owned())
273
}
274
275
/// Downloads the Teams icon into `hicolor` and returns the 256 px PNG.
276
pub fn download_icon(layout: Layout, cx: &App) -> Task<Result<Vec<u8>, String>> {
277
let client = cx.http_client();
278
cx.background_executor().spawn(async move {
279
let get = |url: String| {
280
let client = client.clone();
281
async move {
282
let mut response = client
283
.get(&url, ().into(), true)
284
.await
285
.map_err(|error| error.to_string())?;
286
let mut body = Vec::new();
287
response
288
.body_mut()
289
.read_to_end(&mut body)
290
.await
291
.map_err(|error| error.to_string())?;
292
if !response.status().is_success() {
293
return Err(format!("{url}: status {}", response.status()));
294
}
295
Ok::<_, String>(body)
296
}
297
};
298
let bytes = match get(TEAMS_ICON_URL.to_owned()).await {
299
Ok(bytes) => bytes,
300
Err(first) => {
301
let page = get(TEAMS_PAGE_URL.to_owned()).await?;
302
let url = favicon_url(&String::from_utf8_lossy(&page))
303
.ok_or_else(|| format!("{first}; no favicon on the Teams page"))?;
304
get(url).await?
305
}
306
};
307
install_icon(&layout, &bytes)?;
308
refresh_desktop_caches(&layout);
309
fs::read(layout.largest_icon()).map_err(|error| error.to_string())
310
})
311
}
312
313
static TEAMS_ICON: RwLock<Option<&'static [u8]>> = RwLock::new(None);
314
315
/// The downloaded Teams icon as PNG, once it is on disk.
316
pub fn teams_icon() -> Option<&'static [u8]> {
317
*TEAMS_ICON
318
.read()
319
.unwrap_or_else(|poisoned| poisoned.into_inner())
320
}
321
322
pub fn set_teams_icon(png: Vec<u8>) {
323
if !png.starts_with(b"\x89PNG") {
324
return;
325
}
326
let mut slot = TEAMS_ICON
327
.write()
328
.unwrap_or_else(|poisoned| poisoned.into_inner());
329
// Set once or twice per run (start and after a download); the leak is bounded.
330
*slot = Some(Box::leak(png.into_boxed_slice()));
331
}
332
333
/// Loads the icon a previous run downloaded.
334
pub fn load_teams_icon(layout: &Layout) {
335
if let Ok(png) = fs::read(layout.largest_icon()) {
336
set_teams_icon(png);
337
}
338
}
339
340
253
#[cfg(test)]
341
254
mod tests {
342
255
use super::*;
@@ -355,7 +268,7 @@ mod tests {
355
268
let layout = Layout::new("/home/a/.local/share");
356
269
assert_eq!(
357
270
layout.installed_binary(),
358
Path::new("/home/a/.local/share/applications/teams/teams")
271
Path::new("/home/a/.local/share/rusty-teams/teams")
359
272
);
360
273
assert_eq!(
361
274
layout.desktop_file(),
@@ -459,27 +372,11 @@ mod tests {
459
372
fn the_icon_lands_in_every_size() {
460
373
let home = tempfile::tempdir().unwrap();
461
374
let layout = Layout::new(home.path());
462
assert!(!has_icon(&layout));
463
375
install_icon(&layout, &png(300)).unwrap();
464
376
for size in ICON_SIZES {
465
377
let written = image::open(layout.icon_file(size)).unwrap();
466
378
assert_eq!((written.width(), written.height()), (size, size));
467
379
}
468
assert!(has_icon(&layout));
469
380
assert!(install_icon(&layout, b"not an image").is_err());
470
381
}
471
472
#[test]
473
fn the_favicon_comes_from_the_teams_page() {
474
let html = r#"<head><link rel="shortcut icon" type="image/x-icon" id="teams-favicon" href="https://cdn.example/icons/teams.ico"/></head>"#;
475
assert_eq!(
476
favicon_url(html).as_deref(),
477
Some("https://cdn.example/icons/teams.ico")
478
);
479
assert_eq!(favicon_url("<html></html>"), None);
480
assert_eq!(
481
favicon_url(r#"<link id="teams-favicon" href="http://insecure/x.ico">"#),
482
None
483
);
484
}
485
382
}
@@ -1,28 +1,18 @@1
//! Desktop integration on Linux: the install folder1
//! Desktop integration on Linux: the install folder (`~/.local/share/rusty-teams`),2
//! (`~/.local/share/applications/teams`), the `.desktop` entry and the Teams icon,2
//! the `.desktop` entry and the menu icon.3
//! which is downloaded from Microsoft instead of shipped.4
3
5
use std::fs;4
use std::fs;6
use std::io;5
use std::io;7
use std::path::{Path, PathBuf};6
use std::path::{Path, PathBuf};8
use std::sync::RwLock;9
10
use futures_util::AsyncReadExt as _;11
use gpui_kit::{App, Task};12
7
13
/// Matches the window's app id, so KDE pairs the window with the entry.8
/// Matches the window's app id, so KDE pairs the window with the entry.14
pub const DESKTOP_ID: &str = "rusty-teams";9
pub const DESKTOP_ID: &str = "rusty-teams";15
/// Name the `.desktop` entry, the tray and `hicolor` use for the icon.10
/// Name the `.desktop` entry, the tray and `hicolor` use for the icon.16
pub const ICON_NAME: &str = "rusty-teams";11
pub const ICON_NAME: &str = "rusty-teams";17
pub const BINARY_FILE_NAME: &str = "teams";12
pub const BINARY_FILE_NAME: &str = "teams";18
/// Same icon the Teams web page shows in its tab.19
pub const TEAMS_ICON_URL: &str = "https://teams.public.onecdn.static.microsoft/evergreen-assets/icons/microsoft_teams_logo_refresh_v2025.ico";20
/// Fallback when [`TEAMS_ICON_URL`] moves: the page names its current favicon.21
pub const TEAMS_PAGE_URL: &str = "https://teams.cloud.microsoft/";22
pub const ICON_SIZES: [u32; 5] = [256, 128, 64, 48, 32];13
pub const ICON_SIZES: [u32; 5] = [256, 128, 64, 48, 32];23
const INSTALL_FOLDER: &str = "teams";14
const INSTALL_FOLDER: &str = "rusty-teams";24
const DONT_ASK_META_KEY: &str = "linux.install.dont_ask";15
const DONT_ASK_META_KEY: &str = "linux.install.dont_ask";25
const FAVICON_ID: &str = "id=\"teams-favicon\"";26
16
27
/// Cargo marks its target folder with `CACHEDIR.TAG`; a binary in17
/// Cargo marks its target folder with `CACHEDIR.TAG`; a binary in28
/// `target/<profile>/` is build output and is copied, not moved, on install.18
/// `target/<profile>/` is build output and is copied, not moved, on install.@@ -55,7 +45,7 @@ impl Layout {55
}45
}56
46
57
pub fn install_dir(&self) -> PathBuf {47
pub fn install_dir(&self) -> PathBuf {58
self.applications_dir().join(INSTALL_FOLDER)48
self.data_dir.join(INSTALL_FOLDER)59
}49
}60
50
61
pub fn installed_binary(&self) -> PathBuf {51
pub fn installed_binary(&self) -> PathBuf {@@ -108,8 +98,8 @@ pub fn ask_again(store: &store::Store) {108
let _ = store.set_meta(DONT_ASK_META_KEY, "0");98
let _ = store.set_meta(DONT_ASK_META_KEY, "0");109
}99
}110
100
111
/// Removes the menu entry and the installed binary (with a staged update). Sign-in,101
/// Removes the menu entry and the installed binary (with a staged update). Sign-in112
/// cache and the downloaded icon stay. A running installed copy keeps running.102
/// and cache stay. A running installed copy keeps running.113
pub fn uninstall(layout: &Layout) -> io::Result<()> {103
pub fn uninstall(layout: &Layout) -> io::Result<()> {114
let remove = |path: PathBuf| match fs::remove_file(&path) {104
let remove = |path: PathBuf| match fs::remove_file(&path) {115
Err(error) if error.kind() != io::ErrorKind::NotFound => Err(error),105
Err(error) if error.kind() != io::ErrorKind::NotFound => Err(error),@@ -142,6 +132,7 @@ pub fn install_binary(executable: &Path, layout: &Layout) -> io::Result<PathBuf>142
}132
}143
}133
}144
make_executable(&target)?;134
make_executable(&target)?;135
install_icon(layout, crate::appearance::AppIcon::RustyTeams.png()).map_err(io::Error::other)?;145
write_desktop_entry(layout, &target)?;136
write_desktop_entry(layout, &target)?;146
refresh_desktop_caches(layout);137
refresh_desktop_caches(layout);147
Ok(target)138
Ok(target)@@ -153,7 +144,8 @@ fn move_file(from: &Path, to: &Path) -> io::Result<()> {153
return Ok(());144
return Ok(());154
}145
}155
copy_file(from, to)?;146
copy_file(from, to)?;156
fs::remove_file(from)147
let _ = fs::remove_file(from);148
Ok(())157
}149
}158
150
159
/// Copies through a temporary file and renames it into place, so a running older151
/// Copies through a temporary file and renames it into place, so a running older@@ -180,6 +172,9 @@ fn exec_quoted(path: &Path) -> String {180
if matches!(character, '"' | '`' | '$' | '\\') {172
if matches!(character, '"' | '`' | '$' | '\\') {181
quoted.push('\\');173
quoted.push('\\');182
}174
}175
if character == '%' {176
quoted.push('%');177
}183
quoted.push(character);178
quoted.push(character);184
}179
}185
quoted.push('"');180
quoted.push('"');@@ -235,8 +230,7 @@ pub fn refresh_desktop_caches(layout: &Layout) {235
});230
});236
}231
}237
232
238
/// Writes the Teams icon into `hicolor` in every size of [`ICON_SIZES`].233
/// Writes the menu icon into `hicolor` in every size of [`ICON_SIZES`].239
/// `bytes` is an `.ico` or a `.png`.240
pub fn install_icon(layout: &Layout, bytes: &[u8]) -> Result<(), String> {234
pub fn install_icon(layout: &Layout, bytes: &[u8]) -> Result<(), String> {241
let decoded = image::load_from_memory(bytes).map_err(|error| error.to_string())?;235
let decoded = image::load_from_memory(bytes).map_err(|error| error.to_string())?;242
for size in ICON_SIZES {236
for size in ICON_SIZES {@@ -256,87 +250,6 @@ pub fn install_icon(layout: &Layout, bytes: &[u8]) -> Result<(), String> {256
Ok(())250
Ok(())257
}251
}258
252
259
pub fn has_icon(layout: &Layout) -> bool {260
layout.largest_icon().is_file()261
}262
263
/// The `href` of `<link id="teams-favicon" ...>` in the Teams page.264
pub fn favicon_url(html: &str) -> Option<String> {265
let start = html.find(FAVICON_ID)?;266
let tag_start = html[..start].rfind('<')?;267
let tag_end = start + html[start..].find('>')?;268
let tag = &html[tag_start..tag_end];269
let href = tag.find("href=\"")? + "href=\"".len();270
let length = tag[href..].find('"')?;271
let url = &tag[href..href + length];272
url.starts_with("https://").then(|| url.to_owned())273
}274
275
/// Downloads the Teams icon into `hicolor` and returns the 256 px PNG.276
pub fn download_icon(layout: Layout, cx: &App) -> Task<Result<Vec<u8>, String>> {277
let client = cx.http_client();278
cx.background_executor().spawn(async move {279
let get = |url: String| {280
let client = client.clone();281
async move {282
let mut response = client283
.get(&url, ().into(), true)284
.await285
.map_err(|error| error.to_string())?;286
let mut body = Vec::new();287
response288
.body_mut()289
.read_to_end(&mut body)290
.await291
.map_err(|error| error.to_string())?;292
if !response.status().is_success() {293
return Err(format!("{url}: status {}", response.status()));294
}295
Ok::<_, String>(body)296
}297
};298
let bytes = match get(TEAMS_ICON_URL.to_owned()).await {299
Ok(bytes) => bytes,300
Err(first) => {301
let page = get(TEAMS_PAGE_URL.to_owned()).await?;302
let url = favicon_url(&String::from_utf8_lossy(&page))303
.ok_or_else(|| format!("{first}; no favicon on the Teams page"))?;304
get(url).await?305
}306
};307
install_icon(&layout, &bytes)?;308
refresh_desktop_caches(&layout);309
fs::read(layout.largest_icon()).map_err(|error| error.to_string())310
})311
}312
313
static TEAMS_ICON: RwLock<Option<&'static [u8]>> = RwLock::new(None);314
315
/// The downloaded Teams icon as PNG, once it is on disk.316
pub fn teams_icon() -> Option<&'static [u8]> {317
*TEAMS_ICON318
.read()319
.unwrap_or_else(|poisoned| poisoned.into_inner())320
}321
322
pub fn set_teams_icon(png: Vec<u8>) {323
if !png.starts_with(b"\x89PNG") {324
return;325
}326
let mut slot = TEAMS_ICON327
.write()328
.unwrap_or_else(|poisoned| poisoned.into_inner());329
// Set once or twice per run (start and after a download); the leak is bounded.330
*slot = Some(Box::leak(png.into_boxed_slice()));331
}332
333
/// Loads the icon a previous run downloaded.334
pub fn load_teams_icon(layout: &Layout) {335
if let Ok(png) = fs::read(layout.largest_icon()) {336
set_teams_icon(png);337
}338
}339
340
#[cfg(test)]253
#[cfg(test)]341
mod tests {254
mod tests {342
use super::*;255
use super::*;@@ -355,7 +268,7 @@ mod tests {355
let layout = Layout::new("/home/a/.local/share");268
let layout = Layout::new("/home/a/.local/share");356
assert_eq!(269
assert_eq!(357
layout.installed_binary(),270
layout.installed_binary(),358
Path::new("/home/a/.local/share/applications/teams/teams")271
Path::new("/home/a/.local/share/rusty-teams/teams")359
);272
);360
assert_eq!(273
assert_eq!(361
layout.desktop_file(),274
layout.desktop_file(),@@ -459,27 +372,11 @@ mod tests {459
fn the_icon_lands_in_every_size() {372
fn the_icon_lands_in_every_size() {460
let home = tempfile::tempdir().unwrap();373
let home = tempfile::tempdir().unwrap();461
let layout = Layout::new(home.path());374
let layout = Layout::new(home.path());462
assert!(!has_icon(&layout));463
install_icon(&layout, &png(300)).unwrap();375
install_icon(&layout, &png(300)).unwrap();464
for size in ICON_SIZES {376
for size in ICON_SIZES {465
let written = image::open(layout.icon_file(size)).unwrap();377
let written = image::open(layout.icon_file(size)).unwrap();466
assert_eq!((written.width(), written.height()), (size, size));378
assert_eq!((written.width(), written.height()), (size, size));467
}379
}468
assert!(has_icon(&layout));469
assert!(install_icon(&layout, b"not an image").is_err());380
assert!(install_icon(&layout, b"not an image").is_err());470
}381
}471
472
#[test]473
fn the_favicon_comes_from_the_teams_page() {474
let html = r#"<head><link rel="shortcut icon" type="image/x-icon" id="teams-favicon" href="https://cdn.example/icons/teams.ico"/></head>"#;475
assert_eq!(476
favicon_url(html).as_deref(),477
Some("https://cdn.example/icons/teams.ico")478
);479
assert_eq!(favicon_url("<html></html>"), None);480
assert_eq!(481
favicon_url(r#"<link id="teams-favicon" href="http://insecure/x.ico">"#),482
None483
);484
}485
}382
}@@ -261,7 +261,7 @@ mod platform {
261
261
}
262
262
263
263
/// Whether this build may replace itself from GitHub releases. On Linux only the copy
264
/// installed in `~/.local/share/applications/teams` updates; a binary run from a
264
/// installed in `~/.local/share/rusty-teams` updates; a binary run from a
265
265
/// build folder or a package location is left alone.
266
266
pub fn self_update_allowed() -> bool {
267
267
#[cfg(target_os = "linux")]
@@ -261,7 +261,7 @@ mod platform {261
}261
}262
262
263
/// Whether this build may replace itself from GitHub releases. On Linux only the copy263
/// Whether this build may replace itself from GitHub releases. On Linux only the copy264
/// installed in `~/.local/share/applications/teams` updates; a binary run from a264
/// installed in `~/.local/share/rusty-teams` updates; a binary run from a265
/// build folder or a package location is left alone.265
/// build folder or a package location is left alone.266
pub fn self_update_allowed() -> bool {266
pub fn self_update_allowed() -> bool {267
#[cfg(target_os = "linux")]267
#[cfg(target_os = "linux")]@@ -1,6 +1,5 @@
1
1
//! Linux desktop integration on start: offer to install the binary into
2
//! `~/.local/share/applications/teams` with a menu entry, and fetch the Teams icon
3
//! from Microsoft (it is not shipped with the app).
2
//! `~/.local/share/rusty-teams` with a menu entry.
4
3
5
4
use std::collections::HashMap;
6
5
use std::path::{Path, PathBuf};
@@ -12,26 +11,15 @@ use gpui_kit::component::{WindowExt as _, v_flex};
12
11
use gpui_kit::*;
13
12
14
13
use crate::app_state::AppHandle;
15
use crate::appearance::AppIcon;
16
14
use crate::i18n::{tr, tr_args};
17
15
use crate::theme;
18
16
19
17
const DIALOG_WIDTH: f32 = 460.;
20
18
21
/// Loads an icon a previous run downloaded, before the first window picks its icon.
22
pub fn load_icon() {
23
if let Some(layout) = Layout::current() {
24
linux_desktop::load_teams_icon(&layout);
25
}
26
}
27
28
19
pub fn start(cx: &mut App) {
29
20
let (Ok(executable), Some(layout)) = (std::env::current_exe(), Layout::current()) else {
30
21
return;
31
22
};
32
if !linux_desktop::has_icon(&layout) {
33
download_icon(layout.clone(), cx);
34
}
35
23
if linux_desktop::is_installed(&executable, &layout) {
36
24
// Keeps the menu entry pointing at this file, e.g. after it was deleted by hand.
37
25
if !layout.desktop_file().is_file()
@@ -50,28 +38,6 @@ pub fn start(cx: &mut App) {
50
38
}
51
39
}
52
40
53
fn download_icon(layout: Layout, cx: &mut App) {
54
let download = linux_desktop::download_icon(layout, cx);
55
cx.spawn(async move |cx| match download.await {
56
Ok(png) => {
57
linux_desktop::set_teams_icon(png);
58
cx.update(|cx| {
59
// First run: the Teams icon becomes the default unless one was chosen.
60
if let Some(store) = cx
61
.try_global::<AppHandle>()
62
.map(|handle| handle.0.read(cx).store.clone())
63
&& !crate::appearance::icon_saved(&store)
64
{
65
crate::active_appearance::set_app_icon(AppIcon::MicrosoftTeams, &store, cx);
66
}
67
crate::views::shell::refresh_app_icon(cx);
68
});
69
}
70
Err(error) => log::warn!("Teams icon download failed: {error}"),
71
})
72
.detach();
73
}
74
75
41
fn offer_install(executable: PathBuf, layout: Layout, cx: &mut App) {
76
42
let Some(window) = crate::main_window::current(cx) else {
77
43
return;
@@ -149,7 +115,7 @@ fn notice(text: String, cx: &mut App) {
149
115
}
150
116
}
151
117
152
/// Where this process stands relative to `~/.local/share/applications/teams`.
118
/// Where this process stands relative to the install folder.
153
119
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
154
120
pub enum Installation {
155
121
/// This process is the installed copy.
@@ -1,6 +1,5 @@1
//! Linux desktop integration on start: offer to install the binary into1
//! Linux desktop integration on start: offer to install the binary into2
//! `~/.local/share/applications/teams` with a menu entry, and fetch the Teams icon2
//! `~/.local/share/rusty-teams` with a menu entry.3
//! from Microsoft (it is not shipped with the app).4
3
5
use std::collections::HashMap;4
use std::collections::HashMap;6
use std::path::{Path, PathBuf};5
use std::path::{Path, PathBuf};@@ -12,26 +11,15 @@ use gpui_kit::component::{WindowExt as _, v_flex};12
use gpui_kit::*;11
use gpui_kit::*;13
12
14
use crate::app_state::AppHandle;13
use crate::app_state::AppHandle;15
use crate::appearance::AppIcon;16
use crate::i18n::{tr, tr_args};14
use crate::i18n::{tr, tr_args};17
use crate::theme;15
use crate::theme;18
16
19
const DIALOG_WIDTH: f32 = 460.;17
const DIALOG_WIDTH: f32 = 460.;20
18
21
/// Loads an icon a previous run downloaded, before the first window picks its icon.22
pub fn load_icon() {23
if let Some(layout) = Layout::current() {24
linux_desktop::load_teams_icon(&layout);25
}26
}27
28
pub fn start(cx: &mut App) {19
pub fn start(cx: &mut App) {29
let (Ok(executable), Some(layout)) = (std::env::current_exe(), Layout::current()) else {20
let (Ok(executable), Some(layout)) = (std::env::current_exe(), Layout::current()) else {30
return;21
return;31
};22
};32
if !linux_desktop::has_icon(&layout) {33
download_icon(layout.clone(), cx);34
}35
if linux_desktop::is_installed(&executable, &layout) {23
if linux_desktop::is_installed(&executable, &layout) {36
// Keeps the menu entry pointing at this file, e.g. after it was deleted by hand.24
// Keeps the menu entry pointing at this file, e.g. after it was deleted by hand.37
if !layout.desktop_file().is_file()25
if !layout.desktop_file().is_file()@@ -50,28 +38,6 @@ pub fn start(cx: &mut App) {50
}38
}51
}39
}52
40
53
fn download_icon(layout: Layout, cx: &mut App) {54
let download = linux_desktop::download_icon(layout, cx);55
cx.spawn(async move |cx| match download.await {56
Ok(png) => {57
linux_desktop::set_teams_icon(png);58
cx.update(|cx| {59
// First run: the Teams icon becomes the default unless one was chosen.60
if let Some(store) = cx61
.try_global::<AppHandle>()62
.map(|handle| handle.0.read(cx).store.clone())63
&& !crate::appearance::icon_saved(&store)64
{65
crate::active_appearance::set_app_icon(AppIcon::MicrosoftTeams, &store, cx);66
}67
crate::views::shell::refresh_app_icon(cx);68
});69
}70
Err(error) => log::warn!("Teams icon download failed: {error}"),71
})72
.detach();73
}74
75
fn offer_install(executable: PathBuf, layout: Layout, cx: &mut App) {41
fn offer_install(executable: PathBuf, layout: Layout, cx: &mut App) {76
let Some(window) = crate::main_window::current(cx) else {42
let Some(window) = crate::main_window::current(cx) else {77
return;43
return;@@ -149,7 +115,7 @@ fn notice(text: String, cx: &mut App) {149
}115
}150
}116
}151
117
152
/// Where this process stands relative to `~/.local/share/applications/teams`.118
/// Where this process stands relative to the install folder.153
#[derive(Debug, Clone, Copy, PartialEq, Eq)]119
#[derive(Debug, Clone, Copy, PartialEq, Eq)]154
pub enum Installation {120
pub enum Installation {155
/// This process is the installed copy.121
/// This process is the installed copy.@@ -40,7 +40,7 @@ enum Stage {
40
40
41
41
struct LinuxUpdates {
42
42
stage: Stage,
43
dialog_open: bool,
43
dialog_window: Option<WindowId>,
44
44
/// "Not now" holds for this run only; the next start asks again.
45
45
declined: Option<String>,
46
46
}
@@ -125,7 +125,7 @@ fn ensure_state(cx: &mut App) {
125
125
if !cx.has_global::<LinuxUpdates>() {
126
126
cx.set_global(LinuxUpdates {
127
127
stage: Stage::Idle,
128
dialog_open: false,
128
dialog_window: None,
129
129
declined: None,
130
130
});
131
131
}
@@ -273,21 +273,23 @@ fn open_dialog(cx: &mut App) {
273
273
let Some(window) = crate::main_window::current(cx) else {
274
274
return;
275
275
};
276
if !cx.has_global::<LinuxUpdates>() || cx.global::<LinuxUpdates>().dialog_open {
276
if !cx.has_global::<LinuxUpdates>()
277
|| cx.global::<LinuxUpdates>().dialog_window == Some(window.window_id())
278
{
277
279
return;
278
280
}
279
cx.global_mut::<LinuxUpdates>().dialog_open = true;
281
cx.global_mut::<LinuxUpdates>().dialog_window = Some(window.window_id());
280
282
let opened = window.update(cx, |_, window, cx| {
281
283
window.open_dialog(cx, |dialog: Dialog, _, cx| build_dialog(dialog, cx));
282
284
});
283
285
if opened.is_err() {
284
cx.global_mut::<LinuxUpdates>().dialog_open = false;
286
cx.global_mut::<LinuxUpdates>().dialog_window = None;
285
287
}
286
288
}
287
289
288
290
fn close_dialog(window: &mut Window, cx: &mut App) {
289
291
if cx.has_global::<LinuxUpdates>() {
290
cx.global_mut::<LinuxUpdates>().dialog_open = false;
292
cx.global_mut::<LinuxUpdates>().dialog_window = None;
291
293
}
292
294
window.close_dialog(cx);
293
295
}
@@ -40,7 +40,7 @@ enum Stage {40
40
41
struct LinuxUpdates {41
struct LinuxUpdates {42
stage: Stage,42
stage: Stage,43
dialog_open: bool,43
dialog_window: Option<WindowId>,44
/// "Not now" holds for this run only; the next start asks again.44
/// "Not now" holds for this run only; the next start asks again.45
declined: Option<String>,45
declined: Option<String>,46
}46
}@@ -125,7 +125,7 @@ fn ensure_state(cx: &mut App) {125
if !cx.has_global::<LinuxUpdates>() {125
if !cx.has_global::<LinuxUpdates>() {126
cx.set_global(LinuxUpdates {126
cx.set_global(LinuxUpdates {127
stage: Stage::Idle,127
stage: Stage::Idle,128
dialog_open: false,128
dialog_window: None,129
declined: None,129
declined: None,130
});130
});131
}131
}@@ -273,21 +273,23 @@ fn open_dialog(cx: &mut App) {273
let Some(window) = crate::main_window::current(cx) else {273
let Some(window) = crate::main_window::current(cx) else {274
return;274
return;275
};275
};276
if !cx.has_global::<LinuxUpdates>() || cx.global::<LinuxUpdates>().dialog_open {276
if !cx.has_global::<LinuxUpdates>()277
|| cx.global::<LinuxUpdates>().dialog_window == Some(window.window_id())278
{277
return;279
return;278
}280
}279
cx.global_mut::<LinuxUpdates>().dialog_open = true;281
cx.global_mut::<LinuxUpdates>().dialog_window = Some(window.window_id());280
let opened = window.update(cx, |_, window, cx| {282
let opened = window.update(cx, |_, window, cx| {281
window.open_dialog(cx, |dialog: Dialog, _, cx| build_dialog(dialog, cx));283
window.open_dialog(cx, |dialog: Dialog, _, cx| build_dialog(dialog, cx));282
});284
});283
if opened.is_err() {285
if opened.is_err() {284
cx.global_mut::<LinuxUpdates>().dialog_open = false;286
cx.global_mut::<LinuxUpdates>().dialog_window = None;285
}287
}286
}288
}287
289
288
fn close_dialog(window: &mut Window, cx: &mut App) {290
fn close_dialog(window: &mut Window, cx: &mut App) {289
if cx.has_global::<LinuxUpdates>() {291
if cx.has_global::<LinuxUpdates>() {290
cx.global_mut::<LinuxUpdates>().dialog_open = false;292
cx.global_mut::<LinuxUpdates>().dialog_window = None;291
}293
}292
window.close_dialog(cx);294
window.close_dialog(cx);293
}295
}@@ -198,8 +198,6 @@ fn main() {
198
198
diagnostics::install(data_path(diagnostics::DIAGNOSTICS_FILE));
199
199
#[cfg(target_os = "linux")]
200
200
app_base::linux_fonts::hide_system_color_emoji();
201
#[cfg(target_os = "linux")]
202
linux_install::load_icon();
203
201
let arguments = parse_arguments();
204
202
if !arguments.demo && arguments.database.is_none() {
205
203
let relaunch_value = std::env::var(updater::RELAUNCH_ENV).ok();
@@ -198,8 +198,6 @@ fn main() {198
diagnostics::install(data_path(diagnostics::DIAGNOSTICS_FILE));198
diagnostics::install(data_path(diagnostics::DIAGNOSTICS_FILE));199
#[cfg(target_os = "linux")]199
#[cfg(target_os = "linux")]200
app_base::linux_fonts::hide_system_color_emoji();200
app_base::linux_fonts::hide_system_color_emoji();201
#[cfg(target_os = "linux")]202
linux_install::load_icon();203
let arguments = parse_arguments();201
let arguments = parse_arguments();204
if !arguments.demo && arguments.database.is_none() {202
if !arguments.demo && arguments.database.is_none() {205
let relaunch_value = std::env::var(updater::RELAUNCH_ENV).ok();203
let relaunch_value = std::env::var(updater::RELAUNCH_ENV).ok();@@ -1223,11 +1223,6 @@ impl NotificationCenter {
1223
1223
.ok();
1224
1224
}
1225
1225
1226
/// Applies the icon again even if the choice is unchanged: its image changed.
1227
pub fn reapply_app_icon(&mut self, cx: &mut Context<Self>) {
1228
self.show_app_icon(active_appearance::current(cx).app_icon, cx);
1229
}
1230
1231
1226
fn apply_app_icon(&mut self, icon: AppIcon, cx: &mut Context<Self>) {
1232
1227
if icon != self.app_icon {
1233
1228
self.show_app_icon(icon, cx);
@@ -1223,11 +1223,6 @@ impl NotificationCenter {1223
.ok();1223
.ok();1224
}1224
}1225
1225
1226
/// Applies the icon again even if the choice is unchanged: its image changed.1227
pub fn reapply_app_icon(&mut self, cx: &mut Context<Self>) {1228
self.show_app_icon(active_appearance::current(cx).app_icon, cx);1229
}1230
1231
fn apply_app_icon(&mut self, icon: AppIcon, cx: &mut Context<Self>) {1226
fn apply_app_icon(&mut self, icon: AppIcon, cx: &mut Context<Self>) {1232
if icon != self.app_icon {1227
if icon != self.app_icon {1233
self.show_app_icon(icon, cx);1228
self.show_app_icon(icon, cx);@@ -176,14 +176,6 @@ struct KeptParts {
176
176
177
177
impl Global for KeptParts {}
178
178
179
/// Re-applies the app icon to the tray and window, e.g. after the Teams icon arrived.
180
pub fn refresh_app_icon(cx: &mut App) {
181
if let Some(kept) = cx.try_global::<KeptParts>().cloned() {
182
kept.notifications
183
.update(cx, |notifications, cx| notifications.reapply_app_icon(cx));
184
}
185
}
186
187
179
pub struct AppShell {
188
180
state: Entity<AppState>,
189
181
rail: Entity<RailView>,
@@ -176,14 +176,6 @@ struct KeptParts {176
176
177
impl Global for KeptParts {}177
impl Global for KeptParts {}178
178
179
/// Re-applies the app icon to the tray and window, e.g. after the Teams icon arrived.180
pub fn refresh_app_icon(cx: &mut App) {181
if let Some(kept) = cx.try_global::<KeptParts>().cloned() {182
kept.notifications183
.update(cx, |notifications, cx| notifications.reapply_app_icon(cx));184
}185
}186
187
pub struct AppShell {179
pub struct AppShell {188
state: Entity<AppState>,180
state: Entity<AppState>,189
rail: Entity<RailView>,181
rail: Entity<RailView>,@@ -1,20 +0,0 @@
1
---
2
status: proposed
3
date: 2026-11-14
4
---
5
6
# ADR 0013: The Microsoft Teams icon is downloaded on Linux, not shipped
7
8
## Context
9
10
The "Microsoft Teams" app icon option embeds Microsoft's logo in the binary. For the Linux menu entry and tray we want the real Teams icon, but shipping Microsoft's trademark in our release assets is a risk. The options were: ship the PNG, use an icon theme name (depends on the user's theme), draw a look-alike (worse than either), or let the user's machine fetch the icon from Microsoft.
11
12
## Decision
13
14
Linux builds do not embed `microsoft-teams-256.png`. On start the app downloads the favicon the Teams web client uses (`teams.public.onecdn.static.microsoft/.../microsoft_teams_logo_refresh_v2025.ico`, with the `<link id="teams-favicon">` of `teams.cloud.microsoft` as fallback) into `~/.local/share/icons/hicolor/<size>/apps/rusty-teams.png`. Once present it is the default app icon unless one was chosen in Appearance. Until then, and offline, the Rusty Teams logo is used. Windows and macOS keep the embedded icon.
15
16
## Consequences
17
18
- No Microsoft logo in Linux release assets; the icon comes from Microsoft to the user directly.
19
- The first start shows the Rusty Teams logo for a moment; the title bar picks up the Teams icon on the next start.
20
- If Microsoft moves the file and the page stops naming it, the Rusty Teams logo stays.
@@ -1,20 +0,0 @@1
---2
status: proposed3
date: 2026-11-144
---5
6
# ADR 0013: The Microsoft Teams icon is downloaded on Linux, not shipped7
8
## Context9
10
The "Microsoft Teams" app icon option embeds Microsoft's logo in the binary. For the Linux menu entry and tray we want the real Teams icon, but shipping Microsoft's trademark in our release assets is a risk. The options were: ship the PNG, use an icon theme name (depends on the user's theme), draw a look-alike (worse than either), or let the user's machine fetch the icon from Microsoft.11
12
## Decision13
14
Linux builds do not embed `microsoft-teams-256.png`. On start the app downloads the favicon the Teams web client uses (`teams.public.onecdn.static.microsoft/.../microsoft_teams_logo_refresh_v2025.ico`, with the `<link id="teams-favicon">` of `teams.cloud.microsoft` as fallback) into `~/.local/share/icons/hicolor/<size>/apps/rusty-teams.png`. Once present it is the default app icon unless one was chosen in Appearance. Until then, and offline, the Rusty Teams logo is used. Windows and macOS keep the embedded icon.15
16
## Consequences17
18
- No Microsoft logo in Linux release assets; the icon comes from Microsoft to the user directly.19
- The first start shows the Rusty Teams logo for a moment; the title bar picks up the Teams icon on the next start.20
- If Microsoft moves the file and the page stops naming it, the Rusty Teams logo stays.@@ -11,7 +11,7 @@ The Linux release is a bare binary in a tarball. Users had to copy a `.desktop`
11
11
12
12
## Decision
13
13
14
On start the binary offers to install itself into `~/.local/share/applications/teams/teams` and writes `~/.local/share/applications/rusty-teams.desktop` (`StartupWMClass=rusty-teams`, matching the window's app id). Build output from a cargo `target/` folder is copied, anything else is moved. "Don't ask again" can be undone in Settings > General, which also has Install, Replace and Remove. The installed copy updates itself from the same GitHub releases as Windows (`release_feed.rs`, `updater.rs`), but always with consent (`linux_update.rs`): when Settings > General > Automatic updates is on (the default), a newer release is offered in a dialog; Update downloads the `rusty-teams-<tag>-linux-amd64` asset with progress and checks size, ELF header and the SHA-256 digest GitHub reports; Restart now swaps the file and relaunches. Not now holds for the running session; the next start asks again. There is no idle restart and no install on quit on Linux: a download left for later is offered again on the next start (Restart now, no second download). Settings > General > Check now runs the same flow on demand. A build compares releases against its release tag, or against the workspace version (kept equal to the latest release) when built locally. Binaries outside the install folder never replace themselves; Settings > General still shows the switch and Check now and explains that the app has to be installed first.
14
On start the binary offers to install itself into `~/.local/share/rusty-teams/teams` and writes `~/.local/share/applications/rusty-teams.desktop` (`StartupWMClass=rusty-teams`, matching the window's app id). Build output from a cargo `target/` folder is copied, anything else is moved. "Don't ask again" can be undone in Settings > General, which also has Install, Replace and Remove. The installed copy updates itself from the same GitHub releases as Windows (`release_feed.rs`, `updater.rs`), but always with consent (`linux_update.rs`): when Settings > General > Automatic updates is on (the default), a newer release is offered in a dialog; Update downloads the `rusty-teams-<tag>-linux-amd64` asset with progress and checks size, ELF header and the SHA-256 digest GitHub reports; Restart now swaps the file and relaunches. Not now holds for the running session; the next start asks again. There is no idle restart and no install on quit on Linux: a download left for later is offered again on the next start (Restart now, no second download). Settings > General > Check now runs the same flow on demand. A build compares releases against its release tag, or against the workspace version (kept equal to the latest release) when built locally. Binaries outside the install folder never replace themselves; Settings > General still shows the switch and Check now and explains that the app has to be installed first.
15
15
16
16
## Consequences
17
17
@@ -11,7 +11,7 @@ The Linux release is a bare binary in a tarball. Users had to copy a `.desktop`11
11
12
## Decision12
## Decision13
13
14
On start the binary offers to install itself into `~/.local/share/applications/teams/teams` and writes `~/.local/share/applications/rusty-teams.desktop` (`StartupWMClass=rusty-teams`, matching the window's app id). Build output from a cargo `target/` folder is copied, anything else is moved. "Don't ask again" can be undone in Settings > General, which also has Install, Replace and Remove. The installed copy updates itself from the same GitHub releases as Windows (`release_feed.rs`, `updater.rs`), but always with consent (`linux_update.rs`): when Settings > General > Automatic updates is on (the default), a newer release is offered in a dialog; Update downloads the `rusty-teams-<tag>-linux-amd64` asset with progress and checks size, ELF header and the SHA-256 digest GitHub reports; Restart now swaps the file and relaunches. Not now holds for the running session; the next start asks again. There is no idle restart and no install on quit on Linux: a download left for later is offered again on the next start (Restart now, no second download). Settings > General > Check now runs the same flow on demand. A build compares releases against its release tag, or against the workspace version (kept equal to the latest release) when built locally. Binaries outside the install folder never replace themselves; Settings > General still shows the switch and Check now and explains that the app has to be installed first.14
On start the binary offers to install itself into `~/.local/share/rusty-teams/teams` and writes `~/.local/share/applications/rusty-teams.desktop` (`StartupWMClass=rusty-teams`, matching the window's app id). Build output from a cargo `target/` folder is copied, anything else is moved. "Don't ask again" can be undone in Settings > General, which also has Install, Replace and Remove. The installed copy updates itself from the same GitHub releases as Windows (`release_feed.rs`, `updater.rs`), but always with consent (`linux_update.rs`): when Settings > General > Automatic updates is on (the default), a newer release is offered in a dialog; Update downloads the `rusty-teams-<tag>-linux-amd64` asset with progress and checks size, ELF header and the SHA-256 digest GitHub reports; Restart now swaps the file and relaunches. Not now holds for the running session; the next start asks again. There is no idle restart and no install on quit on Linux: a download left for later is offered again on the next start (Restart now, no second download). Settings > General > Check now runs the same flow on demand. A build compares releases against its release tag, or against the workspace version (kept equal to the latest release) when built locally. Binaries outside the install folder never replace themselves; Settings > General still shows the switch and Check now and explains that the app has to be installed first.15
15
16
## Consequences16
## Consequences17
17
@@ -28,7 +28,6 @@ Statuses: `proposed`, `accepted`, `superseded`.
28
28
| [0010](0010-preferred-external-browser.md) | Preferred browser for links and Google OAuth |
29
29
| [0011](0011-calendar-event-peek.md) | Calendar events open as a Teams-like peek |
30
30
| [0012](0012-linux-close-to-tray-closes-the-window.md) | On Linux, close to tray closes the main window |
31
| [0013](0013-teams-icon-is-downloaded-not-shipped.md) | The Microsoft Teams icon is downloaded on Linux, not shipped |
32
31
| [0014](0014-linux-installs-and-updates-itself.md) | The Linux binary installs and updates itself |
33
32
34
33
Records `0001` to `0010` are the decisions already shipped. `0011` stays `proposed` until the calendar-peek pull request merges, `0012` to `0014` until the Linux tray and install pull request merges. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
@@ -28,7 +28,6 @@ Statuses: `proposed`, `accepted`, `superseded`.28
| [0010](0010-preferred-external-browser.md) | Preferred browser for links and Google OAuth |28
| [0010](0010-preferred-external-browser.md) | Preferred browser for links and Google OAuth |29
| [0011](0011-calendar-event-peek.md) | Calendar events open as a Teams-like peek |29
| [0011](0011-calendar-event-peek.md) | Calendar events open as a Teams-like peek |30
| [0012](0012-linux-close-to-tray-closes-the-window.md) | On Linux, close to tray closes the main window |30
| [0012](0012-linux-close-to-tray-closes-the-window.md) | On Linux, close to tray closes the main window |31
| [0013](0013-teams-icon-is-downloaded-not-shipped.md) | The Microsoft Teams icon is downloaded on Linux, not shipped |32
| [0014](0014-linux-installs-and-updates-itself.md) | The Linux binary installs and updates itself |31
| [0014](0014-linux-installs-and-updates-itself.md) | The Linux binary installs and updates itself |33
32
34
Records `0001` to `0010` are the decisions already shipped. `0011` stays `proposed` until the calendar-peek pull request merges, `0012` to `0014` until the Linux tray and install pull request merges. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.33
Records `0001` to `0010` are the decisions already shipped. `0011` stays `proposed` until the calendar-peek pull request merges, `0012` to `0014` until the Linux tray and install pull request merges. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.