Skip to content

armgit / plexo

Public Imported from GitHub
0

Speed up downloads by combining multiple network connections in parallel

Add brand app icon and light/dark/system theme toggle

Anmol Kapil23d034076bfa
diff --git a/build/icon.icns b/build/icon.icns
index 28644aa..203907b 100644
Binary files a/build/icon.icns and b/build/icon.icns differ
diff --git a/build/icon.ico b/build/icon.ico
index 72c391e..c4de74e 100644
Binary files a/build/icon.ico and b/build/icon.ico differ
diff --git a/build/icon.png b/build/icon.png
index cf9e8b2..9e0607f 100644
Binary files a/build/icon.png and b/build/icon.png differ
diff --git a/resources/icon-dark.png b/resources/icon-dark.png
new file mode 100644
index 0000000..9e0607f
Binary files /dev/null and b/resources/icon-dark.png differ
diff --git a/resources/icon-light.png b/resources/icon-light.png
new file mode 100644
index 0000000..7d61385
Binary files /dev/null and b/resources/icon-light.png differ
diff --git a/resources/icon.png b/resources/icon.png
deleted file mode 100644
index cf9e8b2..0000000
Binary files a/resources/icon.png and /dev/null differ
diff --git a/src/main/index.ts b/src/main/index.ts
index 077f88a..eb0b31b 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -1,14 +1,36 @@
import { electronApp, is, optimizer } from '@electron-toolkit/utils'
-import { app, BrowserWindow, nativeTheme, shell } from 'electron'
+import { app, BrowserWindow, nativeImage, nativeTheme, shell } from 'electron'
import { join } from 'path'
-import icon from '../../resources/icon.png?asset'
+import iconDark from '../../resources/icon-dark.png?asset'
+import iconLight from '../../resources/icon-light.png?asset'
import { registerIpcHandlers } from './ipc/handlers'
+import { loadThemeSource } from './settings'
import type { DownloadManager } from './download/downloadManager'
+// In dev mode the app runs as the raw `electron` binary, which otherwise shows "Electron" in
+// the Dock tooltip/menu bar — must be set before the app is ready. Packaged builds already get
+// this from electron-builder's productName, but setting it here keeps dev and packaged in sync.
+app.setName('Plexo')
+
let mainWindow: BrowserWindow | null = null
let downloadManager: DownloadManager | null = null
let quitAfterSuspending = false
+// The bundled app icon (build/icon.*) is fixed at build time, but the dock/taskbar icon
+// can still be swapped at runtime so it matches the OS's light/dark appearance live.
+function currentIconPath(): string {
+ return nativeTheme.shouldUseDarkColors ? iconDark : iconLight
+}
+
+function applyThemedIcon(): void {
+ const image = nativeImage.createFromPath(currentIconPath())
+ if (process.platform === 'darwin') {
+ app.dock?.setIcon(image)
+ } else {
+ mainWindow?.setIcon(image)
+ }
+}
+
function createWindow(): void {
mainWindow = new BrowserWindow({
width: 760,
@@ -21,7 +43,7 @@ function createWindow(): void {
// Matches the renderer's dark-mode background so a live window resize
// (which briefly exposes the raw window background) doesn't flash white.
backgroundColor: nativeTheme.shouldUseDarkColors ? '#1c1c1e' : '#ffffff',
- ...(process.platform !== 'darwin' ? { icon } : {}),
+ ...(process.platform !== 'darwin' ? { icon: currentIconPath() } : {}),
// Design v2 draws its own logo + status readout where the title normally sits — on macOS,
// keep the real traffic lights (still native, still draggable) but let the renderer's own
// title bar occupy the rest of the strip instead of an OS-drawn title.
@@ -54,9 +76,13 @@ function createWindow(): void {
}
}
-app.whenReady().then(() => {
+app.whenReady().then(async () => {
electronApp.setAppUserModelId('com.plexo.app')
+ // Applied before the window is created so the initial background/icon already match —
+ // the saved preference otherwise only takes effect on the next 'updated' event.
+ nativeTheme.themeSource = await loadThemeSource()
+
app.on('browser-window-created', (_, window) => {
optimizer.watchWindowShortcuts(window)
})
@@ -65,9 +91,11 @@ app.whenReady().then(() => {
nativeTheme.on('updated', () => {
mainWindow?.setBackgroundColor(nativeTheme.shouldUseDarkColors ? '#1c1c1e' : '#ffffff')
+ applyThemedIcon()
})
createWindow()
+ applyThemedIcon()
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
diff --git a/src/main/ipc/handlers.ts b/src/main/ipc/handlers.ts
index 20dfee1..060d4e0 100644
--- a/src/main/ipc/handlers.ts
+++ b/src/main/ipc/handlers.ts
@@ -1,9 +1,10 @@
-import { clipboard, dialog, ipcMain, shell, type BrowserWindow } from 'electron'
+import { clipboard, dialog, ipcMain, nativeTheme, shell, type BrowserWindow } from 'electron'
import { IpcChannels } from '../../shared/ipc-channels'
import type {
NetworkInterfaceInfo,
NetworkPreference,
- StartDownloadRequest
+ StartDownloadRequest,
+ ThemeSource
} from '../../shared/types'
import { DownloadManager } from '../download/downloadManager'
import { getDefaultDownloadsDir, getHomeDir } from '../download/paths'
@@ -11,6 +12,7 @@ import { probeUrl } from '../download/probe'
import { measureLatencies } from '../network/latency'
import { listActiveInterfaces } from '../network/interfaces'
import { loadNetworkPreferences, saveNetworkPreference } from '../network/preferences'
+import { saveThemeSource } from '../settings'
const NETWORK_SETTINGS_URL =
process.platform === 'win32'
@@ -42,6 +44,14 @@ export function registerIpcHandlers(getWindow: () => BrowserWindow | null): Down
async (_event, id: string, patch: NetworkPreference) => saveNetworkPreference(id, patch)
)
+ ipcMain.handle(IpcChannels.getThemeSource, async () => nativeTheme.themeSource)
+
+ ipcMain.handle(IpcChannels.setThemeSource, async (_event, source: ThemeSource) => {
+ nativeTheme.themeSource = source
+ await saveThemeSource(source)
+ return nativeTheme.themeSource
+ })
+
ipcMain.handle(IpcChannels.openNetworkSettings, async () => {
await shell.openExternal(NETWORK_SETTINGS_URL)
})
diff --git a/src/main/settings.ts b/src/main/settings.ts
new file mode 100644
index 0000000..61a5815
--- /dev/null
+++ b/src/main/settings.ts
@@ -0,0 +1,32 @@
+import { readFile, writeFile } from 'node:fs/promises'
+import { join } from 'node:path'
+import { app } from 'electron'
+import type { ThemeSource } from '../shared/types'
+
+function settingsPath(): string {
+ return join(app.getPath('userData'), 'app-settings.json')
+}
+
+interface AppSettings {
+ themeSource?: ThemeSource
+}
+
+async function loadSettings(): Promise<AppSettings> {
+ try {
+ const raw = await readFile(settingsPath(), 'utf-8')
+ return JSON.parse(raw) as AppSettings
+ } catch {
+ // No file yet (first run) or it's unreadable/corrupt — either way, no saved settings.
+ return {}
+ }
+}
+
+export async function loadThemeSource(): Promise<ThemeSource> {
+ const settings = await loadSettings()
+ return settings.themeSource ?? 'system'
+}
+
+export async function saveThemeSource(themeSource: ThemeSource): Promise<void> {
+ const settings = await loadSettings()
+ await writeFile(settingsPath(), JSON.stringify({ ...settings, themeSource }, null, 2), 'utf-8')
+}
diff --git a/src/preload/index.ts b/src/preload/index.ts
index c832d97..4d1053a 100644
--- a/src/preload/index.ts
+++ b/src/preload/index.ts
@@ -7,7 +7,8 @@ import type {
NetworkPreference,
NetworkPreferences,
ProbeResult,
- StartDownloadRequest
+ StartDownloadRequest,
+ ThemeSource
} from '../shared/types'
export interface InitialPaths {
@@ -32,6 +33,11 @@ const plexoApi = {
setNetworkPreference: (id: string, patch: NetworkPreference): Promise<NetworkPreferences> =>
ipcRenderer.invoke(IpcChannels.setNetworkPreference, id, patch),
+ getThemeSource: (): Promise<ThemeSource> => ipcRenderer.invoke(IpcChannels.getThemeSource),
+
+ setThemeSource: (source: ThemeSource): Promise<ThemeSource> =>
+ ipcRenderer.invoke(IpcChannels.setThemeSource, source),
+
probeUrl: (url: string): Promise<ProbeResult> => ipcRenderer.invoke(IpcChannels.probeUrl, url),
getInitialPaths: (): Promise<InitialPaths> => ipcRenderer.invoke(IpcChannels.getInitialPaths),
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index e08472e..b94651a 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -17,10 +17,12 @@ function App(): React.JSX.Element {
const currentDownload = useAppStore((store) => store.currentDownload)
const clearCurrentDownload = useAppStore((store) => store.clearCurrentDownload)
const loadNetworkPreferences = useAppStore((store) => store.loadNetworkPreferences)
+ const loadThemeSource = useAppStore((store) => store.loadThemeSource)
useEffect(() => {
loadNetworkPreferences()
- }, [loadNetworkPreferences])
+ loadThemeSource()
+ }, [loadNetworkPreferences, loadThemeSource])
const handleNewDownload = (): void => {
if (currentDownload) void window.plexo.removeDownload(currentDownload.id)
diff --git a/src/renderer/src/assets/main.css b/src/renderer/src/assets/main.css
index 0609292..b5915e6 100644
--- a/src/renderer/src/assets/main.css
+++ b/src/renderer/src/assets/main.css
@@ -82,6 +82,10 @@
--color-danger: #dc2626;
--color-danger-bg: #fef2f2;
--color-danger-border: #fecaca;
+
+ /* Throughput chart's total-line color — the merge node's tone from the app icon, not raw
+ text-black, so the outline reads as part of the brand instead of a harsh axis line. */
+ --node-accent: #5f6e78;
}
@media (prefers-color-scheme: dark) {
@@ -150,6 +154,8 @@
--color-danger: #eda3a3;
--color-danger-bg: #2c1c1c;
--color-danger-border: #4a2a2a;
+
+ --node-accent: #f7f4ef;
}
}
diff --git a/src/renderer/src/components/MergeDiagram.tsx b/src/renderer/src/components/MergeDiagram.tsx
index cd93199..f0358e0 100644
--- a/src/renderer/src/components/MergeDiagram.tsx
+++ b/src/renderer/src/components/MergeDiagram.tsx
@@ -56,14 +56,16 @@ export function MergeDiagram({
})}
<path
d={`M${MERGE_X},${midY} L${STREAM_END_X},${midY}`}
- stroke={muted ? 'var(--icon-muted)' : paused ? 'var(--text-secondary)' : 'var(--text)'}
+ stroke={
+ muted ? 'var(--icon-muted)' : paused ? 'var(--text-secondary)' : 'var(--node-accent)'
+ }
strokeWidth={6.5}
opacity={paused ? 0.6 : 1}
/>
</g>
<polygon
points={`${STREAM_END_X - 1},${midY - 4.5} ${STREAM_END_X + 6},${midY} ${STREAM_END_X - 1},${midY + 4.5}`}
- fill={muted ? 'var(--icon-muted)' : paused ? 'var(--text-secondary)' : 'var(--text)'}
+ fill={muted ? 'var(--icon-muted)' : paused ? 'var(--text-secondary)' : 'var(--node-accent)'}
opacity={paused ? 0.6 : 1}
/>
<circle
@@ -71,12 +73,17 @@ export function MergeDiagram({
cy={midY}
r={9.5}
fill="none"
- stroke={muted ? 'var(--icon-muted)' : 'var(--text)'}
+ stroke={muted ? 'var(--icon-muted)' : 'var(--node-accent)'}
strokeOpacity={muted ? 1 : 0.25}
strokeWidth={1.5}
strokeDasharray={muted ? '3 4' : undefined}
/>
- <circle cx={MERGE_X} cy={midY} r={3.5} fill={muted ? 'var(--icon-muted)' : 'var(--text)'} />
+ <circle
+ cx={MERGE_X}
+ cy={midY}
+ r={3.5}
+ fill={muted ? 'var(--icon-muted)' : 'var(--node-accent)'}
+ />
{networks.map((network, index) => {
const y = (index + 0.5) * (height / networks.length)
const color = muted ? 'var(--icon-muted)' : network.solid
diff --git a/src/renderer/src/components/ThemeToggle.tsx b/src/renderer/src/components/ThemeToggle.tsx
new file mode 100644
index 0000000..8f02c75
--- /dev/null
+++ b/src/renderer/src/components/ThemeToggle.tsx
@@ -0,0 +1,94 @@
+import type { ThemeSource } from '@shared/types'
+import { useAppStore } from '../store/useAppStore'
+
+const OPTIONS: { id: ThemeSource; label: string; icon: React.JSX.Element }[] = [
+ {
+ id: 'system',
+ label: 'Appearance: System',
+ icon: (
+ <svg width="15" height="15" viewBox="0 0 16 16" fill="none">
+ <rect
+ x="1.5"
+ y="2.5"
+ width="13"
+ height="9"
+ rx="1.5"
+ stroke="currentColor"
+ strokeWidth="1.3"
+ />
+ <path
+ d="M5.5 14.5h5M8 11.5v3"
+ stroke="currentColor"
+ strokeWidth="1.3"
+ strokeLinecap="round"
+ />
+ </svg>
+ )
+ },
+ {
+ id: 'light',
+ label: 'Appearance: Light',
+ icon: (
+ <svg width="15" height="15" viewBox="0 0 16 16" fill="none">
+ <circle cx="8" cy="8" r="3.2" stroke="currentColor" strokeWidth="1.3" />
+ <path
+ d="M8 1.5v1.6M8 12.9v1.6M14.5 8h-1.6M3.1 8H1.5M12.4 3.6l-1.13 1.13M4.73 11.27L3.6 12.4M12.4 12.4l-1.13-1.13M4.73 4.73L3.6 3.6"
+ stroke="currentColor"
+ strokeWidth="1.3"
+ strokeLinecap="round"
+ />
+ </svg>
+ )
+ },
+ {
+ id: 'dark',
+ label: 'Appearance: Dark',
+ icon: (
+ <svg width="15" height="15" viewBox="0 0 16 16" fill="none">
+ <path
+ d="M13.5 9.85A5.6 5.6 0 0 1 6.15 2.5a5.6 5.6 0 1 0 7.35 7.35Z"
+ stroke="currentColor"
+ strokeWidth="1.3"
+ strokeLinejoin="round"
+ />
+ </svg>
+ )
+ }
+]
+
+export function ThemeToggle(): React.JSX.Element {
+ const themeSource = useAppStore((store) => store.themeSource)
+ const setThemeSource = useAppStore((store) => store.setThemeSource)
+
+ const index = OPTIONS.findIndex((option) => option.id === themeSource)
+ const current = OPTIONS[index === -1 ? 0 : index]
+
+ const cycle = (): void => {
+ const next = OPTIONS[(Math.max(index, 0) + 1) % OPTIONS.length]
+ void setThemeSource(next.id)
+ }
+
+ return (
+ <button
+ type="button"
+ title={`${current.label} — click to change`}
+ onClick={cycle}
+ style={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'center',
+ width: 26,
+ height: 26,
+ border: '0.5px solid var(--border)',
+ borderRadius: 6,
+ background: 'var(--bg-tertiary)',
+ color: 'var(--text-secondary)',
+ cursor: 'pointer',
+ WebkitAppRegion: 'no-drag',
+ flexShrink: 0
+ }}
+ >
+ {current.icon}
+ </button>
+ )
+}
diff --git a/src/renderer/src/components/ThroughputChart.tsx b/src/renderer/src/components/ThroughputChart.tsx
index ed54039..834393a 100644
--- a/src/renderer/src/components/ThroughputChart.tsx
+++ b/src/renderer/src/components/ThroughputChart.tsx
@@ -62,7 +62,7 @@ export function ThroughputChart({
<polyline
points={outline}
fill="none"
- stroke="var(--text)"
+ stroke="var(--node-accent)"
strokeWidth={2}
strokeOpacity={0.85}
/>
diff --git a/src/renderer/src/components/TitleBar.tsx b/src/renderer/src/components/TitleBar.tsx
index a81bfd7..cdd6672 100644
--- a/src/renderer/src/components/TitleBar.tsx
+++ b/src/renderer/src/components/TitleBar.tsx
@@ -1,4 +1,5 @@
import { FONT_UI, TITLE_BAR_HEIGHT, pillStyle } from '../theme'
+import { ThemeToggle } from './ThemeToggle'
export type TitleBarStatus =
| { kind: 'none' }
@@ -27,25 +28,15 @@ export function TitleBar({ status }: { status: TitleBarStatus }): React.JSX.Elem
WebkitAppRegion: 'drag'
}}
>
- <div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
- <div
- style={{
- width: 15,
- height: 15,
- borderRadius: 4,
- background: dimmed ? 'var(--icon-muted)' : 'var(--color-accent)',
- flexShrink: 0
- }}
- />
- <div
- style={{
- font: `700 12.5px/1 ${FONT_UI}`,
- letterSpacing: '0.005em',
- color: dimmed ? 'var(--text-tertiary)' : 'var(--text)'
- }}
- >
- Plexo
- </div>
+ <div
+ style={{
+ // Matches the "LOCKUP · horizontal" wordmark spec from the final icon design.
+ font: `700 13px/1 ${FONT_UI}`,
+ letterSpacing: '-0.02em',
+ color: dimmed ? 'var(--text-tertiary)' : 'var(--text)'
+ }}
+ >
+ Plexo
</div>
<div style={{ flex: 1 }} />
{status.kind === 'merged' && (
@@ -83,6 +74,7 @@ export function TitleBar({ status }: { status: TitleBarStatus }): React.JSX.Elem
Offline
</div>
)}
+ <ThemeToggle />
</div>
)
}
diff --git a/src/renderer/src/screens/CompleteScreen.tsx b/src/renderer/src/screens/CompleteScreen.tsx
index e204639..535daa4 100644
--- a/src/renderer/src/screens/CompleteScreen.tsx
+++ b/src/renderer/src/screens/CompleteScreen.tsx
@@ -114,8 +114,8 @@ export function CompleteScreen({
width: 44,
height: 44,
borderRadius: '50%',
- background: '#22312e',
- border: '1px solid #3a5450',
+ background: 'var(--color-wifi-bg)',
+ border: '1px solid var(--color-wifi-border)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
@@ -126,7 +126,7 @@ export function CompleteScreen({
<path
d="M5,13 L10,18 L19,7"
fill="none"
- stroke="#4ea89a"
+ stroke="var(--color-wifi)"
strokeWidth={2.4}
strokeLinecap="round"
strokeLinejoin="round"
diff --git a/src/renderer/src/store/useAppStore.ts b/src/renderer/src/store/useAppStore.ts
index 56a83e0..cdcad28 100644
--- a/src/renderer/src/store/useAppStore.ts
+++ b/src/renderer/src/store/useAppStore.ts
@@ -2,7 +2,8 @@ import type {
DownloadState,
NetworkInterfaceInfo,
NetworkPreference,
- NetworkPreferences
+ NetworkPreferences,
+ ThemeSource
} from '@shared/types'
import { create } from 'zustand'
import { groupChunksByInterface } from '../utils/format'
@@ -24,6 +25,9 @@ interface AppStore {
/** User customizations (name/color) per network interface id — persisted in the main process. */
networkPreferences: NetworkPreferences
+ /** 'system' by default — persisted in the main process alongside nativeTheme.themeSource. */
+ themeSource: ThemeSource
+
homeDir: string
downloadsDir: string
pathsStatus: LoadStatus
@@ -47,6 +51,8 @@ interface AppStore {
loadInitialPaths: () => Promise<void>
loadNetworkPreferences: () => Promise<void>
setNetworkPreference: (id: string, patch: NetworkPreference) => Promise<void>
+ loadThemeSource: () => Promise<void>
+ setThemeSource: (source: ThemeSource) => Promise<void>
setCurrentDownload: (state: DownloadState) => void
clearCurrentDownload: () => void
setDraftUrl: (url: string) => void
@@ -59,6 +65,7 @@ export const useAppStore = create<AppStore>((set, get) => ({
interfacesError: null,
latencies: {},
networkPreferences: {},
+ themeSource: 'system',
homeDir: '',
downloadsDir: '',
@@ -130,6 +137,25 @@ export const useAppStore = create<AppStore>((set, get) => ({
}
},
+ loadThemeSource: async () => {
+ try {
+ const themeSource = await window.plexo.getThemeSource()
+ set({ themeSource })
+ } catch {
+ // Best-effort — a failed read just leaves the toggle showing the 'system' default.
+ }
+ },
+
+ setThemeSource: async (themeSource) => {
+ // Optimistic update, same as setNetworkPreference — the toggle should feel instant.
+ set({ themeSource })
+ try {
+ await window.plexo.setThemeSource(themeSource)
+ } catch {
+ // Leave the optimistic value in place — not persisted to disk, but still usable this session.
+ }
+ },
+
setCurrentDownload: (download) => {
const previous = get().currentDownload
const isNewDownload = !previous || previous.id !== download.id
diff --git a/src/shared/ipc-channels.ts b/src/shared/ipc-channels.ts
index 6cc9903..d9735ca 100644
--- a/src/shared/ipc-channels.ts
+++ b/src/shared/ipc-channels.ts
@@ -4,6 +4,8 @@ export const IpcChannels = {
openNetworkSettings: 'network:open-settings',
getNetworkPreferences: 'network:get-preferences',
setNetworkPreference: 'network:set-preference',
+ getThemeSource: 'theme:get-source',
+ setThemeSource: 'theme:set-source',
probeUrl: 'download:probe',
getInitialPaths: 'paths:get-initial',
chooseDestinationFolder: 'dialog:choose-destination-folder',
diff --git a/src/shared/types.ts b/src/shared/types.ts
index db02163..445ad92 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1,5 +1,8 @@
export type NetworkInterfaceKind = 'wifi' | 'usb' | 'ethernet' | 'bridge' | 'other'
+/** 'system' follows the OS appearance; 'light'/'dark' pin it regardless of the OS setting. */
+export type ThemeSource = 'system' | 'light' | 'dark'
+
export interface NetworkInterfaceInfo {
/** Stable identifier for this interface (currently the OS device name, e.g. "en0"). */
id: string