Python Sidecar

The sidecar (sidecar/kalam-core.py, compiled to kalam-core-x86_64-pc-windows-msvc.exe) handles all system-level operations. The frontend communicates with it via @tauri-apps/plugin-shell Command.sidecar().

CLI Reference

CommandArgsOutputDescription
listJSON [{id, name}]List all profiles
current{id, name} or nullCurrently active profile
apply-by-name"Profile Name"(none)Look up and apply by name
<numeric_id>(none)Apply profile by numeric ID
scan(writes manifest files)Scan all tool configs
autodetectJSON pathsAuto-detect tool install paths
stop-allStatus textStop all managed tools

Profile Application Flow

apply_profile() orchestrates the full sequence:

  1. Fetch running processes once (cached as running_names set)
  2. Apply each tool in order: Rainmeter → Wallpaper → YASB → GlazeWM → Zebar → Windhawk
  3. For each tool: check if config exists → write config → start/restart process
  4. If a tool is not in the profile but is running → kill it
  5. Set activeProfile in settings

Tool-Specific Logic

ToolApply FunctionWhat It Does
Rainmeterrainmeter()Starts exe if not running, loads layout via !LoadLayout
YASByasb_code_inject()Writes config.yaml + styles.css, starts exe if needed
GlazeWMglaze_wm_apply()Writes config.yaml, kills with graceful exit command, restarts
Zebarzebar_apply()Writes settings.json, kills and restarts
Windhawkapply_windhawk_profile()Installed: writes .reg file, runs elevated via ShellExecuteExW with runas; Portable: kills and restarts
Wallpaperset_wallpaper_all_desktops()Uses pyvda to set wallpaper across virtual desktops

Process Scan Optimization

kill_process(), is_process_running(), rainmeter(), yasb_code_inject(), glaze_wm_apply(), and zebar_apply() accept an optional running_names parameter (set of lowercase exe names). When provided, they skip redundant psutil.process_iter scans and use the pre-computed set instead. apply_profile() creates the set internally and threads it through the individual tool functions.

Windhawk Smart Restart

When applying profiles with Windhawk-Mods, the sidecar compares desired settings against current registry via _windhawk_settings_changed(). If nothing changed — re-applying the same profile or switching between profiles with identical Windhawk configs — the registry write, elevation, and service restart are skipped entirely. This avoids unnecessary UAC prompts and service interruptions.

Both scan_windhawk_registry() and _get_current_windhawk_settings() share _enumerate_windhawk_registry(), which reads from HKLM and HKCU under SOFTWARE\Windhawk\Engine\Mods and SOFTWARE\Windhawk\Mods, returning a deduplicated list.

Auto-Detect Paths

autodetect_paths() resolves tool paths dynamically using environment-aware lookups:

HelperPurpose
_first_existing(iterable)Returns first path that os.path.exists(), or ""
_program_files_dirs()Reads %ProgramW6432%, %ProgramFiles%, %ProgramFiles(x86)% — called once and reused

Detection order per tool: shutil.which()_program_files_dirs() + tool name → %LOCALAPPDATA%\Programs\<Tool>%LOCALAPPDATA%\Microsoft\WinGet\Links\<Tool>

Known Config Paths

  • YASB: YASB_CONFIG_HOME env → ~/.config/yasb/~/.yasb/
  • GlazeWM: ~/.glzr/glazewm/~/.glazewm/
  • Zebar: %APPDATA%/zebar~/.zebar/

Sidecar Internal Refactors

  • _enumerate_windhawk_registry() — shared helper, eliminates duplicate registry enumeration
  • _parse_rainmeter_ini() — handles both UTF-16-LE and UTF-8 encodings of Rainmeter.ini
  • _program_files_dirs() — called once per autodetect_paths() instead of per tool
  • kill_process()break after successful kill to avoid scanning remaining processes
  • scan_zebar_configs() — removed redundant json.loads() validation

Windhawk Mod Schema

{
  "id": "modernflyouts",
  "enabled": 1,
  "settings": { "show-labels": true, "animation-speed": 200 }
}