MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / detectPlatformTheme

Function detectPlatformTheme

cli/src/utils/theme-system.ts:831–873  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

829}
830
831export function detectPlatformTheme(): ThemeName {
832 if (typeof Bun !== 'undefined') {
833 if (process.platform === 'darwin') {
834 const value = runSystemCommand([
835 'defaults',
836 'read',
837 '-g',
838 'AppleInterfaceStyle',
839 ])
840 if (value?.toLowerCase() === 'dark') return 'dark'
841 return 'light'
842 }
843
844 if (process.platform === 'win32') {
845 // Try PowerShell background color detection first
846 const powershellTheme = detectWindowsPowerShellTheme()
847 if (powershellTheme) return powershellTheme
848
849 // Fallback to Windows system theme
850 const value = runSystemCommand([
851 'powershell',
852 '-NoProfile',
853 '-Command',
854 '(Get-ItemProperty -Path HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize).AppsUseLightTheme',
855 ])
856 if (value === '0') return 'dark'
857 if (value === '1') return 'light'
858 }
859
860 if (process.platform === 'linux') {
861 const value = runSystemCommand([
862 'gsettings',
863 'get',
864 'org.gnome.desktop.interface',
865 'color-scheme',
866 ])
867 if (value?.toLowerCase().includes('dark')) return 'dark'
868 if (value?.toLowerCase().includes('light')) return 'light'
869 }
870 }
871
872 return 'dark'
873}
874
875const DEFAULT_CHAT_THEMES: Record<ThemeName, ChatTheme> = {
876 dark: {

Callers 3

detectVSCodeThemeFunction · 0.85
detectJetBrainsThemeFunction · 0.85
detectZedThemeFunction · 0.85

Calls 2

runSystemCommandFunction · 0.85

Tested by

no test coverage detected