forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcategory.ts
More file actions
20 lines (18 loc) · 975 Bytes
/
Copy pathcategory.ts
File metadata and controls
20 lines (18 loc) · 975 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import type { UsageCategory } from '../../shared/types'
// Deterministic exe-basename → coarse category map. Matched against the lowercased
// basename without extension. Substring match so variants ("chrome", "chrome_proxy")
// land in the same bucket. Unknown apps fall through to 'other'.
const RULES: ReadonlyArray<[UsageCategory, readonly string[]]> = [
['browser', ['chrome', 'msedge', 'firefox', 'opera', 'brave', 'arc', 'vivaldi']],
['editor', ['code', 'devenv', 'idea', 'pycharm', 'webstorm', 'sublime', 'notepad++', 'rider', 'cursor']],
['comms', ['slack', 'discord', 'teams', 'zoom', 'telegram', 'whatsapp', 'outlook']],
['media', ['spotify', 'vlc', 'wmplayer', 'itunes', 'foobar2000']]
]
export function categorize(exeName: string): UsageCategory {
const base = exeName.toLowerCase().replace(/\.exe$/, '')
if (!base) return 'other'
for (const [cat, keys] of RULES) {
if (keys.some((k) => base.includes(k))) return cat
}
return 'other'
}