Merge pull request #49: feat(macos): tray, Chromium sign-in, ScreenCaptureKit picker, packaging
# Conflicts: # docs/decisions/README.md
@@ -33,7 +33,7 @@ Feature parity with the Microsoft Teams desktop client.
33
33
| Sign in on Windows through embedded WebView2, single sign-on | Done | |
34
34
| Start from the local cache, no spinner | Done | |
35
35
| Self-update | Done | |
36
| 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 |
36
| Tray icon, close to tray | Done | Linux: StatusNotifierItem (KDE, GNOME with AppIndicator). macOS: menu-bar via `tray-icon`, same close-to-tray path as Linux. Windows: `tray-icon` |
37
37
| 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 |
38
38
| 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
39
| Single instance, second start brings the window to front | Done | |
@@ -33,7 +33,7 @@ Feature parity with the Microsoft Teams desktop client.33
| Sign in on Windows through embedded WebView2, single sign-on | Done | |33
| Sign in on Windows through embedded WebView2, single sign-on | Done | |34
| Start from the local cache, no spinner | Done | |34
| Start from the local cache, no spinner | Done | |35
| Self-update | Done | |35
| Self-update | Done | |36
| 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 |36
| Tray icon, close to tray | Done | Linux: StatusNotifierItem (KDE, GNOME with AppIndicator). macOS: menu-bar via `tray-icon`, same close-to-tray path as Linux. Windows: `tray-icon` |37
| 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 |37
| 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 |38
| 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 |38
| 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
| Single instance, second start brings the window to front | Done | |39
| Single instance, second start brings the window to front | Done | |@@ -45,10 +45,12 @@ x11rb = { version = "0.13", features = ["shape"] }
45
45
ksni = { version = "0.3", features = ["blocking"] }
46
46
zbus = { version = "5", default-features = false, features = ["tokio"] }
47
47
48
[target.'cfg(any(windows, target_os = "macos"))'.dependencies]
49
tray-icon = { version = "0.21", default-features = false }
50
48
51
[target.'cfg(windows)'.dependencies]
49
52
libc = "0.2"
50
53
rodio = { version = "0.22", default-features = false, features = ["playback", "mp3"] }
51
tray-icon = { version = "0.21", default-features = false }
52
54
windows = { version = "0.62", features = [
53
55
"Win32_Foundation",
54
56
"Win32_Graphics_Dwm",
@@ -45,10 +45,12 @@ x11rb = { version = "0.13", features = ["shape"] }45
ksni = { version = "0.3", features = ["blocking"] }45
ksni = { version = "0.3", features = ["blocking"] }46
zbus = { version = "5", default-features = false, features = ["tokio"] }46
zbus = { version = "5", default-features = false, features = ["tokio"] }47
47
48
[target.'cfg(any(windows, target_os = "macos"))'.dependencies]49
tray-icon = { version = "0.21", default-features = false }50
48
[target.'cfg(windows)'.dependencies]51
[target.'cfg(windows)'.dependencies]49
libc = "0.2"52
libc = "0.2"50
rodio = { version = "0.22", default-features = false, features = ["playback", "mp3"] }53
rodio = { version = "0.22", default-features = false, features = ["playback", "mp3"] }51
tray-icon = { version = "0.21", default-features = false }52
windows = { version = "0.62", features = [54
windows = { version = "0.62", features = [53
"Win32_Foundation",55
"Win32_Foundation",54
"Win32_Graphics_Dwm",56
"Win32_Graphics_Dwm",@@ -5,6 +5,11 @@ pub use windows_impl::*;
5
5
6
6
#[cfg(target_os = "linux")]
7
7
mod linux_notifications;
8
#[cfg(any(windows, target_os = "macos"))]
9
mod tray_icon_impl;
10
#[cfg(any(windows, target_os = "macos"))]
11
pub use tray_icon_impl::Tray;
12
8
13
#[cfg(any(target_os = "linux", target_os = "macos"))]
9
14
mod linux_sound;
10
15
#[cfg(target_os = "linux")]
@@ -5,6 +5,11 @@ pub use windows_impl::*;5
5
6
#[cfg(target_os = "linux")]6
#[cfg(target_os = "linux")]7
mod linux_notifications;7
mod linux_notifications;8
#[cfg(any(windows, target_os = "macos"))]9
mod tray_icon_impl;10
#[cfg(any(windows, target_os = "macos"))]11
pub use tray_icon_impl::Tray;12
8
#[cfg(any(target_os = "linux", target_os = "macos"))]13
#[cfg(any(target_os = "linux", target_os = "macos"))]9
mod linux_sound;14
mod linux_sound;10
#[cfg(target_os = "linux")]15
#[cfg(target_os = "linux")]@@ -112,10 +112,10 @@ pub fn play_mp3(_bytes: Vec<u8>) {}
112
112
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
113
113
pub fn play_mp3_until(_bytes: Vec<u8>, _looped: bool, _stop: Arc<AtomicBool>) {}
114
114
115
#[cfg(not(target_os = "linux"))]
115
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
116
116
pub struct Tray;
117
117
118
#[cfg(not(target_os = "linux"))]
118
#[cfg(not(any(target_os = "linux", target_os = "macos")))]
119
119
impl Tray {
120
120
pub fn new(_presence: super::TrayPresence, _icon_png: &[u8]) -> Option<Self> {
121
121
None
@@ -112,10 +112,10 @@ pub fn play_mp3(_bytes: Vec<u8>) {}112
#[cfg(not(any(target_os = "linux", target_os = "macos")))]112
#[cfg(not(any(target_os = "linux", target_os = "macos")))]113
pub fn play_mp3_until(_bytes: Vec<u8>, _looped: bool, _stop: Arc<AtomicBool>) {}113
pub fn play_mp3_until(_bytes: Vec<u8>, _looped: bool, _stop: Arc<AtomicBool>) {}114
114
115
#[cfg(not(target_os = "linux"))]115
#[cfg(not(any(target_os = "linux", target_os = "macos")))]116
pub struct Tray;116
pub struct Tray;117
117
118
#[cfg(not(target_os = "linux"))]118
#[cfg(not(any(target_os = "linux", target_os = "macos")))]119
impl Tray {119
impl Tray {120
pub fn new(_presence: super::TrayPresence, _icon_png: &[u8]) -> Option<Self> {120
pub fn new(_presence: super::TrayPresence, _icon_png: &[u8]) -> Option<Self> {121
None121
None@@ -0,0 +1,240 @@
1
//! Menu-bar / system-tray icon via `tray-icon` (Windows and macOS).
2
3
use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};
4
use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
5
6
use super::{TrayCommand, TrayPresence};
7
use crate::notify::tray_status;
8
9
const TRAY_ICON_SIZE: u32 = 32;
10
const TRAY_DOT_RADIUS: f32 = 6.;
11
12
const ID_OPEN: &str = "open";
13
const ID_NOTIFICATIONS: &str = "notifications";
14
const ID_QUIT: &str = "quit";
15
const ID_RESET_STATUS: &str = "status:reset";
16
17
pub struct Tray {
18
icon: TrayIcon,
19
open: MenuItem,
20
status: Submenu,
21
status_items: Vec<CheckMenuItem>,
22
duration_items: Vec<MenuItem>,
23
duration_menu: Submenu,
24
reset: MenuItem,
25
notifications: MenuItem,
26
quit: MenuItem,
27
plain: Icon,
28
with_dot: Icon,
29
}
30
31
fn tray_menu_label(key: &str) -> String {
32
crate::ui_locale::tr(key)
33
}
34
35
impl Tray {
36
pub fn new(presence: TrayPresence, icon_png: &[u8]) -> Option<Self> {
37
let (plain, with_dot) = tray_icons(icon_png)?;
38
let open = MenuItem::with_id(ID_OPEN, tray_menu_label("tray.open"), true, None);
39
let status_items: Vec<CheckMenuItem> = tray_status::STATUS_CHOICES
40
.into_iter()
41
.map(|kind| {
42
CheckMenuItem::with_id(
43
tray_status::kind_id(kind),
44
tray_status::choice_label(kind),
45
true,
46
presence.forced == Some(kind),
47
None,
48
)
49
})
50
.collect();
51
let duration_enabled = tray_status::duration_target(presence.forced).is_some();
52
let duration_items: Vec<MenuItem> = tray_status::STATUS_DURATIONS
53
.into_iter()
54
.map(|duration| {
55
MenuItem::with_id(
56
tray_status::duration_id(duration),
57
duration.label(),
58
duration_enabled,
59
None,
60
)
61
})
62
.collect();
63
let duration_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = duration_items
64
.iter()
65
.map(|item| item as &dyn tray_icon::menu::IsMenuItem)
66
.collect();
67
let duration_menu = Submenu::with_items(
68
tray_status::duration_menu_label(),
69
duration_enabled,
70
&duration_refs,
71
)
72
.ok()?;
73
let reset = MenuItem::with_id(ID_RESET_STATUS, tray_status::reset_label(), true, None);
74
let mut status_entry_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = status_items
75
.iter()
76
.map(|item| item as &dyn tray_icon::menu::IsMenuItem)
77
.collect();
78
let separator = PredefinedMenuItem::separator();
79
status_entry_refs.push(&separator);
80
status_entry_refs.push(&duration_menu);
81
status_entry_refs.push(&reset);
82
let status = Submenu::with_items(&presence.title, true, &status_entry_refs).ok()?;
83
let notifications = MenuItem::with_id(
84
ID_NOTIFICATIONS,
85
tray_menu_label("tray.notifications"),
86
true,
87
None,
88
);
89
let quit = MenuItem::with_id(ID_QUIT, tray_menu_label("tray.quit"), true, None);
90
let menu = Menu::new();
91
menu.append_items(&[
92
&open,
93
&PredefinedMenuItem::separator(),
94
&status,
95
¬ifications,
96
&PredefinedMenuItem::separator(),
97
&quit,
98
])
99
.ok()?;
100
let icon = TrayIconBuilder::new()
101
.with_icon(plain.clone())
102
.with_tooltip(crate::APP_NAME)
103
.with_menu(Box::new(menu))
104
.with_menu_on_left_click(false)
105
.build()
106
.ok()?;
107
Some(Tray {
108
icon,
109
open,
110
status,
111
status_items,
112
duration_items,
113
duration_menu,
114
reset,
115
notifications,
116
quit,
117
plain,
118
with_dot,
119
})
120
}
121
122
pub fn relocalize(&self) {
123
let _ = self.open.set_text(tray_menu_label("tray.open"));
124
let _ = self
125
.notifications
126
.set_text(tray_menu_label("tray.notifications"));
127
let _ = self.quit.set_text(tray_menu_label("tray.quit"));
128
let _ = self.reset.set_text(tray_status::reset_label());
129
let _ = self
130
.duration_menu
131
.set_text(tray_status::duration_menu_label());
132
for (item, kind) in self
133
.status_items
134
.iter()
135
.zip(tray_status::STATUS_CHOICES.into_iter())
136
{
137
let _ = item.set_text(tray_status::choice_label(kind));
138
}
139
for (item, duration) in self
140
.duration_items
141
.iter()
142
.zip(tray_status::STATUS_DURATIONS.into_iter())
143
{
144
let _ = item.set_text(duration.label());
145
}
146
}
147
148
pub fn poll(&self) -> Vec<TrayCommand> {
149
let mut commands = Vec::new();
150
while let Ok(event) = MenuEvent::receiver().try_recv() {
151
let id = event.id.0.as_str();
152
let command = match id {
153
ID_OPEN => TrayCommand::Open,
154
ID_NOTIFICATIONS => TrayCommand::Notifications,
155
ID_QUIT => TrayCommand::Quit,
156
ID_RESET_STATUS => TrayCommand::ResetStatus,
157
other => {
158
if let Some(kind) = tray_status::parse_kind_id(other) {
159
TrayCommand::SetStatus(kind)
160
} else if let Some(duration) = tray_status::parse_duration_id(other) {
161
TrayCommand::SetStatusDuration(duration)
162
} else {
163
continue;
164
}
165
}
166
};
167
commands.push(command);
168
}
169
while let Ok(event) = TrayIconEvent::receiver().try_recv() {
170
if let TrayIconEvent::Click {
171
button: MouseButton::Left,
172
button_state: MouseButtonState::Up,
173
..
174
} = event
175
{
176
commands.push(TrayCommand::Toggle);
177
}
178
}
179
commands
180
}
181
182
pub fn set_app_icon(&mut self, icon_png: &[u8], mention: bool) {
183
let Some((plain, with_dot)) = tray_icons(icon_png) else {
184
return;
185
};
186
self.plain = plain;
187
self.with_dot = with_dot;
188
let icon = if mention { &self.with_dot } else { &self.plain };
189
let _ = self.icon.set_icon(Some(icon.clone()));
190
}
191
192
pub fn sync(&self, presence: TrayPresence) {
193
self.relocalize();
194
let _ = self.status.set_text(&presence.title);
195
for (item, kind) in self
196
.status_items
197
.iter()
198
.zip(tray_status::STATUS_CHOICES.into_iter())
199
{
200
item.set_checked(presence.forced == Some(kind));
201
}
202
let duration_enabled = tray_status::duration_target(presence.forced).is_some();
203
let _ = self.duration_menu.set_enabled(duration_enabled);
204
for item in &self.duration_items {
205
let _ = item.set_enabled(duration_enabled);
206
}
207
let icon = if presence.mention {
208
&self.with_dot
209
} else {
210
&self.plain
211
};
212
let _ = self.icon.set_icon(Some(icon.clone()));
213
}
214
}
215
216
fn tray_icons(icon_png: &[u8]) -> Option<(Icon, Icon)> {
217
let decoded = image::load_from_memory(icon_png).ok()?;
218
let resized = decoded
219
.resize_exact(
220
TRAY_ICON_SIZE,
221
TRAY_ICON_SIZE,
222
image::imageops::FilterType::Lanczos3,
223
)
224
.to_rgba8();
225
let plain = resized.clone().into_raw();
226
let mut dotted = resized;
227
let size = TRAY_ICON_SIZE as f32;
228
let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);
229
for (column, row, pixel) in dotted.enumerate_pixels_mut() {
230
let distance =
231
((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();
232
if distance <= TRAY_DOT_RADIUS {
233
*pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);
234
}
235
}
236
Some((
237
Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
238
Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
239
))
240
}
@@ -0,0 +1,240 @@1
//! Menu-bar / system-tray icon via `tray-icon` (Windows and macOS).2
3
use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};4
use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};5
6
use super::{TrayCommand, TrayPresence};7
use crate::notify::tray_status;8
9
const TRAY_ICON_SIZE: u32 = 32;10
const TRAY_DOT_RADIUS: f32 = 6.;11
12
const ID_OPEN: &str = "open";13
const ID_NOTIFICATIONS: &str = "notifications";14
const ID_QUIT: &str = "quit";15
const ID_RESET_STATUS: &str = "status:reset";16
17
pub struct Tray {18
icon: TrayIcon,19
open: MenuItem,20
status: Submenu,21
status_items: Vec<CheckMenuItem>,22
duration_items: Vec<MenuItem>,23
duration_menu: Submenu,24
reset: MenuItem,25
notifications: MenuItem,26
quit: MenuItem,27
plain: Icon,28
with_dot: Icon,29
}30
31
fn tray_menu_label(key: &str) -> String {32
crate::ui_locale::tr(key)33
}34
35
impl Tray {36
pub fn new(presence: TrayPresence, icon_png: &[u8]) -> Option<Self> {37
let (plain, with_dot) = tray_icons(icon_png)?;38
let open = MenuItem::with_id(ID_OPEN, tray_menu_label("tray.open"), true, None);39
let status_items: Vec<CheckMenuItem> = tray_status::STATUS_CHOICES40
.into_iter()41
.map(|kind| {42
CheckMenuItem::with_id(43
tray_status::kind_id(kind),44
tray_status::choice_label(kind),45
true,46
presence.forced == Some(kind),47
None,48
)49
})50
.collect();51
let duration_enabled = tray_status::duration_target(presence.forced).is_some();52
let duration_items: Vec<MenuItem> = tray_status::STATUS_DURATIONS53
.into_iter()54
.map(|duration| {55
MenuItem::with_id(56
tray_status::duration_id(duration),57
duration.label(),58
duration_enabled,59
None,60
)61
})62
.collect();63
let duration_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = duration_items64
.iter()65
.map(|item| item as &dyn tray_icon::menu::IsMenuItem)66
.collect();67
let duration_menu = Submenu::with_items(68
tray_status::duration_menu_label(),69
duration_enabled,70
&duration_refs,71
)72
.ok()?;73
let reset = MenuItem::with_id(ID_RESET_STATUS, tray_status::reset_label(), true, None);74
let mut status_entry_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = status_items75
.iter()76
.map(|item| item as &dyn tray_icon::menu::IsMenuItem)77
.collect();78
let separator = PredefinedMenuItem::separator();79
status_entry_refs.push(&separator);80
status_entry_refs.push(&duration_menu);81
status_entry_refs.push(&reset);82
let status = Submenu::with_items(&presence.title, true, &status_entry_refs).ok()?;83
let notifications = MenuItem::with_id(84
ID_NOTIFICATIONS,85
tray_menu_label("tray.notifications"),86
true,87
None,88
);89
let quit = MenuItem::with_id(ID_QUIT, tray_menu_label("tray.quit"), true, None);90
let menu = Menu::new();91
menu.append_items(&[92
&open,93
&PredefinedMenuItem::separator(),94
&status,95
¬ifications,96
&PredefinedMenuItem::separator(),97
&quit,98
])99
.ok()?;100
let icon = TrayIconBuilder::new()101
.with_icon(plain.clone())102
.with_tooltip(crate::APP_NAME)103
.with_menu(Box::new(menu))104
.with_menu_on_left_click(false)105
.build()106
.ok()?;107
Some(Tray {108
icon,109
open,110
status,111
status_items,112
duration_items,113
duration_menu,114
reset,115
notifications,116
quit,117
plain,118
with_dot,119
})120
}121
122
pub fn relocalize(&self) {123
let _ = self.open.set_text(tray_menu_label("tray.open"));124
let _ = self125
.notifications126
.set_text(tray_menu_label("tray.notifications"));127
let _ = self.quit.set_text(tray_menu_label("tray.quit"));128
let _ = self.reset.set_text(tray_status::reset_label());129
let _ = self130
.duration_menu131
.set_text(tray_status::duration_menu_label());132
for (item, kind) in self133
.status_items134
.iter()135
.zip(tray_status::STATUS_CHOICES.into_iter())136
{137
let _ = item.set_text(tray_status::choice_label(kind));138
}139
for (item, duration) in self140
.duration_items141
.iter()142
.zip(tray_status::STATUS_DURATIONS.into_iter())143
{144
let _ = item.set_text(duration.label());145
}146
}147
148
pub fn poll(&self) -> Vec<TrayCommand> {149
let mut commands = Vec::new();150
while let Ok(event) = MenuEvent::receiver().try_recv() {151
let id = event.id.0.as_str();152
let command = match id {153
ID_OPEN => TrayCommand::Open,154
ID_NOTIFICATIONS => TrayCommand::Notifications,155
ID_QUIT => TrayCommand::Quit,156
ID_RESET_STATUS => TrayCommand::ResetStatus,157
other => {158
if let Some(kind) = tray_status::parse_kind_id(other) {159
TrayCommand::SetStatus(kind)160
} else if let Some(duration) = tray_status::parse_duration_id(other) {161
TrayCommand::SetStatusDuration(duration)162
} else {163
continue;164
}165
}166
};167
commands.push(command);168
}169
while let Ok(event) = TrayIconEvent::receiver().try_recv() {170
if let TrayIconEvent::Click {171
button: MouseButton::Left,172
button_state: MouseButtonState::Up,173
..174
} = event175
{176
commands.push(TrayCommand::Toggle);177
}178
}179
commands180
}181
182
pub fn set_app_icon(&mut self, icon_png: &[u8], mention: bool) {183
let Some((plain, with_dot)) = tray_icons(icon_png) else {184
return;185
};186
self.plain = plain;187
self.with_dot = with_dot;188
let icon = if mention { &self.with_dot } else { &self.plain };189
let _ = self.icon.set_icon(Some(icon.clone()));190
}191
192
pub fn sync(&self, presence: TrayPresence) {193
self.relocalize();194
let _ = self.status.set_text(&presence.title);195
for (item, kind) in self196
.status_items197
.iter()198
.zip(tray_status::STATUS_CHOICES.into_iter())199
{200
item.set_checked(presence.forced == Some(kind));201
}202
let duration_enabled = tray_status::duration_target(presence.forced).is_some();203
let _ = self.duration_menu.set_enabled(duration_enabled);204
for item in &self.duration_items {205
let _ = item.set_enabled(duration_enabled);206
}207
let icon = if presence.mention {208
&self.with_dot209
} else {210
&self.plain211
};212
let _ = self.icon.set_icon(Some(icon.clone()));213
}214
}215
216
fn tray_icons(icon_png: &[u8]) -> Option<(Icon, Icon)> {217
let decoded = image::load_from_memory(icon_png).ok()?;218
let resized = decoded219
.resize_exact(220
TRAY_ICON_SIZE,221
TRAY_ICON_SIZE,222
image::imageops::FilterType::Lanczos3,223
)224
.to_rgba8();225
let plain = resized.clone().into_raw();226
let mut dotted = resized;227
let size = TRAY_ICON_SIZE as f32;228
let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);229
for (column, row, pixel) in dotted.enumerate_pixels_mut() {230
let distance =231
((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();232
if distance <= TRAY_DOT_RADIUS {233
*pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);234
}235
}236
Some((237
Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,238
Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,239
))240
}@@ -7,8 +7,6 @@ use std::time::Duration;
7
7
use calling::ShareKind;
8
8
use gpui_kit::Window;
9
9
use raw_window_handle::{HasWindowHandle, RawWindowHandle};
10
use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};
11
use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};
12
10
use windows::Win32::Foundation::{COLORREF, HWND, LPARAM, POINT, RECT, WPARAM};
13
11
use windows::Win32::Graphics::Dwm::{
14
12
DWMWA_BORDER_COLOR, DWMWA_CLOAKED, DWMWA_COLOR_NONE, DWMWA_EXTENDED_FRAME_BOUNDS,
@@ -43,15 +41,12 @@ use windows::Win32::UI::WindowsAndMessaging::{
43
41
use windows::core::{BOOL, PCWSTR, w};
44
42
45
43
use super::stack_plan::{StackPlan, stack_plan};
46
use super::{NativeHandle, ScreenRect, ShareGeometry, TrayCommand, TrayPresence, WorkArea};
44
use super::{NativeHandle, ScreenRect, ShareGeometry, WorkArea};
47
45
use crate::notify::badge::{Badge, render_badge};
48
use crate::notify::tray_status;
49
46
50
47
const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");
51
const TRAY_ICON_SIZE: u32 = 32;
52
48
const WINDOW_ICON_SIZE: f32 = 32.;
53
49
const WINDOW_SMALL_ICON_SIZE: f32 = 16.;
54
const TRAY_DOT_RADIUS: f32 = 6.;
55
50
const BASE_DPI: f32 = 96.;
56
51
const RING_POLL: Duration = Duration::from_millis(20);
57
52
@@ -652,236 +647,6 @@ pub fn play_sound() {
652
647
});
653
648
}
654
649
655
const ID_OPEN: &str = "open";
656
const ID_NOTIFICATIONS: &str = "notifications";
657
const ID_QUIT: &str = "quit";
658
const ID_RESET_STATUS: &str = "status:reset";
659
660
pub struct Tray {
661
icon: TrayIcon,
662
open: MenuItem,
663
status: Submenu,
664
status_items: Vec<CheckMenuItem>,
665
duration_items: Vec<MenuItem>,
666
duration_menu: Submenu,
667
reset: MenuItem,
668
notifications: MenuItem,
669
quit: MenuItem,
670
plain: Icon,
671
with_dot: Icon,
672
}
673
674
fn tray_menu_label(key: &str) -> String {
675
crate::ui_locale::tr(key)
676
}
677
678
impl Tray {
679
pub fn new(presence: TrayPresence, icon_png: &[u8]) -> Option<Self> {
680
let (plain, with_dot) = tray_icons(icon_png)?;
681
let open = MenuItem::with_id(ID_OPEN, tray_menu_label("tray.open"), true, None);
682
let status_items: Vec<CheckMenuItem> = tray_status::STATUS_CHOICES
683
.into_iter()
684
.map(|kind| {
685
CheckMenuItem::with_id(
686
tray_status::kind_id(kind),
687
tray_status::choice_label(kind),
688
true,
689
presence.forced == Some(kind),
690
None,
691
)
692
})
693
.collect();
694
let duration_enabled = tray_status::duration_target(presence.forced).is_some();
695
let duration_items: Vec<MenuItem> = tray_status::STATUS_DURATIONS
696
.into_iter()
697
.map(|duration| {
698
MenuItem::with_id(
699
tray_status::duration_id(duration),
700
duration.label(),
701
duration_enabled,
702
None,
703
)
704
})
705
.collect();
706
let duration_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = duration_items
707
.iter()
708
.map(|item| item as &dyn tray_icon::menu::IsMenuItem)
709
.collect();
710
let duration_menu = Submenu::with_items(
711
tray_status::duration_menu_label(),
712
duration_enabled,
713
&duration_refs,
714
)
715
.ok()?;
716
let reset = MenuItem::with_id(ID_RESET_STATUS, tray_status::reset_label(), true, None);
717
let mut status_entry_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = status_items
718
.iter()
719
.map(|item| item as &dyn tray_icon::menu::IsMenuItem)
720
.collect();
721
let separator = PredefinedMenuItem::separator();
722
status_entry_refs.push(&separator);
723
status_entry_refs.push(&duration_menu);
724
status_entry_refs.push(&reset);
725
let status = Submenu::with_items(&presence.title, true, &status_entry_refs).ok()?;
726
let notifications = MenuItem::with_id(
727
ID_NOTIFICATIONS,
728
tray_menu_label("tray.notifications"),
729
true,
730
None,
731
);
732
let quit = MenuItem::with_id(ID_QUIT, tray_menu_label("tray.quit"), true, None);
733
let menu = Menu::new();
734
menu.append_items(&[
735
&open,
736
&PredefinedMenuItem::separator(),
737
&status,
738
¬ifications,
739
&PredefinedMenuItem::separator(),
740
&quit,
741
])
742
.ok()?;
743
let icon = TrayIconBuilder::new()
744
.with_icon(plain.clone())
745
.with_tooltip(crate::APP_NAME)
746
.with_menu(Box::new(menu))
747
.with_menu_on_left_click(false)
748
.build()
749
.ok()?;
750
Some(Tray {
751
icon,
752
open,
753
status,
754
status_items,
755
duration_items,
756
duration_menu,
757
reset,
758
notifications,
759
quit,
760
plain,
761
with_dot,
762
})
763
}
764
765
pub fn relocalize(&self) {
766
let _ = self.open.set_text(tray_menu_label("tray.open"));
767
let _ = self
768
.notifications
769
.set_text(tray_menu_label("tray.notifications"));
770
let _ = self.quit.set_text(tray_menu_label("tray.quit"));
771
let _ = self.reset.set_text(tray_status::reset_label());
772
let _ = self
773
.duration_menu
774
.set_text(tray_status::duration_menu_label());
775
for (item, kind) in self
776
.status_items
777
.iter()
778
.zip(tray_status::STATUS_CHOICES.into_iter())
779
{
780
let _ = item.set_text(tray_status::choice_label(kind));
781
}
782
for (item, duration) in self
783
.duration_items
784
.iter()
785
.zip(tray_status::STATUS_DURATIONS.into_iter())
786
{
787
let _ = item.set_text(duration.label());
788
}
789
}
790
791
pub fn poll(&self) -> Vec<TrayCommand> {
792
let mut commands = Vec::new();
793
while let Ok(event) = MenuEvent::receiver().try_recv() {
794
let id = event.id.0.as_str();
795
let command = match id {
796
ID_OPEN => TrayCommand::Open,
797
ID_NOTIFICATIONS => TrayCommand::Notifications,
798
ID_QUIT => TrayCommand::Quit,
799
ID_RESET_STATUS => TrayCommand::ResetStatus,
800
other => {
801
if let Some(kind) = tray_status::parse_kind_id(other) {
802
TrayCommand::SetStatus(kind)
803
} else if let Some(duration) = tray_status::parse_duration_id(other) {
804
TrayCommand::SetStatusDuration(duration)
805
} else {
806
continue;
807
}
808
}
809
};
810
commands.push(command);
811
}
812
while let Ok(event) = TrayIconEvent::receiver().try_recv() {
813
if let TrayIconEvent::Click {
814
button: MouseButton::Left,
815
button_state: MouseButtonState::Up,
816
..
817
} = event
818
{
819
commands.push(TrayCommand::Toggle);
820
}
821
}
822
commands
823
}
824
825
pub fn set_app_icon(&mut self, icon_png: &[u8], mention: bool) {
826
let Some((plain, with_dot)) = tray_icons(icon_png) else {
827
return;
828
};
829
self.plain = plain;
830
self.with_dot = with_dot;
831
let icon = if mention { &self.with_dot } else { &self.plain };
832
let _ = self.icon.set_icon(Some(icon.clone()));
833
}
834
835
pub fn sync(&self, presence: TrayPresence) {
836
self.relocalize();
837
let _ = self.status.set_text(&presence.title);
838
for (item, kind) in self
839
.status_items
840
.iter()
841
.zip(tray_status::STATUS_CHOICES.into_iter())
842
{
843
item.set_checked(presence.forced == Some(kind));
844
}
845
let duration_enabled = tray_status::duration_target(presence.forced).is_some();
846
let _ = self.duration_menu.set_enabled(duration_enabled);
847
for item in &self.duration_items {
848
let _ = item.set_enabled(duration_enabled);
849
}
850
let icon = if presence.mention {
851
&self.with_dot
852
} else {
853
&self.plain
854
};
855
let _ = self.icon.set_icon(Some(icon.clone()));
856
}
857
}
858
859
fn tray_icons(icon_png: &[u8]) -> Option<(Icon, Icon)> {
860
let decoded = image::load_from_memory(icon_png).ok()?;
861
let resized = decoded
862
.resize_exact(
863
TRAY_ICON_SIZE,
864
TRAY_ICON_SIZE,
865
image::imageops::FilterType::Lanczos3,
866
)
867
.to_rgba8();
868
let plain = resized.clone().into_raw();
869
let mut dotted = resized;
870
let size = TRAY_ICON_SIZE as f32;
871
let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);
872
for (column, row, pixel) in dotted.enumerate_pixels_mut() {
873
let distance =
874
((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();
875
if distance <= TRAY_DOT_RADIUS {
876
*pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);
877
}
878
}
879
Some((
880
Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
881
Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,
882
))
883
}
884
885
650
pub fn animations_enabled() -> bool {
886
651
let mut enabled = BOOL(1);
887
652
let read = unsafe {
@@ -7,8 +7,6 @@ use std::time::Duration;7
use calling::ShareKind;7
use calling::ShareKind;8
use gpui_kit::Window;8
use gpui_kit::Window;9
use raw_window_handle::{HasWindowHandle, RawWindowHandle};9
use raw_window_handle::{HasWindowHandle, RawWindowHandle};10
use tray_icon::menu::{CheckMenuItem, Menu, MenuEvent, MenuItem, PredefinedMenuItem, Submenu};11
use tray_icon::{Icon, MouseButton, MouseButtonState, TrayIcon, TrayIconBuilder, TrayIconEvent};12
use windows::Win32::Foundation::{COLORREF, HWND, LPARAM, POINT, RECT, WPARAM};10
use windows::Win32::Foundation::{COLORREF, HWND, LPARAM, POINT, RECT, WPARAM};13
use windows::Win32::Graphics::Dwm::{11
use windows::Win32::Graphics::Dwm::{14
DWMWA_BORDER_COLOR, DWMWA_CLOAKED, DWMWA_COLOR_NONE, DWMWA_EXTENDED_FRAME_BOUNDS,12
DWMWA_BORDER_COLOR, DWMWA_CLOAKED, DWMWA_COLOR_NONE, DWMWA_EXTENDED_FRAME_BOUNDS,@@ -43,15 +41,12 @@ use windows::Win32::UI::WindowsAndMessaging::{43
use windows::core::{BOOL, PCWSTR, w};41
use windows::core::{BOOL, PCWSTR, w};44
42
45
use super::stack_plan::{StackPlan, stack_plan};43
use super::stack_plan::{StackPlan, stack_plan};46
use super::{NativeHandle, ScreenRect, ShareGeometry, TrayCommand, TrayPresence, WorkArea};44
use super::{NativeHandle, ScreenRect, ShareGeometry, WorkArea};47
use crate::notify::badge::{Badge, render_badge};45
use crate::notify::badge::{Badge, render_badge};48
use crate::notify::tray_status;49
46
50
const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");47
const SOUND_BYTES: &[u8] = include_bytes!("../../../../app/assets/sounds/notification.mp3");51
const TRAY_ICON_SIZE: u32 = 32;52
const WINDOW_ICON_SIZE: f32 = 32.;48
const WINDOW_ICON_SIZE: f32 = 32.;53
const WINDOW_SMALL_ICON_SIZE: f32 = 16.;49
const WINDOW_SMALL_ICON_SIZE: f32 = 16.;54
const TRAY_DOT_RADIUS: f32 = 6.;55
const BASE_DPI: f32 = 96.;50
const BASE_DPI: f32 = 96.;56
const RING_POLL: Duration = Duration::from_millis(20);51
const RING_POLL: Duration = Duration::from_millis(20);57
52
@@ -652,236 +647,6 @@ pub fn play_sound() {652
});647
});653
}648
}654
649
655
const ID_OPEN: &str = "open";656
const ID_NOTIFICATIONS: &str = "notifications";657
const ID_QUIT: &str = "quit";658
const ID_RESET_STATUS: &str = "status:reset";659
660
pub struct Tray {661
icon: TrayIcon,662
open: MenuItem,663
status: Submenu,664
status_items: Vec<CheckMenuItem>,665
duration_items: Vec<MenuItem>,666
duration_menu: Submenu,667
reset: MenuItem,668
notifications: MenuItem,669
quit: MenuItem,670
plain: Icon,671
with_dot: Icon,672
}673
674
fn tray_menu_label(key: &str) -> String {675
crate::ui_locale::tr(key)676
}677
678
impl Tray {679
pub fn new(presence: TrayPresence, icon_png: &[u8]) -> Option<Self> {680
let (plain, with_dot) = tray_icons(icon_png)?;681
let open = MenuItem::with_id(ID_OPEN, tray_menu_label("tray.open"), true, None);682
let status_items: Vec<CheckMenuItem> = tray_status::STATUS_CHOICES683
.into_iter()684
.map(|kind| {685
CheckMenuItem::with_id(686
tray_status::kind_id(kind),687
tray_status::choice_label(kind),688
true,689
presence.forced == Some(kind),690
None,691
)692
})693
.collect();694
let duration_enabled = tray_status::duration_target(presence.forced).is_some();695
let duration_items: Vec<MenuItem> = tray_status::STATUS_DURATIONS696
.into_iter()697
.map(|duration| {698
MenuItem::with_id(699
tray_status::duration_id(duration),700
duration.label(),701
duration_enabled,702
None,703
)704
})705
.collect();706
let duration_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = duration_items707
.iter()708
.map(|item| item as &dyn tray_icon::menu::IsMenuItem)709
.collect();710
let duration_menu = Submenu::with_items(711
tray_status::duration_menu_label(),712
duration_enabled,713
&duration_refs,714
)715
.ok()?;716
let reset = MenuItem::with_id(ID_RESET_STATUS, tray_status::reset_label(), true, None);717
let mut status_entry_refs: Vec<&dyn tray_icon::menu::IsMenuItem> = status_items718
.iter()719
.map(|item| item as &dyn tray_icon::menu::IsMenuItem)720
.collect();721
let separator = PredefinedMenuItem::separator();722
status_entry_refs.push(&separator);723
status_entry_refs.push(&duration_menu);724
status_entry_refs.push(&reset);725
let status = Submenu::with_items(&presence.title, true, &status_entry_refs).ok()?;726
let notifications = MenuItem::with_id(727
ID_NOTIFICATIONS,728
tray_menu_label("tray.notifications"),729
true,730
None,731
);732
let quit = MenuItem::with_id(ID_QUIT, tray_menu_label("tray.quit"), true, None);733
let menu = Menu::new();734
menu.append_items(&[735
&open,736
&PredefinedMenuItem::separator(),737
&status,738
¬ifications,739
&PredefinedMenuItem::separator(),740
&quit,741
])742
.ok()?;743
let icon = TrayIconBuilder::new()744
.with_icon(plain.clone())745
.with_tooltip(crate::APP_NAME)746
.with_menu(Box::new(menu))747
.with_menu_on_left_click(false)748
.build()749
.ok()?;750
Some(Tray {751
icon,752
open,753
status,754
status_items,755
duration_items,756
duration_menu,757
reset,758
notifications,759
quit,760
plain,761
with_dot,762
})763
}764
765
pub fn relocalize(&self) {766
let _ = self.open.set_text(tray_menu_label("tray.open"));767
let _ = self768
.notifications769
.set_text(tray_menu_label("tray.notifications"));770
let _ = self.quit.set_text(tray_menu_label("tray.quit"));771
let _ = self.reset.set_text(tray_status::reset_label());772
let _ = self773
.duration_menu774
.set_text(tray_status::duration_menu_label());775
for (item, kind) in self776
.status_items777
.iter()778
.zip(tray_status::STATUS_CHOICES.into_iter())779
{780
let _ = item.set_text(tray_status::choice_label(kind));781
}782
for (item, duration) in self783
.duration_items784
.iter()785
.zip(tray_status::STATUS_DURATIONS.into_iter())786
{787
let _ = item.set_text(duration.label());788
}789
}790
791
pub fn poll(&self) -> Vec<TrayCommand> {792
let mut commands = Vec::new();793
while let Ok(event) = MenuEvent::receiver().try_recv() {794
let id = event.id.0.as_str();795
let command = match id {796
ID_OPEN => TrayCommand::Open,797
ID_NOTIFICATIONS => TrayCommand::Notifications,798
ID_QUIT => TrayCommand::Quit,799
ID_RESET_STATUS => TrayCommand::ResetStatus,800
other => {801
if let Some(kind) = tray_status::parse_kind_id(other) {802
TrayCommand::SetStatus(kind)803
} else if let Some(duration) = tray_status::parse_duration_id(other) {804
TrayCommand::SetStatusDuration(duration)805
} else {806
continue;807
}808
}809
};810
commands.push(command);811
}812
while let Ok(event) = TrayIconEvent::receiver().try_recv() {813
if let TrayIconEvent::Click {814
button: MouseButton::Left,815
button_state: MouseButtonState::Up,816
..817
} = event818
{819
commands.push(TrayCommand::Toggle);820
}821
}822
commands823
}824
825
pub fn set_app_icon(&mut self, icon_png: &[u8], mention: bool) {826
let Some((plain, with_dot)) = tray_icons(icon_png) else {827
return;828
};829
self.plain = plain;830
self.with_dot = with_dot;831
let icon = if mention { &self.with_dot } else { &self.plain };832
let _ = self.icon.set_icon(Some(icon.clone()));833
}834
835
pub fn sync(&self, presence: TrayPresence) {836
self.relocalize();837
let _ = self.status.set_text(&presence.title);838
for (item, kind) in self839
.status_items840
.iter()841
.zip(tray_status::STATUS_CHOICES.into_iter())842
{843
item.set_checked(presence.forced == Some(kind));844
}845
let duration_enabled = tray_status::duration_target(presence.forced).is_some();846
let _ = self.duration_menu.set_enabled(duration_enabled);847
for item in &self.duration_items {848
let _ = item.set_enabled(duration_enabled);849
}850
let icon = if presence.mention {851
&self.with_dot852
} else {853
&self.plain854
};855
let _ = self.icon.set_icon(Some(icon.clone()));856
}857
}858
859
fn tray_icons(icon_png: &[u8]) -> Option<(Icon, Icon)> {860
let decoded = image::load_from_memory(icon_png).ok()?;861
let resized = decoded862
.resize_exact(863
TRAY_ICON_SIZE,864
TRAY_ICON_SIZE,865
image::imageops::FilterType::Lanczos3,866
)867
.to_rgba8();868
let plain = resized.clone().into_raw();869
let mut dotted = resized;870
let size = TRAY_ICON_SIZE as f32;871
let center = (size - TRAY_DOT_RADIUS - 1., size - TRAY_DOT_RADIUS - 1.);872
for (column, row, pixel) in dotted.enumerate_pixels_mut() {873
let distance =874
((column as f32 - center.0).powi(2) + (row as f32 - center.1).powi(2)).sqrt();875
if distance <= TRAY_DOT_RADIUS {876
*pixel = image::Rgba([0xef, 0x44, 0x44, 0xff]);877
}878
}879
Some((880
Icon::from_rgba(plain, TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,881
Icon::from_rgba(dotted.into_raw(), TRAY_ICON_SIZE, TRAY_ICON_SIZE).ok()?,882
))883
}884
885
pub fn animations_enabled() -> bool {650
pub fn animations_enabled() -> bool {886
let mut enabled = BOOL(1);651
let mut enabled = BOOL(1);887
let read = unsafe {652
let read = unsafe {@@ -1,4 +1,7 @@
1
#![cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]
1
#![cfg_attr(
2
not(any(windows, target_os = "linux", target_os = "macos")),
3
allow(dead_code)
4
)]
2
5
3
6
use std::cmp::Ordering;
4
7
use std::fs;
@@ -17,14 +20,20 @@ pub const CHECK_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60);
17
20
const RELEASES_URL: &str =
18
21
"https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";
19
22
/// The release asset this platform installs, and the magic bytes it must start with.
20
#[cfg(not(target_os = "linux"))]
23
#[cfg(windows)]
21
24
const ASSET_SUFFIX: &str = "-windows-amd64.exe";
22
#[cfg(not(target_os = "linux"))]
25
#[cfg(windows)]
23
26
const EXECUTABLE_MAGIC: &[u8] = b"MZ";
24
27
#[cfg(target_os = "linux")]
25
28
const ASSET_SUFFIX: &str = "-linux-amd64";
26
29
#[cfg(target_os = "linux")]
27
30
const EXECUTABLE_MAGIC: &[u8] = b"\x7fELF";
31
/// macOS and any other target still compile. The suffix matches no release asset,
32
/// so the feed stays idle. macOS updates by replacing the `.app`, not a Mach-O in place.
33
#[cfg(not(any(windows, target_os = "linux")))]
34
const ASSET_SUFFIX: &str = "-unsupported";
35
#[cfg(not(any(windows, target_os = "linux")))]
36
const EXECUTABLE_MAGIC: &[u8] = b"\0unsupported";
28
37
const PARTIAL_SUFFIX: &str = ".partial";
29
38
const DOWNLOAD_CHUNK: usize = 64 * 1024;
30
39
const SHA256_PREFIX: &str = "sha256:";
@@ -1,4 +1,7 @@1
#![cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]1
#![cfg_attr(2
not(any(windows, target_os = "linux", target_os = "macos")),3
allow(dead_code)4
)]2
5
3
use std::cmp::Ordering;6
use std::cmp::Ordering;4
use std::fs;7
use std::fs;@@ -17,14 +20,20 @@ pub const CHECK_INTERVAL: Duration = Duration::from_secs(6 * 60 * 60);17
const RELEASES_URL: &str =20
const RELEASES_URL: &str =18
"https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";21
"https://api.github.com/repos/danieldaeschle/rusty-teams/releases?per_page=10";19
/// The release asset this platform installs, and the magic bytes it must start with.22
/// The release asset this platform installs, and the magic bytes it must start with.20
#[cfg(not(target_os = "linux"))]23
#[cfg(windows)]21
const ASSET_SUFFIX: &str = "-windows-amd64.exe";24
const ASSET_SUFFIX: &str = "-windows-amd64.exe";22
#[cfg(not(target_os = "linux"))]25
#[cfg(windows)]23
const EXECUTABLE_MAGIC: &[u8] = b"MZ";26
const EXECUTABLE_MAGIC: &[u8] = b"MZ";24
#[cfg(target_os = "linux")]27
#[cfg(target_os = "linux")]25
const ASSET_SUFFIX: &str = "-linux-amd64";28
const ASSET_SUFFIX: &str = "-linux-amd64";26
#[cfg(target_os = "linux")]29
#[cfg(target_os = "linux")]27
const EXECUTABLE_MAGIC: &[u8] = b"\x7fELF";30
const EXECUTABLE_MAGIC: &[u8] = b"\x7fELF";31
/// macOS and any other target still compile. The suffix matches no release asset,32
/// so the feed stays idle. macOS updates by replacing the `.app`, not a Mach-O in place.33
#[cfg(not(any(windows, target_os = "linux")))]34
const ASSET_SUFFIX: &str = "-unsupported";35
#[cfg(not(any(windows, target_os = "linux")))]36
const EXECUTABLE_MAGIC: &[u8] = b"\0unsupported";28
const PARTIAL_SUFFIX: &str = ".partial";37
const PARTIAL_SUFFIX: &str = ".partial";29
const DOWNLOAD_CHUNK: usize = 64 * 1024;38
const DOWNLOAD_CHUNK: usize = 64 * 1024;30
const SHA256_PREFIX: &str = "sha256:";39
const SHA256_PREFIX: &str = "sha256:";@@ -1,4 +1,7 @@
1
#![cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]
1
#![cfg_attr(
2
not(any(windows, target_os = "linux", target_os = "macos")),
3
allow(dead_code)
4
)]
2
5
3
6
use std::io;
4
7
use std::path::{Path, PathBuf};
@@ -263,15 +266,24 @@ mod platform {
263
266
264
267
/// Whether this build may replace itself from GitHub releases. On Linux only the copy
265
268
/// installed in `~/.local/share/rusty-teams` updates; a binary run from a
266
/// build folder or a package location is left alone.
269
/// build folder or a package location is left alone. macOS ships a `.app` and does not
270
/// swap its Mach-O in place.
267
271
pub fn self_update_allowed() -> bool {
268
272
#[cfg(target_os = "linux")]
269
return std::env::current_exe().is_ok_and(|executable| {
270
crate::linux_desktop::Layout::current()
271
.is_some_and(|layout| crate::linux_desktop::is_installed(&executable, &layout))
272
});
273
#[cfg(not(target_os = "linux"))]
274
true
273
{
274
return std::env::current_exe().is_ok_and(|executable| {
275
crate::linux_desktop::Layout::current()
276
.is_some_and(|layout| crate::linux_desktop::is_installed(&executable, &layout))
277
});
278
}
279
#[cfg(windows)]
280
{
281
return true;
282
}
283
#[cfg(not(any(windows, target_os = "linux")))]
284
{
285
false
286
}
275
287
}
276
288
277
289
/// Reading the new exe once lets the virus scanner finish before the restart, which otherwise blocks process start for seconds.
@@ -1,4 +1,7 @@1
#![cfg_attr(not(any(windows, target_os = "linux")), allow(dead_code))]1
#![cfg_attr(2
not(any(windows, target_os = "linux", target_os = "macos")),3
allow(dead_code)4
)]2
5
3
use std::io;6
use std::io;4
use std::path::{Path, PathBuf};7
use std::path::{Path, PathBuf};@@ -263,15 +266,24 @@ mod platform {263
266
264
/// Whether this build may replace itself from GitHub releases. On Linux only the copy267
/// Whether this build may replace itself from GitHub releases. On Linux only the copy265
/// installed in `~/.local/share/rusty-teams` updates; a binary run from a268
/// installed in `~/.local/share/rusty-teams` updates; a binary run from a266
/// build folder or a package location is left alone.269
/// build folder or a package location is left alone. macOS ships a `.app` and does not270
/// swap its Mach-O in place.267
pub fn self_update_allowed() -> bool {271
pub fn self_update_allowed() -> bool {268
#[cfg(target_os = "linux")]272
#[cfg(target_os = "linux")]269
return std::env::current_exe().is_ok_and(|executable| {273
{270
crate::linux_desktop::Layout::current()274
return std::env::current_exe().is_ok_and(|executable| {271
.is_some_and(|layout| crate::linux_desktop::is_installed(&executable, &layout))275
crate::linux_desktop::Layout::current()272
});276
.is_some_and(|layout| crate::linux_desktop::is_installed(&executable, &layout))273
#[cfg(not(target_os = "linux"))]277
});274
true278
}279
#[cfg(windows)]280
{281
return true;282
}283
#[cfg(not(any(windows, target_os = "linux")))]284
{285
false286
}275
}287
}276
288
277
/// Reading the new exe once lets the virus scanner finish before the restart, which otherwise blocks process start for seconds.289
/// Reading the new exe once lets the virus scanner finish before the restart, which otherwise blocks process start for seconds.@@ -1,8 +1,9 @@
1
1
//! Owns the main window so it can be closed into the tray and opened again.
2
2
//!
3
//! GPUI cannot hide a window on Wayland, so on Linux "close to tray" really closes
4
//! the main window while the app (tray, notifications, calls) keeps running; the tray
5
//! or a second start opens a fresh one. Windows hides the window natively instead.
3
//! GPUI cannot hide a window on Wayland, so on Linux (and macOS, which reuses this
4
//! path) "close to tray" really closes the main window while the app (tray,
5
//! notifications, calls) keeps running; the tray or a second start opens a fresh one.
6
//! Windows hides the window natively instead.
6
7
7
8
use std::rc::Rc;
8
9
@@ -1,8 +1,9 @@1
//! Owns the main window so it can be closed into the tray and opened again.1
//! Owns the main window so it can be closed into the tray and opened again.2
//!2
//!3
//! GPUI cannot hide a window on Wayland, so on Linux "close to tray" really closes3
//! GPUI cannot hide a window on Wayland, so on Linux (and macOS, which reuses this4
//! the main window while the app (tray, notifications, calls) keeps running; the tray4
//! path) "close to tray" really closes the main window while the app (tray,5
//! or a second start opens a fresh one. Windows hides the window natively instead.5
//! notifications, calls) keeps running; the tray or a second start opens a fresh one.6
//! Windows hides the window natively instead.6
7
7
use std::rc::Rc;8
use std::rc::Rc;8
9
@@ -359,7 +359,7 @@ impl NotificationCenter {
359
359
pub fn start_in_background(&self, window: &mut Window, cx: &mut App) {
360
360
match (&self.tray, self.main_native) {
361
361
(Some(_), Some(native)) => platform::hide_window(native),
362
#[cfg(target_os = "linux")]
362
#[cfg(any(target_os = "linux", target_os = "macos"))]
363
363
(Some(_), None) => crate::main_window::hide(cx),
364
364
_ => window.minimize_window(),
365
365
}
@@ -374,7 +374,7 @@ impl NotificationCenter {
374
374
platform::hide_window(native);
375
375
true
376
376
}
377
#[cfg(target_os = "linux")]
377
#[cfg(any(target_os = "linux", target_os = "macos"))]
378
378
(true, Some(_), None) => {
379
379
crate::main_window::mark_hiding(cx);
380
380
false
@@ -1552,7 +1552,7 @@ impl NotificationCenter {
1552
1552
if let Some(native) = self.main_native {
1553
1553
platform::hide_window(native);
1554
1554
} else {
1555
#[cfg(target_os = "linux")]
1555
#[cfg(any(target_os = "linux", target_os = "macos"))]
1556
1556
crate::main_window::hide(cx);
1557
1557
}
1558
1558
} else {
@@ -1567,7 +1567,7 @@ impl NotificationCenter {
1567
1567
}
1568
1568
1569
1569
fn raise_main_window(&mut self, cx: &mut Context<Self>) {
1570
#[cfg(target_os = "linux")]
1570
#[cfg(any(target_os = "linux", target_os = "macos"))]
1571
1571
if crate::main_window::is_hidden(cx) {
1572
1572
crate::main_window::show(cx);
1573
1573
return;
@@ -359,7 +359,7 @@ impl NotificationCenter {359
pub fn start_in_background(&self, window: &mut Window, cx: &mut App) {359
pub fn start_in_background(&self, window: &mut Window, cx: &mut App) {360
match (&self.tray, self.main_native) {360
match (&self.tray, self.main_native) {361
(Some(_), Some(native)) => platform::hide_window(native),361
(Some(_), Some(native)) => platform::hide_window(native),362
#[cfg(target_os = "linux")]362
#[cfg(any(target_os = "linux", target_os = "macos"))]363
(Some(_), None) => crate::main_window::hide(cx),363
(Some(_), None) => crate::main_window::hide(cx),364
_ => window.minimize_window(),364
_ => window.minimize_window(),365
}365
}@@ -374,7 +374,7 @@ impl NotificationCenter {374
platform::hide_window(native);374
platform::hide_window(native);375
true375
true376
}376
}377
#[cfg(target_os = "linux")]377
#[cfg(any(target_os = "linux", target_os = "macos"))]378
(true, Some(_), None) => {378
(true, Some(_), None) => {379
crate::main_window::mark_hiding(cx);379
crate::main_window::mark_hiding(cx);380
false380
false@@ -1552,7 +1552,7 @@ impl NotificationCenter {1552
if let Some(native) = self.main_native {1552
if let Some(native) = self.main_native {1553
platform::hide_window(native);1553
platform::hide_window(native);1554
} else {1554
} else {1555
#[cfg(target_os = "linux")]1555
#[cfg(any(target_os = "linux", target_os = "macos"))]1556
crate::main_window::hide(cx);1556
crate::main_window::hide(cx);1557
}1557
}1558
} else {1558
} else {@@ -1567,7 +1567,7 @@ impl NotificationCenter {1567
}1567
}1568
1568
1569
fn raise_main_window(&mut self, cx: &mut Context<Self>) {1569
fn raise_main_window(&mut self, cx: &mut Context<Self>) {1570
#[cfg(target_os = "linux")]1570
#[cfg(any(target_os = "linux", target_os = "macos"))]1571
if crate::main_window::is_hidden(cx) {1571
if crate::main_window::is_hidden(cx) {1572
crate::main_window::show(cx);1572
crate::main_window::show(cx);1573
return;1573
return;@@ -67,6 +67,11 @@ pub(crate) fn is_chrome_image(image_name: &str) -> bool {
67
67
lowered.starts_with("chrome")
68
68
|| lowered.starts_with("google chrome")
69
69
|| lowered.starts_with("chromium")
70
|| lowered.starts_with("microsoft edge")
71
|| lowered.starts_with("msedge")
72
|| lowered.starts_with("brave")
73
|| lowered.starts_with("helium")
74
|| lowered.starts_with("vivaldi")
70
75
}
71
76
72
77
pub(crate) fn is_firefox_image(image_name: &str) -> bool {
@@ -168,6 +173,16 @@ mod tests {
168
173
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
169
174
));
170
175
assert!(is_chrome_image("/usr/bin/chromium"));
176
assert!(is_chrome_image(
177
"/Applications/Helium.app/Contents/MacOS/Helium"
178
));
179
assert!(is_chrome_image(
180
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"
181
));
182
assert!(is_chrome_image(
183
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"
184
));
185
assert!(is_chrome_image("Vivaldi"));
171
186
assert!(!is_chrome_image("\"wslrelay.exe\""));
172
187
assert!(!is_chrome_image(
173
188
"/Applications/Firefox.app/Contents/MacOS/firefox"
@@ -67,6 +67,11 @@ pub(crate) fn is_chrome_image(image_name: &str) -> bool {67
lowered.starts_with("chrome")67
lowered.starts_with("chrome")68
|| lowered.starts_with("google chrome")68
|| lowered.starts_with("google chrome")69
|| lowered.starts_with("chromium")69
|| lowered.starts_with("chromium")70
|| lowered.starts_with("microsoft edge")71
|| lowered.starts_with("msedge")72
|| lowered.starts_with("brave")73
|| lowered.starts_with("helium")74
|| lowered.starts_with("vivaldi")70
}75
}71
76
72
pub(crate) fn is_firefox_image(image_name: &str) -> bool {77
pub(crate) fn is_firefox_image(image_name: &str) -> bool {@@ -168,6 +173,16 @@ mod tests {168
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"173
"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"169
));174
));170
assert!(is_chrome_image("/usr/bin/chromium"));175
assert!(is_chrome_image("/usr/bin/chromium"));176
assert!(is_chrome_image(177
"/Applications/Helium.app/Contents/MacOS/Helium"178
));179
assert!(is_chrome_image(180
"/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge"181
));182
assert!(is_chrome_image(183
"/Applications/Brave Browser.app/Contents/MacOS/Brave Browser"184
));185
assert!(is_chrome_image("Vivaldi"));171
assert!(!is_chrome_image("\"wslrelay.exe\""));186
assert!(!is_chrome_image("\"wslrelay.exe\""));172
assert!(!is_chrome_image(187
assert!(!is_chrome_image(173
"/Applications/Firefox.app/Contents/MacOS/firefox"188
"/Applications/Firefox.app/Contents/MacOS/firefox"@@ -0,0 +1,26 @@
1
---
2
status: proposed
3
date: 2026-11-15
4
---
5
6
# ADR 0018: macOS tray and close-to-tray match Linux
7
8
Upstream already shipped Linux desktop toasts as ADR 0015, so this macOS tray note is 0018.
9
10
## Context
11
12
Linux already has a StatusNotifierItem tray and closes the main window into the tray because GPUI cannot hide a Wayland window (ADR 0012). macOS daily-driver use needs the same affordances: a menu-bar icon with presence / Open / Quit, and Settings → Close to tray. Native window hide is unreliable enough across GPUI versions that reusing the Linux “really close, reopen from tray” path is simpler than a separate Cocoa hide path.
13
14
Windows already uses `tray-icon`; macOS can share that crate instead of inventing a third tray stack.
15
16
## Decision
17
18
- On macOS, the tray is `tray-icon` (same implementation as Windows).
19
- Close to tray on macOS follows the Linux path: the main window closes for real; the tray (or a second start) opens a fresh one.
20
- Message toasts stay on the existing GPUI / Windows card path for now. macOS Notification Center is a follow-up once the shared desktop-notification policy from the Linux toast work lands.
21
22
## Consequences
23
24
- One close-to-tray mental model for Linux and macOS.
25
- Signing / notarization still matter for TCC and Gatekeeper; packaging scripts may ship a bare Mach-O or a signed `.app`.
26
- Contributors should not add a macOS-only hide path without revisiting this ADR.
@@ -0,0 +1,26 @@1
---2
status: proposed3
date: 2026-11-154
---5
6
# ADR 0018: macOS tray and close-to-tray match Linux7
8
Upstream already shipped Linux desktop toasts as ADR 0015, so this macOS tray note is 0018.9
10
## Context11
12
Linux already has a StatusNotifierItem tray and closes the main window into the tray because GPUI cannot hide a Wayland window (ADR 0012). macOS daily-driver use needs the same affordances: a menu-bar icon with presence / Open / Quit, and Settings → Close to tray. Native window hide is unreliable enough across GPUI versions that reusing the Linux “really close, reopen from tray” path is simpler than a separate Cocoa hide path.13
14
Windows already uses `tray-icon`; macOS can share that crate instead of inventing a third tray stack.15
16
## Decision17
18
- On macOS, the tray is `tray-icon` (same implementation as Windows).19
- Close to tray on macOS follows the Linux path: the main window closes for real; the tray (or a second start) opens a fresh one.20
- Message toasts stay on the existing GPUI / Windows card path for now. macOS Notification Center is a follow-up once the shared desktop-notification policy from the Linux toast work lands.21
22
## Consequences23
24
- One close-to-tray mental model for Linux and macOS.25
- Signing / notarization still matter for TCC and Gatekeeper; packaging scripts may ship a bare Mach-O or a signed `.app`.26
- Contributors should not add a macOS-only hide path without revisiting this ADR.@@ -35,5 +35,6 @@ Statuses: `proposed`, `accepted`, `superseded`.
35
35
| [0017](0017-guest-orgs-switch-by-restart.md) | Guest orgs, one org per window, switch by restart |
36
36
| [0018](0018-regional-format-is-separate-from-the-app-language.md) | Regional format is separate from the app language |
37
37
| [0019](0019-caldav-app-password-and-keyring.md) | CalDAV with app password and OS keyring |
38
| [0018](0018-macos-tray-and-close-to-tray.md) | macOS tray and close-to-tray match Linux |
38
39
39
40
Records `0001` to `0019` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.
@@ -35,5 +35,6 @@ Statuses: `proposed`, `accepted`, `superseded`.35
| [0017](0017-guest-orgs-switch-by-restart.md) | Guest orgs, one org per window, switch by restart |35
| [0017](0017-guest-orgs-switch-by-restart.md) | Guest orgs, one org per window, switch by restart |36
| [0018](0018-regional-format-is-separate-from-the-app-language.md) | Regional format is separate from the app language |36
| [0018](0018-regional-format-is-separate-from-the-app-language.md) | Regional format is separate from the app language |37
| [0019](0019-caldav-app-password-and-keyring.md) | CalDAV with app password and OS keyring |37
| [0019](0019-caldav-app-password-and-keyring.md) | CalDAV with app password and OS keyring |38
| [0018](0018-macos-tray-and-close-to-tray.md) | macOS tray and close-to-tray match Linux |38
39
39
Records `0001` to `0019` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.40
Records `0001` to `0019` are the decisions already shipped. `0001` follows Daniel's call-window note in `GUARDRAILS.md`.@@ -0,0 +1,33 @@
1
# macOS smoke checklist
2
3
Run on a real Mac (`.app` from `scripts/build-macos.sh` or a release zip). Unit tests on the `macos-arm64` Forgejo runner cover picker frames and browser discovery; this list is the live gate for a daily-driver RC.
4
5
## Sign-in
6
7
1. No Google Chrome installed (or rename it) — only Helium / Edge / Brave / Vivaldi under `/Applications`.
8
2. Cold start without `--endpoint`: managed browser opens, splash shows a connecting phase, Microsoft login completes.
9
3. Quit and start again: sidebar paints from cache without a spinner wall; browser stays headless.
10
4. Second Dock click focuses the existing window (single instance).
11
12
## Calls and screen share
13
14
1. Echo / test call: mic and speaker work; hang up cleans up.
15
2. Start screen share: ScreenCaptureKit picker stays open until you pick or cancel (no portal-unavailable flash).
16
3. Pick a display or window: share banner shows; stop share leaves the call up.
17
4. Cancel the picker: no share, call stays connected, no error toast.
18
5. Prefer a second person for 1:1 ring / accept when available (ROADMAP still Partial without that).
19
20
## Desktop integration
21
22
1. Menu-bar tray icon appears; Open / presence / Quit work.
23
2. Settings → General → Close to tray: close hides/reopens via the tray (new window path like Linux).
24
3. Incoming chat still uses in-app toasts on this branch (Notification Center is a follow-up after the Linux desktop-toast path).
25
26
## Packaging
27
28
1. Unsigned local build: TCC prompts for mic / camera / screen when first used.
29
2. Signed + notarized build (when `MACOS_CODESIGN_IDENTITY` / `MACOS_NOTARY_PROFILE` are set): Gatekeeper opens without a right-click override.
30
31
## Report
32
33
Note OS version, browser used for sign-in, which checklist rows passed, and anything skipped. No real names, chats, ids or tokens in tickets or screenshots — use `--demo` for UI shots.
@@ -0,0 +1,33 @@1
# macOS smoke checklist2
3
Run on a real Mac (`.app` from `scripts/build-macos.sh` or a release zip). Unit tests on the `macos-arm64` Forgejo runner cover picker frames and browser discovery; this list is the live gate for a daily-driver RC.4
5
## Sign-in6
7
1. No Google Chrome installed (or rename it) — only Helium / Edge / Brave / Vivaldi under `/Applications`.8
2. Cold start without `--endpoint`: managed browser opens, splash shows a connecting phase, Microsoft login completes.9
3. Quit and start again: sidebar paints from cache without a spinner wall; browser stays headless.10
4. Second Dock click focuses the existing window (single instance).11
12
## Calls and screen share13
14
1. Echo / test call: mic and speaker work; hang up cleans up.15
2. Start screen share: ScreenCaptureKit picker stays open until you pick or cancel (no portal-unavailable flash).16
3. Pick a display or window: share banner shows; stop share leaves the call up.17
4. Cancel the picker: no share, call stays connected, no error toast.18
5. Prefer a second person for 1:1 ring / accept when available (ROADMAP still Partial without that).19
20
## Desktop integration21
22
1. Menu-bar tray icon appears; Open / presence / Quit work.23
2. Settings → General → Close to tray: close hides/reopens via the tray (new window path like Linux).24
3. Incoming chat still uses in-app toasts on this branch (Notification Center is a follow-up after the Linux desktop-toast path).25
26
## Packaging27
28
1. Unsigned local build: TCC prompts for mic / camera / screen when first used.29
2. Signed + notarized build (when `MACOS_CODESIGN_IDENTITY` / `MACOS_NOTARY_PROFILE` are set): Gatekeeper opens without a right-click override.30
31
## Report32
33
Note OS version, browser used for sign-in, which checklist rows passed, and anything skipped. No real names, chats, ids or tokens in tickets or screenshots — use `--demo` for UI shots.@@ -1,6 +1,13 @@
1
1
#!/usr/bin/env bash
2
2
# Build a universal macOS binary (arm64 + x86_64) from a crate. Needs Xcode CLT only.
3
3
# Wraps it in a .app bundle (icon, Info.plist) and zips that for distribution.
4
# The published artifact is the `.app` zip. There is no in-app Mach-O swap.
5
#
6
# Optional signing / notarization when Apple credentials are present:
7
# MACOS_CODESIGN_IDENTITY e.g. "Developer ID Application: …"
8
# MACOS_NOTARY_PROFILE notarytool keychain profile (from `xcrun notarytool store-credentials`)
9
# Without those env vars the .app stays unsigned (fine for local / internal RC).
10
#
4
11
# Usage: scripts/build-macos.sh [crate-dir, default crates/app] [binary-or-example-name, default: the crate's only binary]
5
12
set -euo pipefail
6
13
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
@@ -8,6 +15,7 @@ crateDir="$(realpath "${1:-$repoRoot/crates/app}")"
8
15
binaryName="${2:-}"
9
16
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repoRoot/target}"
10
17
export PATH="$HOME/.cargo/bin:$PATH"
18
entitlements="$repoRoot/scripts/macos/RustyTeams.entitlements"
11
19
targets=(aarch64-apple-darwin x86_64-apple-darwin)
12
20
13
21
rustup target add "${targets[@]}" >/dev/null
@@ -98,8 +106,33 @@ cp "$iconset/icon_64x64.png" "$iconset/icon_32x32@2x.png"
98
106
cp "$iconset/icon_256x256.png" "$iconset/icon_128x128@2x.png"
99
107
iconutil -c icns "$iconset" -o "$app/Contents/Resources/icon.icns"
100
108
101
# ditto keeps the bundle intact (plain zip would not); the result is the release asset.
109
# Developer ID signing when a certificate is configured in the build environment.
110
if [ -n "${MACOS_CODESIGN_IDENTITY:-}" ]; then
111
echo "codesign with $MACOS_CODESIGN_IDENTITY"
112
codesign --force --options runtime --timestamp \
113
--entitlements "$entitlements" \
114
--sign "$MACOS_CODESIGN_IDENTITY" \
115
"$app/Contents/MacOS/$binary"
116
codesign --force --options runtime --timestamp \
117
--entitlements "$entitlements" \
118
--sign "$MACOS_CODESIGN_IDENTITY" \
119
"$app"
120
codesign --verify --deep --strict --verbose=2 "$app"
121
fi
122
123
# ditto keeps the bundle intact (plain zip would not); the result is the .app release asset.
102
124
ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"
103
125
126
if [ -n "${MACOS_CODESIGN_IDENTITY:-}" ] && [ -n "${MACOS_NOTARY_PROFILE:-}" ]; then
127
echo "notarize with profile $MACOS_NOTARY_PROFILE"
128
xcrun notarytool submit "$outputDirectory/teams-macos.zip" \
129
--keychain-profile "$MACOS_NOTARY_PROFILE" \
130
--wait
131
xcrun stapler staple "$app"
132
# Re-zip after staple so the published .app zip carries the ticket.
133
ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"
134
fi
135
104
136
file "$output"
105
ls -la "$output" "$app/Contents/MacOS/$binary" "$outputDirectory/teams-macos.zip"
137
ls -la "$output" "$app/Contents/MacOS/$binary" \
138
"$outputDirectory/teams-macos.zip"
@@ -1,6 +1,13 @@1
#!/usr/bin/env bash1
#!/usr/bin/env bash2
# Build a universal macOS binary (arm64 + x86_64) from a crate. Needs Xcode CLT only.2
# Build a universal macOS binary (arm64 + x86_64) from a crate. Needs Xcode CLT only.3
# Wraps it in a .app bundle (icon, Info.plist) and zips that for distribution.3
# Wraps it in a .app bundle (icon, Info.plist) and zips that for distribution.4
# The published artifact is the `.app` zip. There is no in-app Mach-O swap.5
#6
# Optional signing / notarization when Apple credentials are present:7
# MACOS_CODESIGN_IDENTITY e.g. "Developer ID Application: …"8
# MACOS_NOTARY_PROFILE notarytool keychain profile (from `xcrun notarytool store-credentials`)9
# Without those env vars the .app stays unsigned (fine for local / internal RC).10
#4
# Usage: scripts/build-macos.sh [crate-dir, default crates/app] [binary-or-example-name, default: the crate's only binary]11
# Usage: scripts/build-macos.sh [crate-dir, default crates/app] [binary-or-example-name, default: the crate's only binary]5
set -euo pipefail12
set -euo pipefail6
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"13
repoRoot="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"@@ -8,6 +15,7 @@ crateDir="$(realpath "${1:-$repoRoot/crates/app}")"8
binaryName="${2:-}"15
binaryName="${2:-}"9
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repoRoot/target}"16
export CARGO_TARGET_DIR="${CARGO_TARGET_DIR:-$repoRoot/target}"10
export PATH="$HOME/.cargo/bin:$PATH"17
export PATH="$HOME/.cargo/bin:$PATH"18
entitlements="$repoRoot/scripts/macos/RustyTeams.entitlements"11
targets=(aarch64-apple-darwin x86_64-apple-darwin)19
targets=(aarch64-apple-darwin x86_64-apple-darwin)12
20
13
rustup target add "${targets[@]}" >/dev/null21
rustup target add "${targets[@]}" >/dev/null@@ -98,8 +106,33 @@ cp "$iconset/icon_64x64.png" "$iconset/icon_32x32@2x.png"98
cp "$iconset/icon_256x256.png" "$iconset/icon_128x128@2x.png"106
cp "$iconset/icon_256x256.png" "$iconset/icon_128x128@2x.png"99
iconutil -c icns "$iconset" -o "$app/Contents/Resources/icon.icns"107
iconutil -c icns "$iconset" -o "$app/Contents/Resources/icon.icns"100
108
101
# ditto keeps the bundle intact (plain zip would not); the result is the release asset.109
# Developer ID signing when a certificate is configured in the build environment.110
if [ -n "${MACOS_CODESIGN_IDENTITY:-}" ]; then111
echo "codesign with $MACOS_CODESIGN_IDENTITY"112
codesign --force --options runtime --timestamp \113
--entitlements "$entitlements" \114
--sign "$MACOS_CODESIGN_IDENTITY" \115
"$app/Contents/MacOS/$binary"116
codesign --force --options runtime --timestamp \117
--entitlements "$entitlements" \118
--sign "$MACOS_CODESIGN_IDENTITY" \119
"$app"120
codesign --verify --deep --strict --verbose=2 "$app"121
fi122
123
# ditto keeps the bundle intact (plain zip would not); the result is the .app release asset.102
ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"124
ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"103
125
126
if [ -n "${MACOS_CODESIGN_IDENTITY:-}" ] && [ -n "${MACOS_NOTARY_PROFILE:-}" ]; then127
echo "notarize with profile $MACOS_NOTARY_PROFILE"128
xcrun notarytool submit "$outputDirectory/teams-macos.zip" \129
--keychain-profile "$MACOS_NOTARY_PROFILE" \130
--wait131
xcrun stapler staple "$app"132
# Re-zip after staple so the published .app zip carries the ticket.133
ditto -c -k --keepParent "$app" "$outputDirectory/teams-macos.zip"134
fi135
104
file "$output"136
file "$output"105
ls -la "$output" "$app/Contents/MacOS/$binary" "$outputDirectory/teams-macos.zip"137
ls -la "$output" "$app/Contents/MacOS/$binary" \138
"$outputDirectory/teams-macos.zip"@@ -0,0 +1,16 @@
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
<plist version="1.0">
4
<dict>
5
<!-- Hardened Runtime for notarization; keep JIT off. -->
6
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
7
<false/>
8
<key>com.apple.security.device.audio-input</key>
9
<true/>
10
<key>com.apple.security.device.camera</key>
11
<true/>
12
<!-- ScreenCaptureKit system picker; not the legacy screen-capture entitlement alone. -->
13
<key>com.apple.security.cs.disable-library-validation</key>
14
<true/>
15
</dict>
16
</plist>
@@ -0,0 +1,16 @@1
<?xml version="1.0" encoding="UTF-8"?>2
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">3
<plist version="1.0">4
<dict>5
<!-- Hardened Runtime for notarization; keep JIT off. -->6
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>7
<false/>8
<key>com.apple.security.device.audio-input</key>9
<true/>10
<key>com.apple.security.device.camera</key>11
<true/>12
<!-- ScreenCaptureKit system picker; not the legacy screen-capture entitlement alone. -->13
<key>com.apple.security.cs.disable-library-validation</key>14
<true/>15
</dict>16
</plist>