repositories / dotfiles
dotfiles
bugabingas dorkfiles
owned by bugabinga
quickshell/nugu/Launcher.qml
Rawimport QtQuick
import Quickshell
import Quickshell.Wayland
PanelWindow {
id: root
required property QtObject theme
property bool open: false
property string query: ""
// Native launcher replaces `hyprlauncher` later, but stays hidden until IPC
// or a future Hypr bind opens it. DesktopEntries avoids external parsers.
visible: open
focusable: open
anchors { top: true; left: true; right: true }
margins { top: 62 }
exclusiveZone: -1
implicitHeight: 330
color: "transparent"
WlrLayershell {
layer: WlrLayer.Overlay
namespace: "nugu-launcher"
keyboardFocus: root.open ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None
}
ScriptModel { id: matches }
Connections {
target: DesktopEntries.applications
function onValuesChanged(): void { root.rebuild() }
}
Component.onCompleted: rebuild()
onQueryChanged: rebuild()
onOpenChanged: {
if (open) Qt.callLater(search.forceActiveFocus)
}
function show(initialQuery: string): string {
query = initialQuery
open = true
return query
}
function close(): void {
open = false
query = ""
}
function matchCount(): int { return matches.values.length }
function firstMatchName(): string { return matches.values.length > 0 ? matches.values[0].name : "" }
function rebuild(): void {
const needle = query.toLowerCase().trim()
const apps = DesktopEntries.applications.values || []
matches.values = apps
.filter(app => app && !app.noDisplay && app.name.length > 0)
.filter(app => needle.length === 0 || searchableText(app).indexOf(needle) !== -1)
.sort((a, b) => a.name.localeCompare(b.name))
.slice(0, 12)
results.currentIndex = matches.values.length > 0 ? 0 : -1
}
function searchableText(app): string {
return [
app.name,
app.genericName,
app.comment,
app.id,
app.categories.join(" "),
app.keywords.join(" ")
].join(" ").toLowerCase()
}
function launchIndex(index: int): void {
if (index < 0 || index >= matches.values.length) return
const app = matches.values[index]
close()
app.execute()
}
MouseArea {
anchors.fill: parent
onClicked: root.close()
}
Rectangle {
anchors.top: parent.top
anchors.horizontalCenter: parent.horizontalCenter
width: Math.min(parent.width - 32, 620)
height: parent.height
radius: 14
color: `${theme.ui.backdrop}f2`
border.width: 2
border.color: theme.ui.accent
Column {
anchors.fill: parent
anchors.margins: 14
spacing: 10
TextInput {
id: search
width: parent.width
height: 42
text: root.query
onTextChanged: root.query = text
color: theme.ui.important_global
selectionColor: theme.ui.focus
selectedTextColor: theme.content.backdrop
font.family: "IBM Plex Sans"
font.pixelSize: 20
font.bold: true
clip: true
Rectangle {
anchors.fill: parent
anchors.margins: -6
z: -1
radius: 9
color: theme.content.backdrop
border.width: 1
border.color: theme.ui.unfocus
}
Keys.onPressed: event => {
if (event.key === Qt.Key_Escape) {
root.close()
event.accepted = true
} else if (event.key === Qt.Key_Down) {
results.currentIndex = Math.min(results.currentIndex + 1, matches.values.length - 1)
event.accepted = true
} else if (event.key === Qt.Key_Up) {
results.currentIndex = Math.max(results.currentIndex - 1, 0)
event.accepted = true
} else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
root.launchIndex(results.currentIndex)
event.accepted = true
}
}
}
ListView {
id: results
width: parent.width
height: parent.height - search.height - parent.spacing
model: matches
clip: true
spacing: 4
delegate: Rectangle {
id: row
required property var modelData
required property int index
width: results.width
height: 36
radius: 8
color: results.currentIndex === index ? theme.ui.focus : (rowMouse.containsMouse ? theme.ui.accent : "transparent")
MouseArea {
id: rowMouse
anchors.fill: parent
hoverEnabled: true
onClicked: root.launchIndex(row.index)
}
Row {
anchors.fill: parent
anchors.leftMargin: 10
anchors.rightMargin: 10
spacing: 10
Image {
width: 22
height: 22
anchors.verticalCenter: parent.verticalCenter
source: Quickshell.iconPath(row.modelData.icon, true)
fillMode: Image.PreserveAspectFit
visible: source.length > 0
}
Column {
anchors.verticalCenter: parent.verticalCenter
width: parent.width - 42
spacing: 0
Text {
width: parent.width
text: row.modelData.name
color: (results.currentIndex === row.index || rowMouse.containsMouse) ? theme.content.backdrop : theme.ui.normal
font.family: "IBM Plex Sans"
font.pixelSize: 14
font.bold: true
elide: Text.ElideRight
}
Text {
width: parent.width
text: row.modelData.comment || row.modelData.genericName || row.modelData.id
color: (results.currentIndex === row.index || rowMouse.containsMouse) ? theme.content.backdrop : theme.ui.minor
font.family: "IBM Plex Sans"
font.pixelSize: 11
elide: Text.ElideRight
}
}
}
}
}
}
}
}