Skip to content

Commit

Permalink
Testing For KDE Plasma Pure
Browse files Browse the repository at this point in the history
  • Loading branch information
harshau007 committed Jul 19, 2024
1 parent cbf0286 commit 5374a1f
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 11 deletions.
62 changes: 52 additions & 10 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,31 +64,73 @@ func getDesktopEnvironment() string {
return strings.ToLower(os.Getenv("XDG_CURRENT_DESKTOP"))
}

const defaultColorScheme = "org.kde.breeze.desktop"

func getLookAndFeelPackageKDE() string {
configFile := os.ExpandEnv("$HOME/.config/kdeglobals")
configFiles := []string{
os.ExpandEnv("$HOME/.config/kdeglobals"),
os.ExpandEnv("$HOME/.kde/share/config/kdeglobals"),
"/etc/kde/kdeglobals",
}

for _, configFile := range configFiles {
colorScheme, err := getColorSchemeFromFile(configFile)
if err == nil {
return formatColorScheme(colorScheme)
}
}

return defaultColorScheme
}

func getColorSchemeFromFile(configFile string) (string, error) {
file, err := os.Open(configFile)
if err != nil {
fmt.Println("Error opening file:", err)
return "org.kde.breeze.desktop"
return "", fmt.Errorf("error opening file %s: %w", configFile, err)
}
defer file.Close()

scanner := bufio.NewScanner(file)

inGeneralSection := false
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "ColorScheme=") {
fmt.Println(strings.TrimPrefix(line, "ColorScheme="))
return strings.TrimPrefix(line, "ColorScheme=")
line := strings.TrimSpace(scanner.Text())

// Skip empty lines and comments
if line == "" || strings.HasPrefix(line, "#") {
continue
}

// Check for [General] section
if line == "[General]" {
inGeneralSection = true
continue
}

// If we're in [General] and find ColorScheme, return it
if inGeneralSection && strings.HasPrefix(line, "ColorScheme=") {
return strings.TrimPrefix(line, "ColorScheme="), nil
}

// If we've moved past [General], stop searching
if inGeneralSection && strings.HasPrefix(line, "[") {
break
}
}

if err := scanner.Err(); err != nil {
fmt.Println("Error reading file:", err)
return "", fmt.Errorf("error reading file %s: %w", configFile, err)
}

return "org.kde.breeze.desktop"
return "", fmt.Errorf("ColorScheme not found in [General] section of %s", configFile)
}

func formatColorScheme(colorScheme string) string {
// Check if the color scheme is a file path or a theme name
if filepath.Ext(colorScheme) == ".colors" {
// It's a file path, extract the theme name
colorScheme = strings.TrimSuffix(filepath.Base(colorScheme), ".colors")
}
return colorScheme
}

func getShellTheme() string {
Expand Down
Binary file modified build/bin/welcome
Binary file not shown.
2 changes: 1 addition & 1 deletion frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const App: React.FC = () => {
"prefer-dark",
"org.kde.breezedark.desktop",
"com.github.vinceliuice.Qogir-Dark",
"QogirDark",
"Qogirdark",
"Qogir-Dark",
"Qogir-win-Dark",
];
Expand Down

0 comments on commit 5374a1f

Please sign in to comment.