Skip to content

Commit 85702c9

Browse files
authored
Add windows and linux support (#43)
* Add windows and linux support * organize colors
1 parent b2d7463 commit 85702c9

File tree

6 files changed

+138
-53
lines changed

6 files changed

+138
-53
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
strategy:
1212
fail-fast: false
1313
matrix:
14-
platform: [macos-latest]
14+
platform: [macos-latest, ubuntu-20.04, windows-latest]
1515

1616
runs-on: ${{ matrix.platform }}
1717
steps:

src-tauri/src/commands.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,39 @@ pub fn play_notification_sound(app: AppHandle) {
2525
});
2626
}
2727

28+
#[cfg(target_os = "macos")]
2829
#[tauri::command]
2930
pub fn set_icon_template(is_template: bool, app: AppHandle) {
3031
app.tray_handle().set_icon_as_template(is_template).unwrap();
32+
3133
app.tray_handle()
3234
.set_icon(tauri::Icon::Raw(
3335
include_bytes!("../icons/tray/icon.png").to_vec(),
3436
))
3537
.unwrap();
3638
}
3739

40+
#[cfg(any(target_os = "linux", target_os = "windows"))]
41+
#[tauri::command]
42+
pub fn set_icon_template(is_template: bool, app: AppHandle) {
43+
// In other systems there is no template option for tray icons
44+
// So we just simulate like it has.
45+
46+
if is_template {
47+
app.tray_handle()
48+
.set_icon(tauri::Icon::Raw(
49+
include_bytes!("../icons/128x128.png").to_vec(),
50+
))
51+
.unwrap();
52+
} else {
53+
app.tray_handle()
54+
.set_icon(tauri::Icon::Raw(
55+
include_bytes!("../icons/tray/icon.png").to_vec(),
56+
))
57+
.unwrap();
58+
}
59+
}
60+
3861
#[tauri::command]
3962
pub fn start_server(window: Window, state: State<'_, Mutex<AuthServer>>) {
4063
let mut server = state.lock().unwrap();

src-tauri/src/main.rs

Lines changed: 36 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,15 @@ use commands::{
1616
use server::AuthServer;
1717

1818
use tauri::{
19-
ActivationPolicy, App, AppHandle, GlobalWindowEvent, Manager, PhysicalPosition, SystemTray,
20-
SystemTrayEvent, WindowEvent,
19+
App, AppHandle, GlobalWindowEvent, Manager, PhysicalPosition, SystemTray, SystemTrayEvent,
20+
WindowEvent,
2121
};
22-
use window_vibrancy::{apply_vibrancy, NSVisualEffectMaterial, NSVisualEffectState};
2322

2423
fn handle_system_tray_event(app: &AppHandle, event: SystemTrayEvent) {
2524
let window = app.get_window("main").unwrap();
2625

2726
if let SystemTrayEvent::LeftClick { position, .. } = event {
28-
let win_width = window.outer_size().expect("size").width;
27+
let win_outer_size = window.outer_size().unwrap();
2928

3029
if window.is_visible().unwrap() {
3130
window.hide().unwrap();
@@ -35,17 +34,31 @@ fn handle_system_tray_event(app: &AppHandle, event: SystemTrayEvent) {
3534
window.set_focus().unwrap();
3635
}
3736

37+
window
38+
.set_position(PhysicalPosition {
39+
x: position.x,
40+
y: position.y,
41+
})
42+
.unwrap();
43+
3844
let current_monitor = window.current_monitor().unwrap().unwrap();
3945
let screen_size = current_monitor.size();
4046
let screen_position = current_monitor.position();
4147

48+
let y = if position.y > screen_size.height as f64 / 2.0 {
49+
position.y - win_outer_size.height as f64
50+
} else {
51+
position.y as f64
52+
};
53+
4254
window
4355
.set_position(PhysicalPosition {
4456
x: f64::min(
45-
position.x - win_width as f64 / 2.0,
46-
(screen_position.x as f64 + screen_size.width as f64) - win_width as f64,
57+
position.x - win_outer_size.width as f64 / 2.0,
58+
(screen_position.x as f64 + screen_size.width as f64)
59+
- win_outer_size.width as f64,
4760
),
48-
y: position.y,
61+
y,
4962
})
5063
.unwrap()
5164
}
@@ -55,15 +68,22 @@ fn handle_setup(app: &mut App) -> Result<(), Box<dyn std::error::Error>> {
5568
let win = app.get_window("main").expect("window not found");
5669

5770
let _ = win.set_always_on_top(true);
58-
app.set_activation_policy(ActivationPolicy::Accessory);
59-
60-
apply_vibrancy(
61-
&win,
62-
NSVisualEffectMaterial::HudWindow,
63-
Some(NSVisualEffectState::Active),
64-
Some(8.0),
65-
)
66-
.expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");
71+
72+
#[cfg(target_os = "macos")]
73+
{
74+
use tauri::ActivationPolicy;
75+
app.set_activation_policy(ActivationPolicy::Accessory);
76+
77+
use window_vibrancy::{apply_vibrancy, NSVisualEffectMaterial, NSVisualEffectState};
78+
79+
apply_vibrancy(
80+
&win,
81+
NSVisualEffectMaterial::HudWindow,
82+
Some(NSVisualEffectState::Active),
83+
Some(8.0),
84+
)
85+
.expect("Unsupported platform! 'apply_vibrancy' is only supported on macOS");
86+
}
6787

6888
Ok(())
6989
}

src/assets/main.scss

Lines changed: 69 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,43 @@
1+
$colors: (
2+
// Colors are: [mac, non-mac] because in macOS we use glass effect for the background.
3+
dark: (
4+
text-faded: rgb(190, 190, 190) rgb(190, 190, 190),
5+
text: rgb(255, 255, 255) rgb(255, 255, 255),
6+
gray-bright: rgb(150, 150, 150) rgb(150, 150, 150),
7+
switch-dot: rgb(200, 200, 200) rgb(200, 200, 200),
8+
gray: rgb(95, 95, 95) rgb(95, 95, 95),
9+
switch-bg: var(--gray) var(--gray),
10+
content-bg: rgba(30, 30, 30, 8) rgb(30, 30, 30),
11+
page-header-bg: rgba(43, 43, 43, .6) rgb(43, 43, 43),
12+
popover-bg: rgba(20, 20, 20, .6) rgb(26, 26, 26),
13+
bottom-bar-bg: rgba(21, 21, 21, 0.2) rgb(21, 21, 21),
14+
sidebar-bg: rgba(50, 50, 50, .75) rgb(50, 50, 50),
15+
app-border: rgb(90, 90, 90) rgb(90, 90, 90),
16+
item-bg: rgba(80, 80, 80, .3) rgb(56, 56, 56),
17+
item-hover-bg: rgba(80, 80, 80, .75) rgb(70, 70, 70),
18+
item-border-color: rgb(22, 22, 22, .3) rgb(22, 22, 22),
19+
header-border: rgb(50, 50, 50) rgb(50, 50, 50),
20+
popover-border: rgb(43, 43, 43) rgb(43, 43, 43)
21+
),
22+
light: (
23+
text-faded: rgb(20, 20, 20) rgb(30, 30, 30),
24+
text: rgb(0, 0, 0) rgb(0, 0, 0),
25+
gray-bright: rgb(105, 105, 105) rgb(115, 115, 115),
26+
gray: rgb(160, 160, 160) rgb(160, 160, 160),
27+
switch-bg: rgb(145, 145, 145) rgb(168, 168, 168),
28+
switch-dot: rgb(160, 160, 160) rgb(255, 255, 255),
29+
content-bg: rgba(220, 220, 220, .75) rgb(220, 220, 220),
30+
page-header-bg: rgba(212, 212, 212, .6) rgb(212, 212, 212),
31+
popover-bg: rgba(210, 210, 210, .8) rgb(240, 240, 240),
32+
sidebar-bg: rgba(240, 240, 240, .6) rgb(240, 240, 240),
33+
app-border: rgb(185, 185, 185) rgb(185, 185, 185),
34+
item-bg: rgba(255, 255, 255, .3) rgb(255, 255, 255),
35+
item-hover-bg: rgba(150, 150, 150, .7) rgb(235, 235, 235),
36+
item-border-color: rgb(180, 180, 180, .7) rgb(201, 201, 201),
37+
popover-border: rgb(167, 167, 167) rgb(210, 210, 210),
38+
)
39+
);
40+
141
:root {
242
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
343
font-synthesis: none;
@@ -6,44 +46,37 @@
646
-moz-osx-font-smoothing: grayscale;
747
-webkit-text-size-adjust: 100%;
848
line-height: 20px;
9-
10-
--text-faded: rgb(190, 190, 190);
11-
--text: rgb(255, 255, 255);
12-
--gray-bright: rgb(150, 150, 150);
13-
--switch-dot: rgb(200, 200, 200);
14-
--gray: rgb(95, 95, 95);
15-
--switch-bg: var(--gray);
16-
--content-bg: rgba(30, 30, 30, .8);
17-
--page-header-bg: rgba(43, 43, 43, .6);
18-
--popover-bg: rgba(20, 20, 20, .6);
19-
--popover-bg-solid: rgba(40, 40, 40);
20-
--bottom-bar-bg: rgba(21, 21, 21, 0.2);
21-
--sidebar-bg: rgba(50, 50, 50, .75);
22-
--app-border: rgb(90, 90, 90);
23-
--item-bg: rgba(80, 80, 80, .3);
24-
--item-hover-bg: rgba(80, 80, 80, .75);
25-
--item-border-color: rgb(22, 22, 22, .3);
49+
2650
--accent-color: rgb(23, 115, 243);
27-
--header-border: rgb(50, 50, 50);
2851

29-
&.light-theme {
30-
--text-faded: rgb(20, 20, 20);
31-
--text: rgb(0, 0, 0);
32-
--gray-bright: rgb(105, 105, 105);
33-
--gray: rgb(160, 160, 160);
34-
--switch-bg: rgb(145, 145, 145);
35-
--switch-dot: rgb(60, 60, 60);
36-
--content-bg: rgba(220, 220, 220, .75);
37-
--page-header-bg: rgba(212, 212, 212, .6);
38-
--popover-bg: rgba(210, 210, 210, .8);
39-
--popover-bg-solid: rgba(215, 215, 215);
40-
--bottom-bar-bg: rgba(234, 234, 234, 0.2);
41-
--sidebar-bg: rgba(240, 240, 240, .6);
42-
--app-border: rgb(185, 185, 185);
43-
--item-bg: rgba(255, 255, 255, .3);
44-
--item-hover-bg: rgba(150, 150, 150, .7);
45-
--item-border-color: rgb(180, 180, 180, .7);
46-
--popover-border: rgb(167, 167, 167);
52+
// Colors look really bad on Windows and Linux because there is no glass effect.
53+
// Some colors are different because of that.
54+
&:not([data-os-darwin]) {
55+
@each $color-name, $color-list in map-get($colors, dark) {
56+
$color: nth($color-list, 2);
57+
--#{"" + $color-name}: #{"" + $color};
58+
}
59+
60+
&.light-theme {
61+
@each $color-name, $color-list in map-get($colors, light) {
62+
$color: nth($color-list, 2);
63+
--#{"" + $color-name}: #{"" + $color};
64+
}
65+
}
66+
}
67+
68+
&[data-os-darwin] {
69+
@each $color-name, $color-list in map-get($colors, dark) {
70+
$color: nth($color-list, 1);
71+
--#{"" + $color-name}: #{"" + $color};
72+
}
73+
74+
&.light-theme {
75+
@each $color-name, $color-list in map-get($colors, light) {
76+
$color: nth($color-list, 1);
77+
--#{"" + $color-name}: #{"" + $color};
78+
}
79+
}
4780
}
4881
}
4982

src/main.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { isEnabled as isAutostartEnabled } from 'tauri-plugin-autostart-api'
88
import dayjs from 'dayjs'
99
import relativeTime from 'dayjs/plugin/relativeTime'
1010
import { isPermissionGranted } from '@tauri-apps/api/notification'
11+
import { type as osType } from '@tauri-apps/api/os'
1112
import { checkUpdate } from '@tauri-apps/api/updater'
1213
import App from './App.vue'
1314
import { AppStorage, cacheStorageFromDisk } from './storage'
@@ -58,6 +59,10 @@ async function main() {
5859
console.error(error)
5960
}
6061

62+
const os = await osType()
63+
if (os === 'Darwin')
64+
document.documentElement.setAttribute('data-os-darwin', '')
65+
6166
app.mount('#app')
6267
}
6368

src/pages/SettingsPage.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ function handleScroll(e: Event) {
282282
-webkit-backdrop-filter: blur(20px);
283283
transition: box-shadow 0.2s ease-in-out;
284284
285+
@supports not ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
286+
background-color: var(--content-bg);
287+
}
288+
285289
&-with-border {
286290
box-shadow: 0px 3px 8px -5px rgba(0, 0, 0, 0.3);
287291
}

0 commit comments

Comments
 (0)