ColorSchemeTab: auto-detect themabale discord client

This commit is contained in:
lysec
2025-10-10 13:42:42 +02:00
parent 8c5968c721
commit 63881bf8a9
13 changed files with 260 additions and 105 deletions
+72 -2
View File
@@ -16,13 +16,67 @@ Singleton {
property bool ghosttyAvailable: false
property bool footAvailable: false
property bool fuzzelAvailable: false
property bool vesktopAvailable: false
property bool gpuScreenRecorderAvailable: false
property bool wlsunsetAvailable: false
// Discord client auto-detection
property var availableDiscordClients: []
// Signal emitted when all checks are complete
signal checksCompleted
// Function to detect Discord client by checking config directories
function detectDiscordClient() {
// Build list of client names from MatugenTemplates
var clientNames = []
for (var i = 0; i < MatugenTemplates.discordClients.length; i++) {
clientNames.push(MatugenTemplates.discordClients[i].name)
}
// Use a Process to check directory existence for all clients
discordDetector.command = ["sh", "-c", "available_clients=\"\"; " + "for client in " + clientNames.join(" ") + "; do " + " if [ -d \"$HOME/.config/$client\" ]; then " + " available_clients=\"$available_clients $client\"; " + " fi; " + "done; " + "echo \"$available_clients\""]
discordDetector.running = true
}
// Process to detect Discord client directories
Process {
id: discordDetector
running: false
onExited: function (exitCode) {
availableDiscordClients = []
if (exitCode === 0) {
var detectedClients = stdout.text.trim().split(/\s+/).filter(function (client) {
return client.length > 0
})
if (detectedClients.length > 0) {
// Build list of available clients
for (var i = 0; i < detectedClients.length; i++) {
var clientName = detectedClients[i]
for (var j = 0; j < MatugenTemplates.discordClients.length; j++) {
var client = MatugenTemplates.discordClients[j]
if (client.name === clientName) {
availableDiscordClients.push(client)
break
}
}
}
Logger.log("ProgramChecker", "Detected Discord clients:", detectedClients.join(", "))
}
}
if (availableDiscordClients.length === 0) {
Logger.log("ProgramChecker", "No Discord clients detected")
}
}
stdout: StdioCollector {}
stderr: StdioCollector {}
}
// Programs to check - maps property names to commands
readonly property var programsToCheck: ({
"matugenAvailable": ["which", "matugen"],
@@ -31,7 +85,6 @@ Singleton {
"ghosttyAvailable": ["which", "ghostty"],
"footAvailable": ["which", "foot"],
"fuzzelAvailable": ["which", "fuzzel"],
"vesktopAvailable": ["which", "vesktop"],
"gpuScreenRecorderAvailable": ["sh", "-c", "command -v gpu-screen-recorder >/dev/null 2>&1 || (command -v flatpak >/dev/null 2>&1 && flatpak list --app | grep -q 'com.dec05eba.gpu_screen_recorder')"],
"wlsunsetAvailable": ["which", "wlsunset"]
})
@@ -59,6 +112,8 @@ Singleton {
// Check next program or emit completion signal
if (root.completedChecks >= root.totalChecks) {
// Run Discord client detection after all checks are complete
root.detectDiscordClient()
root.checksCompleted()
} else {
root.checkNextProgram()
@@ -113,6 +168,21 @@ Singleton {
checker.running = true
}
// Manual function to test Discord detection (for debugging)
function testDiscordDetection() {
Logger.log("ProgramChecker", "Testing Discord detection...")
Logger.log("ProgramChecker", "HOME:", Quickshell.env("HOME"))
// Test each client directory
for (var i = 0; i < MatugenTemplates.discordClients.length; i++) {
var client = MatugenTemplates.discordClients[i]
var configDir = client.configPath.replace("~", Quickshell.env("HOME"))
Logger.log("ProgramChecker", "Checking:", configDir)
}
detectDiscordClient()
}
// Initialize checks when service is created
Component.onCompleted: {
checkAllPrograms()