aboutsummaryrefslogtreecommitdiffstats
path: root/home/quickshell/bar/BarText.qml
diff options
context:
space:
mode:
authorPetri Hienonen <petri.hienonen@gmail.com>2024-05-23 13:56:00 +0300
committerPetri Hienonen <petri.hienonen@gmail.com>2025-11-30 12:29:57 +0200
commit08297376a85a1719518507e54fca9de954d2376a (patch)
tree3b9c58304b40248533bbb2bb5b7bad2da9da1ff0 /home/quickshell/bar/BarText.qml
parent75c2af4aedd2ac5c2cfc74b346625fa4b265541d (diff)
downloadnixos-08297376a85a1719518507e54fca9de954d2376a.tar.zst
Agenix configuration
Diffstat (limited to 'home/quickshell/bar/BarText.qml')
-rw-r--r--home/quickshell/bar/BarText.qml57
1 files changed, 57 insertions, 0 deletions
diff --git a/home/quickshell/bar/BarText.qml b/home/quickshell/bar/BarText.qml
new file mode 100644
index 0000000..4cf42cc
--- /dev/null
+++ b/home/quickshell/bar/BarText.qml
@@ -0,0 +1,57 @@
+import Quickshell
+import Quickshell.Io
+import Quickshell.Widgets
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Effects
+import Qt5Compat.GraphicalEffects
+
+Text {
+ property string mainFont: "FiraCode"
+ property string symbolFont: "Symbols Nerd Font Mono"
+ property int pointSize: 12
+ property int symbolSize: pointSize * 1.4
+ property string symbolText
+ property bool dim
+ text: wrapSymbols(symbolText)
+ anchors.centerIn: parent
+ color: dim ? "#CCCCCC" : "white"
+ textFormat: Text.RichText
+ font {
+ family: mainFont
+ pointSize: pointSize
+ }
+
+ Text {
+ visible: false
+ id: textcopy
+ text: parent.text
+ textFormat: parent.textFormat
+ color: parent.color
+ font: parent.font
+ }
+
+ DropShadow {
+ anchors.fill: parent
+ horizontalOffset: 1
+ verticalOffset: 1
+ color: "#000000"
+ source: textcopy
+ }
+
+ function wrapSymbols(text) {
+ if (!text)
+ return ""
+
+ const isSymbol = (codePoint) =>
+ (codePoint >= 0xE000 && codePoint <= 0xF8FF) // Private Use Area
+ || (codePoint >= 0xF0000 && codePoint <= 0xFFFFF) // Supplementary Private Use Area-A
+ || (codePoint >= 0x100000 && codePoint <= 0x10FFFF); // Supplementary Private Use Area-B
+
+ return text.replace(/./gu, (c) => isSymbol(c.codePointAt(0))
+ ? `<span style='font-family: ${symbolFont}; letter-spacing: 5px; font-size: ${symbolSize}px'>${c}</span>`
+ // ? c
+ : c);
+ }
+}
+