Skip to content

Commit 95c0dae

Browse files
committed
Add tray icon styles and autostart support
Add monochrome tray icon variants and runtime styling plus unified autostart handling. - Add generate-tray-icons.mjs and generated tray-black.png / tray-white.png to produce 32x32 monochrome tray icons. - Implement tray icon loading, resolution (auto/black/white/color), and immediate application on theme changes and when user updates the setting. - Expose get_tray_icon_style / set_tray_icon_style Tauri commands and wire UI: Settings page control, i18n entries (en/zh), and frontend API methods. - Replace platform-specific Windows registry autostart code with tauri-plugin-autostart: use AppHandle.autolaunch() for set/get launch-at-startup and add plugin to the builder; add dependency in Cargo.toml (Cargo.lock updated). - Update package.json scripts to run tray icon generator during dev/build flows. - Improve Microsoft Store update routing: open Store updates URI for store installs and update localized copy; add InstallChannelInfo.update_url field to types. These changes let users pick a tray icon style (auto/color/black/white), apply it immediately, follow system theme when set to auto, and enable cross-platform startup-on-login behavior via the autostart plugin.
1 parent 28c4e83 commit 95c0dae

17 files changed

Lines changed: 341 additions & 76 deletions

File tree

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
99

1010
### Added
1111

12+
#### Tray Icon and Startup
13+
14+
- **Black & white tray icon options** — Appearance settings now includes a Tray Icon Style selector (Color / Black / White); the chosen style is persisted and applied immediately at runtime without restart. Black/white variants are generated from the main icon via `generate-tray-icons.mjs`
15+
- **Auto tray icon theme matching** — tray icon style now supports `Auto`; when enabled, TimeLens switches between white/black monochrome tray icons based on the current system theme (dark/light) and updates live when the theme changes
16+
- **macOS launch at startup** — startup-on-login now supported on macOS via LaunchAgent; migrated from manual Windows registry code to `tauri-plugin-autostart` for unified cross-platform (Windows + macOS) support; the Startup settings section is now shown on both platforms
17+
- **Microsoft Store update routing** — when a newer TimeLens release is detected on Microsoft Store installs, TimeLens now opens the Microsoft Store updates page directly instead of only showing a reminder
18+
1219
#### Build and Packaging Utilities
1320

1421
- Added multiple icon-processing and troubleshooting scripts for MSIX/taskbar icon workflows, including generation and one-off fix helpers

generate-tray-icons.mjs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Generate tray-ready monochrome icon variants.
4+
* Run: node generate-tray-icons.mjs
5+
*/
6+
7+
import sharp from 'sharp';
8+
import path from 'path';
9+
import { fileURLToPath } from 'url';
10+
11+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
12+
const OUT_BLACK = path.join(__dirname, 'src-tauri', 'icons', 'tray-black.png');
13+
const OUT_WHITE = path.join(__dirname, 'src-tauri', 'icons', 'tray-white.png');
14+
15+
function buildTemplateSvg(color) {
16+
// 32x32 transparent tray glyph based on TimeLens brand motif:
17+
// clock dial + hands + magnifier handle.
18+
return `
19+
<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">
20+
<g fill="none" stroke="${color}" stroke-linecap="round" stroke-linejoin="round">
21+
<circle cx="14" cy="14" r="9.5" stroke-width="2.1" />
22+
<circle cx="14" cy="14" r="7.6" stroke-width="1.3" opacity="0.5" />
23+
<path d="M14 7.6V6.2M14 21.8V20.4M7.6 14H6.2M21.8 14H20.4" stroke-width="1.8" opacity="0.9" />
24+
<path d="M14 14L10.5 11.7" stroke-width="2.1" />
25+
<path d="M14 14L18.9 11.1" stroke-width="2.1" />
26+
<path d="M14 14L11.3 18.9" stroke-width="1.5" opacity="0.9" />
27+
<circle cx="14" cy="14" r="1.15" fill="${color}" stroke="none" />
28+
<path d="M20.8 20.8L26.3 26.3" stroke-width="3" />
29+
</g>
30+
</svg>
31+
`.trim();
32+
}
33+
34+
async function writeTrayIcon(color, outPath) {
35+
const svg = buildTemplateSvg(color);
36+
await sharp(Buffer.from(svg, 'utf8'))
37+
.resize(32, 32, { fit: 'contain' })
38+
.png()
39+
.toFile(outPath);
40+
}
41+
42+
async function generate() {
43+
await writeTrayIcon('#000000', OUT_BLACK);
44+
console.log('✔ Generated:', OUT_BLACK);
45+
46+
await writeTrayIcon('#FFFFFF', OUT_WHITE);
47+
console.log('✔ Generated:', OUT_WHITE);
48+
}
49+
50+
generate().catch((err) => {
51+
console.error('generate-tray-icons failed:', err);
52+
process.exit(1);
53+
});

package.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@
1111
"build": "tsc && vite build",
1212
"preview": "vite preview",
1313
"tauri": "tauri",
14-
"tauri:dev": "tauri dev",
15-
"tauri:build": "npm run generate:icons && tauri build",
16-
"tauri:build:msi": "npm run generate:icons && tauri build --bundles msi",
17-
"tauri:build:nsis": "npm run generate:icons && tauri build --bundles nsis",
18-
"tauri:build:all": "npm run generate:icons && npm run tauri:build:msi && npm run tauri:build:nsis",
14+
"tauri:dev": "npm run gen:tray-icons && tauri dev",
15+
"tauri:build": "npm run generate:icons && npm run gen:tray-icons && tauri build",
16+
"tauri:build:msi": "npm run generate:icons && npm run gen:tray-icons && tauri build --bundles msi",
17+
"tauri:build:nsis": "npm run generate:icons && npm run gen:tray-icons && tauri build --bundles nsis",
18+
"tauri:build:all": "npm run generate:icons && npm run gen:tray-icons && npm run tauri:build:msi && npm run tauri:build:nsis",
1919
"generate:icons": "node generate-msix-icons.mjs",
20+
"gen:tray-icons": "node generate-tray-icons.mjs",
2021
"lint": "eslint src --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
2122
"typecheck": "tsc --noEmit",
2223
"test": "vitest run",

src-tauri/Cargo.lock

Lines changed: 74 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ macos-private-api = ["tauri/macos-private-api"]
2222

2323
[dependencies]
2424
tauri = { version = "2", features = ["tray-icon", "image-png", "image-ico"] }
25+
tauri-plugin-autostart = "2"
2526
tauri-plugin-shell = "2"
2627
tauri-plugin-global-shortcut = "2"
2728
tauri-plugin-notification = "2"
@@ -54,7 +55,6 @@ windows = { version = "0.58", features = [
5455
"Win32_System_ProcessStatus",
5556
"Win32_System_SystemInformation",
5657
] }
57-
winreg = "0.55"
5858

5959
[target.'cfg(target_os = "linux")'.dependencies]
6060
x11rb = "0.13"

src-tauri/icons/tray-black.png

667 Bytes
Loading

src-tauri/icons/tray-white.png

690 Bytes
Loading

0 commit comments

Comments
 (0)