summaryrefslogtreecommitdiff
path: root/raveos-hyprland-theme/theme-data/DankMaterialShell/quickshell/Widgets/SystemLogo.qml
blob: 19922e5eac9ecc63e2311df2f5344f1160c29c39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import QtQuick
import QtQuick.Effects
import Quickshell
import Quickshell.Widgets
import qs.Common
import qs.Widgets

Item {
    id: root

    property string colorOverride: ""
    property real brightnessOverride: 0.5
    property real contrastOverride: 1

    readonly property bool hasColorOverride: colorOverride !== ""

    property bool useNerdFont: false
    property string nerdFontIcon: ""

    IconImage {
        id: iconImage
        anchors.fill: parent
        visible: !root.useNerdFont

        smooth: true
        asynchronous: true
        layer.enabled: hasColorOverride

        layer.effect: MultiEffect {
            colorization: 1
            colorizationColor: colorOverride
            brightness: brightnessOverride
            contrast: contrastOverride
        }
    }

    DankNFIcon {
        id: nfIcon
        anchors.centerIn: parent
        visible: root.useNerdFont
        name: root.nerdFontIcon
        size: Math.min(root.width, root.height)
        color: hasColorOverride ? colorOverride : Theme.surfaceText
    }

    Component.onCompleted: {
        Proc.runCommand(null, ["sh", "-c", ". /etc/os-release && echo $NAME"], (nameOutput, nameExitCode) => {
            if (nameExitCode === 0 && nameOutput.trim() === "RaveOS") {
                iconImage.source = "file://" + Theme.shellDir + "/assets/raveos-logo.svg"
                return
            }
            
            Proc.runCommand(null, ["sh", "-c", ". /etc/os-release && echo $ID"], (output, exitCode) => {
                if (!root || exitCode !== 0 || !output) return
                const distroId = output.trim()
                if (!distroId) return

                const supportedDistroNFs = ["debian", "arch", "archcraft", "fedora", "nixos", "ubuntu", "guix", "gentoo", "endeavouros", "manjaro", "opensuse"]
                if (supportedDistroNFs.includes(distroId)) {
                    if (!root) return
                    root.useNerdFont = true
                    root.nerdFontIcon = distroId
                    return
                }

                Proc.runCommand(null, ["sh", "-c", ". /etc/os-release && echo $LOGO"], (logoOutput, logoExitCode) => {
                    if (!root || !iconImage || logoExitCode !== 0 || !logoOutput) return
                    const logo = logoOutput.trim()
                    if (!logo) return

                    if (logo === "cachyos") {
                        iconImage.source = "file:///usr/share/icons/cachyos.svg"
                        return
                    }
                    if (logo === "guix-icon") {
                        iconImage.source = "file:///run/current-system/profile/share/icons/hicolor/scalable/apps/guix-icon.svg"
                        return
                    }
                    iconImage.source = Quickshell.iconPath(logo, true)
                }, 0)
            }, 0)
        }, 0)
    }
}