mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-28 15:32:50 -05:00
logo: use nerd fonts for some distros
This commit is contained in:
@@ -5,15 +5,28 @@ Item {
|
|||||||
id: root
|
id: root
|
||||||
|
|
||||||
property string name: ""
|
property string name: ""
|
||||||
property alias size: icon.font.pixelSize
|
property int size: Theme.fontSizeMedium
|
||||||
property alias color: icon.color
|
property alias color: icon.color
|
||||||
|
|
||||||
implicitWidth: icon.implicitWidth
|
width: size
|
||||||
implicitHeight: icon.implicitHeight
|
height: size
|
||||||
visible: text.length > 0
|
visible: text.length > 0
|
||||||
|
|
||||||
// This is for file browser, particularly - might want another map later for app IDs
|
// This is for file browser, particularly - might want another map later for app IDs
|
||||||
readonly property var iconMap: ({
|
readonly property var iconMap: ({
|
||||||
|
// --- Distribution logos ---
|
||||||
|
"debian": "\u{f08da}",
|
||||||
|
"arch": "\u{f08c7}",
|
||||||
|
"archcraft": "\u{f345}",
|
||||||
|
"guix": "\u{f325}",
|
||||||
|
"fedora": "\u{f08db}",
|
||||||
|
"nixos": "\u{f1105}",
|
||||||
|
"ubuntu": "\u{f0548}",
|
||||||
|
"gentoo": "\u{f08e8}",
|
||||||
|
"endeavouros": "\u{f322}",
|
||||||
|
"manjaro": "\u{f160a}",
|
||||||
|
"opensuse": "\u{f314}",
|
||||||
|
|
||||||
// --- special types ---
|
// --- special types ---
|
||||||
"folder": "\u{F024B}",
|
"folder": "\u{F024B}",
|
||||||
"file": "\u{F0214}",
|
"file": "\u{F0214}",
|
||||||
@@ -129,14 +142,12 @@ Item {
|
|||||||
StyledText {
|
StyledText {
|
||||||
id: icon
|
id: icon
|
||||||
|
|
||||||
anchors.fill: parent
|
anchors.centerIn: parent
|
||||||
|
|
||||||
font.family: firaCodeFont.name
|
font.family: firaCodeFont.name
|
||||||
font.pixelSize: Theme.fontSizeMedium
|
font.pixelSize: root.size
|
||||||
color: Theme.surfaceText
|
color: Theme.surfaceText
|
||||||
text: root.text
|
text: root.text
|
||||||
verticalAlignment: Text.AlignVCenter
|
|
||||||
horizontalAlignment: Text.AlignHCenter
|
|
||||||
antialiasing: true
|
antialiasing: true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,39 +3,71 @@ import QtQuick.Effects
|
|||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Widgets
|
import Quickshell.Widgets
|
||||||
import qs.Common
|
import qs.Common
|
||||||
|
import qs.Widgets
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: root
|
||||||
|
|
||||||
IconImage {
|
|
||||||
property string colorOverride: ""
|
property string colorOverride: ""
|
||||||
property real brightnessOverride: 0.5
|
property real brightnessOverride: 0.5
|
||||||
property real contrastOverride: 1
|
property real contrastOverride: 1
|
||||||
|
|
||||||
readonly property bool hasColorOverride: colorOverride !== ""
|
readonly property bool hasColorOverride: colorOverride !== ""
|
||||||
|
|
||||||
smooth: true
|
property bool useNerdFont: false
|
||||||
asynchronous: true
|
property string nerdFontIcon: ""
|
||||||
layer.enabled: hasColorOverride
|
|
||||||
|
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: {
|
Component.onCompleted: {
|
||||||
Proc.runCommand(null, ["sh", "-c", ". /etc/os-release && echo $LOGO"], (output, exitCode) => {
|
Proc.runCommand(null, ["sh", "-c", ". /etc/os-release && echo $ID"], (output, exitCode) => {
|
||||||
if (exitCode !== 0) return
|
if (exitCode !== 0) return
|
||||||
const logo = output.trim()
|
const distroId = output.trim()
|
||||||
if (logo === "cachyos") {
|
|
||||||
source = "file:///usr/share/icons/cachyos.svg"
|
// Nerd fonts are better than images usually
|
||||||
|
const supportedDistroNFs = ["debian", "arch", "archcraft", "fedora", "nixos", "ubuntu", "guix", "gentoo", "endeavouros", "manjaro", "opensuse"]
|
||||||
|
if (supportedDistroNFs.includes(distroId)) {
|
||||||
|
root.useNerdFont = true
|
||||||
|
root.nerdFontIcon = distroId
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else if (logo === "guix-icon")
|
|
||||||
{
|
Proc.runCommand(null, ["sh", "-c", ". /etc/os-release && echo $LOGO"], (logoOutput, logoExitCode) => {
|
||||||
source = "file:///run/current-system/profile/share/icons/hicolor/scalable/apps/guix-icon.svg"
|
if (logoExitCode !== 0) return
|
||||||
return
|
const logo = logoOutput.trim()
|
||||||
}
|
if (logo === "cachyos") {
|
||||||
source = Quickshell.iconPath(logo, true)
|
iconImage.source = "file:///usr/share/icons/cachyos.svg"
|
||||||
|
return
|
||||||
|
} else 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
layer.effect: MultiEffect {
|
|
||||||
colorization: 1
|
|
||||||
colorizationColor: colorOverride
|
|
||||||
brightness: brightnessOverride
|
|
||||||
contrast: contrastOverride
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user