aboutsummaryrefslogtreecommitdiffstats
path: root/home/quickshell/bar/blocks/Icon.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/blocks/Icon.qml
parent75c2af4aedd2ac5c2cfc74b346625fa4b265541d (diff)
downloadnixos-08297376a85a1719518507e54fca9de954d2376a.tar.zst
Agenix configuration
Diffstat (limited to 'home/quickshell/bar/blocks/Icon.qml')
-rw-r--r--home/quickshell/bar/blocks/Icon.qml146
1 files changed, 146 insertions, 0 deletions
diff --git a/home/quickshell/bar/blocks/Icon.qml b/home/quickshell/bar/blocks/Icon.qml
new file mode 100644
index 0000000..c111a7e
--- /dev/null
+++ b/home/quickshell/bar/blocks/Icon.qml
@@ -0,0 +1,146 @@
+import QtQuick
+import QtQuick.Layouts
+import QtQuick.Controls
+import Quickshell
+import Quickshell.Io
+import Quickshell.Widgets
+import Qt5Compat.GraphicalEffects
+import "../"
+import "root:/"
+
+BarBlock {
+ id: root
+ Layout.preferredWidth: 20
+
+ content: BarText {
+ text: "󰣇"
+ pointSize: 24
+ anchors.horizontalCenterOffset: 4
+ anchors.verticalCenterOffset: 3
+ }
+
+ color: "transparent"
+
+ Process {
+ id: appListProc
+ command: ["sh", "-c", "for f in /usr/share/applications/*.desktop; do if ! grep -qi 'terminal=true' \"$f\"; then name=$(grep -i '^Name=' \"$f\" | head -n1 | cut -d= -f2); basename=$(basename \"$f\" .desktop); echo \"$name|$basename|$f\"; fi; done"]
+ running: false
+ stdout: SplitParser {
+ onRead: data => {
+ const [appName, launchName, desktopFile] = data.trim().split("|")
+ if (appName && launchName && desktopFile) {
+ appListModel.append({ name: appName, launchName: launchName, path: desktopFile })
+ }
+ }
+ }
+ }
+
+ Process {
+ id: appLauncher
+ running: false
+ command: ["gtk-launch"]
+ }
+
+ ListModel {
+ id: appListModel
+ }
+
+ PopupWindow {
+ id: menuWindow
+ width: 300
+ height: 400
+ visible: false
+
+ anchor {
+ window: root.QsWindow?.window
+ edges: Edges.Bottom
+ gravity: Edges.Top
+ }
+
+ FocusScope {
+ anchors.fill: parent
+ focus: true
+
+ MouseArea {
+ anchors.fill: parent
+ hoverEnabled: true
+ onExited: {
+ if (!containsMouse) {
+ closeTimer.start()
+ }
+ }
+ onEntered: closeTimer.stop()
+
+ Timer {
+ id: closeTimer
+ interval: 500
+ onTriggered: menuWindow.visible = false
+ }
+
+ Rectangle {
+ anchors.fill: parent
+ color: "#2E3440" // Using Nord theme color
+ border.color: "#4C566A"
+ border.width: 1
+ radius: 4
+
+ ColumnLayout {
+ anchors.fill: parent
+ anchors.margins: 10
+ spacing: 5
+
+ ListView {
+ id: appListView
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ clip: true
+ model: appListModel
+ delegate: Rectangle {
+ width: parent.width
+ height: 35
+ color: mouseArea.containsMouse ? "#4C566A" : "transparent"
+ radius: 4
+
+ Text {
+ anchors.fill: parent
+ anchors.leftMargin: 10
+ text: model.name
+ color: "white"
+ font.pixelSize: 12
+ verticalAlignment: Text.AlignVCenter
+ }
+
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ hoverEnabled: true
+ onClicked: {
+ console.log("Launching:", model.launchName, "from", model.path)
+ appLauncher.command = ["gtk-launch", model.launchName]
+ appLauncher.running = true
+ menuWindow.visible = false
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ function filterApps() {
+ const searchText = searchField.text.toLowerCase()
+ for (let i = 0; i < appListModel.count; i++) {
+ const item = appListModel.get(i)
+ item.visible = item.name.toLowerCase().includes(searchText)
+ }
+ }
+ onClicked: function() {
+ if (!menuWindow.visible) {
+ appListModel.clear()
+ appListProc.running = true
+ }
+ menuWindow.visible = !menuWindow.visible
+ }
+} \ No newline at end of file