feat: quickshell rewrite wip
This commit is contained in:
1 parent
962ae7c1c7
commit
452d7080f9
36 files changed
+677
-1685
No files matched your search
@@ -0,0 +1,191 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Widgets as QSW
|
||||
import "../core"
|
||||
|
||||
FloatingWindow {
|
||||
id: win
|
||||
title: "App Launcher"
|
||||
visible: false
|
||||
implicitWidth: 760
|
||||
implicitHeight: 560
|
||||
color: "transparent"
|
||||
|
||||
property var apps: []
|
||||
property string query: ""
|
||||
property int selectedIndex: 0
|
||||
property bool mouseWasInside: false
|
||||
property var filteredApps: apps.filter(function(app) {
|
||||
const q = query.toLowerCase()
|
||||
return q.length === 0 || app.name.toLowerCase().indexOf(q) >= 0 || app.comment.toLowerCase().indexOf(q) >= 0 || app.id.toLowerCase().indexOf(q) >= 0
|
||||
})
|
||||
|
||||
function shellQuote(s) { return "'" + String(s).replace(/'/g, "'\\''") + "'" }
|
||||
function focusSearch() { Qt.callLater(function() { search.focus = true; search.forceActiveFocus(); search.cursorPosition = search.text.length }) }
|
||||
function clampIndex(index) { if (filteredApps.length === 0) return 0; return Math.max(0, Math.min(filteredApps.length - 1, index)) }
|
||||
function selectIndex(index) { selectedIndex = clampIndex(index) }
|
||||
function open() { mouseWasInside = false; query = ""; visible = true; refresh(); focusSearch() }
|
||||
function toggle() { visible = !visible; if (visible) { mouseWasInside = false; query = ""; refresh(); focusSearch() } }
|
||||
function refresh() { appList.running = true }
|
||||
function launchSelected() {
|
||||
if (filteredApps.length === 0) return
|
||||
const id = filteredApps[selectedIndex].id
|
||||
const path = filteredApps[selectedIndex].path
|
||||
const hist = Quickshell.env("HOME") + "/.cache/quickshell/app-launcher-history"
|
||||
launchProcess.command = ["bash", "-c", "mkdir -p ~/.cache/quickshell; { printf '%s\\n' " + shellQuote(id) + "; grep -vxF " + shellQuote(id) + " " + shellQuote(hist) + " 2>/dev/null | head -n 29; } > " + shellQuote(hist + ".tmp") + " && mv " + shellQuote(hist + ".tmp") + " " + shellQuote(hist) + "; uwsm app " + shellQuote(path) + " > ~/.cache/quickshell/launch.log 2>&1 & disown"]
|
||||
console.log("launching: " + launchProcess.command.join(" "))
|
||||
launchProcess.running = true
|
||||
visible = false
|
||||
}
|
||||
|
||||
onQueryChanged: { selectedIndex = 0; focusSearch() }
|
||||
onFilteredAppsChanged: selectedIndex = clampIndex(selectedIndex)
|
||||
onSelectedIndexChanged: if (visible) Qt.callLater(function() { list.positionViewAtIndex(selectedIndex, ListView.Contain) })
|
||||
|
||||
IpcHandler {
|
||||
target: "appLauncher"
|
||||
function open() { win.open() }
|
||||
function toggle() { win.toggle() }
|
||||
function refresh() { win.refresh() }
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
focus: win.visible
|
||||
|
||||
function handleKey(event) {
|
||||
if (event.text && event.text.length > 0 && event.text >= " " && !(event.modifiers & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier))) {
|
||||
if (!search.activeFocus) {
|
||||
win.query += event.text
|
||||
win.focusSearch()
|
||||
event.accepted = true
|
||||
}
|
||||
return
|
||||
}
|
||||
if (event.key === Qt.Key_Backspace && !search.activeFocus && win.query.length > 0) { win.query = win.query.slice(0, -1); win.focusSearch(); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Down || event.key === Qt.Key_J) { win.selectIndex(win.selectedIndex + 1); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Up || event.key === Qt.Key_K) { win.selectIndex(win.selectedIndex - 1); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { win.launchSelected(); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Escape) { win.visible = false; event.accepted = true }
|
||||
}
|
||||
|
||||
Keys.onPressed: function(event) { root.handleKey(event) }
|
||||
|
||||
MouseArea { anchors.fill: parent; hoverEnabled: true; acceptedButtons: Qt.NoButton; onEntered: win.mouseWasInside = true; onExited: if (win.mouseWasInside) win.visible = false }
|
||||
Rectangle { anchors.fill: parent; radius: 34; color: Qt.rgba(Theme.base.r, Theme.base.g, Theme.base.b, 0.13); border.color: Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.38); border.width: 1 }
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.top: parent.top
|
||||
anchors.margins: 28; height: 52; radius: 21
|
||||
color: Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.50)
|
||||
border.color: Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.45)
|
||||
Text { anchors.left: parent.left; anchors.verticalCenter: parent.verticalCenter; anchors.leftMargin: 16; text: ""; font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize + 5; color: Theme.mauve }
|
||||
TextInput {
|
||||
id: search
|
||||
focus: true
|
||||
activeFocusOnTab: true
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: 50; anchors.rightMargin: 16
|
||||
text: win.query
|
||||
onTextChanged: win.query = text
|
||||
clip: true
|
||||
font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize + 2
|
||||
color: Theme.text
|
||||
selectionColor: Theme.mauve
|
||||
selectedTextColor: Theme.base
|
||||
Text { visible: search.text.length === 0; text: "Launch app…"; font: search.font; color: Theme.overlay1 }
|
||||
Keys.onPressed: function(event) { root.handleKey(event) }
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 60
|
||||
repeat: true
|
||||
running: win.visible && !search.activeFocus
|
||||
onTriggered: win.focusSearch()
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: list
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: footer.top
|
||||
anchors.leftMargin: 28; anchors.rightMargin: 28; anchors.topMargin: 96; anchors.bottomMargin: 14
|
||||
model: win.filteredApps
|
||||
spacing: 10
|
||||
clip: true
|
||||
currentIndex: win.selectedIndex
|
||||
delegate: Rectangle {
|
||||
id: card
|
||||
width: list.width
|
||||
height: 68
|
||||
radius: 20
|
||||
color: index === win.selectedIndex ? Qt.rgba(Theme.mauve.r, Theme.mauve.g, Theme.mauve.b, 0.22) : Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.45)
|
||||
border.color: index === win.selectedIndex ? Theme.mauve : Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.45)
|
||||
border.width: index === win.selectedIndex ? 2 : 1
|
||||
antialiasing: true
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: 12
|
||||
width: 44
|
||||
height: 44
|
||||
radius: 14
|
||||
color: Qt.rgba(Theme.surface0.r, Theme.surface0.g, Theme.surface0.b, 0.72)
|
||||
|
||||
QSW.IconImage {
|
||||
id: appIcon
|
||||
anchors.centerIn: parent
|
||||
width: 32
|
||||
height: 32
|
||||
source: modelData.icon ? "image://icon/" + modelData.icon : ""
|
||||
asynchronous: true
|
||||
mipmap: true
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: appIcon.status === Image.Error || appIcon.source === ""
|
||||
anchors.centerIn: parent
|
||||
text: modelData.name.length ? modelData.name[0].toUpperCase() : "?"
|
||||
font.family: Theme.fontFamily
|
||||
font.bold: true
|
||||
font.pixelSize: Theme.fontPixelSize + 7
|
||||
color: Theme.mauve
|
||||
}
|
||||
}
|
||||
ColumnLayout {
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: 70; anchors.rightMargin: 14
|
||||
spacing: 2
|
||||
Text { Layout.fillWidth: true; text: modelData.name; elide: Text.ElideRight; font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize + 1; font.bold: true; color: Theme.text }
|
||||
Text { Layout.fillWidth: true; text: (modelData.used ? "Recent · " : "") + (modelData.comment || modelData.id); elide: Text.ElideRight; font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize - 2; color: modelData.used ? Theme.green : Theme.overlay2 }
|
||||
}
|
||||
MouseArea { anchors.fill: parent; onClicked: { if (index === win.selectedIndex) win.launchSelected(); else win.selectIndex(index); search.forceActiveFocus() } }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: footer
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.bottom: parent.bottom
|
||||
anchors.leftMargin: 42; anchors.rightMargin: 42; anchors.bottomMargin: 22
|
||||
height: 44; radius: 18
|
||||
color: Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.42)
|
||||
border.color: Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.45)
|
||||
Text { anchors.centerIn: parent; text: win.filteredApps.length + " apps · type search · ↑/↓ select · Enter launch · Esc"; font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize - 2; color: Theme.overlay2 }
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: appList
|
||||
running: false
|
||||
command: ["python3", "-c", "import configparser,glob,os,json;\nseen={};\nhist_path=os.path.expanduser('~/.cache/quickshell/app-launcher-history');\nhist=[]\ntry:\n hist=[x.strip() for x in open(hist_path, encoding='utf-8') if x.strip()]\nexcept Exception:\n pass\nrank={v:i for i,v in enumerate(hist)}\npaths=[f for d in os.environ.get('XDG_DATA_DIRS', '/usr/share').split(':') + ['~/.local/share'] for f in glob.glob(os.path.expanduser(d)+'/applications/*.desktop')];\nfor p in paths:\n cp=configparser.ConfigParser(interpolation=None); cp.optionxform=str\n try: cp.read(p, encoding='utf-8')\n except Exception: continue\n if not cp.has_section('Desktop Entry'): continue\n d=cp['Desktop Entry']\n if d.get('Type','Application')!='Application' or d.get('NoDisplay','false').lower()=='true' or d.get('Hidden','false').lower()=='true': continue\n name=d.get('Name','').strip()\n if not name: continue\n did=os.path.basename(p)\n appid=did[:-8] if did.endswith('.desktop') else did\n seen[appid]={'id':appid,'path':p,'name':name,'comment':d.get('Comment','').strip(),'icon':d.get('Icon','').strip(),'used': appid in rank}\nprint(json.dumps(sorted(seen.values(), key=lambda x:(rank.get(x['id'],999999), x['name'].lower()))))"]
|
||||
stdout: StdioCollector { onStreamFinished: { try { win.apps = JSON.parse(text) } catch(e) { win.apps = [] }; win.selectedIndex = 0 } }
|
||||
}
|
||||
Process {
|
||||
id: launchProcess
|
||||
running: false
|
||||
command: []
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
|
||||
FloatingWindow {
|
||||
id: win
|
||||
title: "Clipboard Picker"
|
||||
visible: false
|
||||
implicitWidth: 760
|
||||
implicitHeight: 520
|
||||
color: "transparent"
|
||||
|
||||
property var items: []
|
||||
property string query: ""
|
||||
property int selectedIndex: 0
|
||||
property bool mouseWasInside: false
|
||||
property var filteredItems: items.filter(function(x) { return query.length === 0 || x.toLowerCase().indexOf(query.toLowerCase()) >= 0 })
|
||||
|
||||
function shellQuote(s) { return "'" + String(s).replace(/'/g, "'\\''") + "'" }
|
||||
function focusSearch() { Qt.callLater(function() { search.focus = true; search.forceActiveFocus(); search.cursorPosition = search.text.length }) }
|
||||
function clampIndex(index) { if (filteredItems.length === 0) return 0; return Math.max(0, Math.min(filteredItems.length - 1, index)) }
|
||||
function selectIndex(index) { selectedIndex = clampIndex(index) }
|
||||
function open() { mouseWasInside = false; query = ""; visible = true; refresh(); focusSearch() }
|
||||
function toggle() { visible = !visible; if (visible) { mouseWasInside = false; query = ""; refresh(); focusSearch() } }
|
||||
function refresh() { listProcess.running = true }
|
||||
function choose() {
|
||||
if (filteredItems.length === 0) return
|
||||
copyProcess.command = ["bash", "-lc", "printf %s " + shellQuote(filteredItems[selectedIndex]) + " | cliphist decode | wl-copy"]
|
||||
copyProcess.running = true
|
||||
visible = false
|
||||
}
|
||||
function removeSelected() {
|
||||
if (filteredItems.length === 0) return
|
||||
deleteProcess.command = ["bash", "-lc", "printf %s " + shellQuote(filteredItems[selectedIndex]) + " | cliphist delete"]
|
||||
deleteProcess.running = true
|
||||
}
|
||||
|
||||
onQueryChanged: { selectedIndex = 0; focusSearch() }
|
||||
onFilteredItemsChanged: selectedIndex = clampIndex(selectedIndex)
|
||||
onSelectedIndexChanged: if (visible) Qt.callLater(function() { list.positionViewAtIndex(selectedIndex, ListView.Contain) })
|
||||
|
||||
IpcHandler {
|
||||
target: "clipboardPicker"
|
||||
function open() { win.open() }
|
||||
function toggle() { win.toggle() }
|
||||
function refresh() { win.refresh() }
|
||||
}
|
||||
|
||||
FocusScope {
|
||||
id: root
|
||||
anchors.fill: parent
|
||||
focus: win.visible
|
||||
|
||||
function handleKey(event) {
|
||||
if (event.text && event.text.length > 0 && event.text >= " " && !(event.modifiers & (Qt.ControlModifier | Qt.AltModifier | Qt.MetaModifier))) {
|
||||
if (!search.activeFocus) {
|
||||
win.query += event.text
|
||||
win.focusSearch()
|
||||
event.accepted = true
|
||||
}
|
||||
return
|
||||
}
|
||||
if (event.key === Qt.Key_Down || event.key === Qt.Key_J) { win.selectIndex(win.selectedIndex + 1); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Up || event.key === Qt.Key_K) { win.selectIndex(win.selectedIndex - 1); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) { win.choose(); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Delete || event.key === Qt.Key_Backspace) {
|
||||
if (event.key === Qt.Key_Backspace && search.activeFocus && search.text.length > 0) return
|
||||
win.removeSelected(); event.accepted = true
|
||||
}
|
||||
else if (event.key === Qt.Key_Escape) { win.visible = false; event.accepted = true }
|
||||
}
|
||||
|
||||
Keys.onPressed: function(event) { root.handleKey(event) }
|
||||
|
||||
MouseArea { anchors.fill: parent; hoverEnabled: true; acceptedButtons: Qt.NoButton; onEntered: win.mouseWasInside = true; onExited: if (win.mouseWasInside) win.visible = false }
|
||||
Rectangle { anchors.fill: parent; radius: 34; color: Qt.rgba(Theme.base.r, Theme.base.g, Theme.base.b, 0.13); border.color: Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.38); border.width: 1 }
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.top: parent.top
|
||||
anchors.margins: 28; height: 48; radius: 20
|
||||
color: Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.50)
|
||||
border.color: Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.45)
|
||||
Text { anchors.left: parent.left; anchors.verticalCenter: parent.verticalCenter; anchors.leftMargin: 16; text: ""; font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize + 3; color: Theme.mauve }
|
||||
TextInput {
|
||||
id: search
|
||||
focus: true
|
||||
activeFocusOnTab: true
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.verticalCenter: parent.verticalCenter
|
||||
anchors.leftMargin: 48; anchors.rightMargin: 16
|
||||
text: win.query
|
||||
onTextChanged: win.query = text
|
||||
clip: true
|
||||
font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize + 1
|
||||
color: Theme.text
|
||||
selectionColor: Theme.mauve
|
||||
selectedTextColor: Theme.base
|
||||
Text { visible: search.text.length === 0; text: "Search clipboard…"; font: search.font; color: Theme.overlay1 }
|
||||
Keys.onPressed: function(event) { root.handleKey(event) }
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 60
|
||||
repeat: true
|
||||
running: win.visible && !search.activeFocus
|
||||
onTriggered: win.focusSearch()
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: list
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.top: parent.top; anchors.bottom: footer.top
|
||||
anchors.leftMargin: 28; anchors.rightMargin: 28; anchors.topMargin: 90; anchors.bottomMargin: 14
|
||||
model: win.filteredItems
|
||||
spacing: 10
|
||||
clip: true
|
||||
currentIndex: win.selectedIndex
|
||||
delegate: Rectangle {
|
||||
id: card
|
||||
width: list.width
|
||||
height: 62
|
||||
radius: 18
|
||||
color: index === win.selectedIndex ? Qt.rgba(Theme.mauve.r, Theme.mauve.g, Theme.mauve.b, 0.22) : Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.45)
|
||||
border.color: index === win.selectedIndex ? Theme.mauve : Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.45)
|
||||
border.width: index === win.selectedIndex ? 2 : 1
|
||||
antialiasing: true
|
||||
Text {
|
||||
anchors.fill: parent; anchors.margins: 14
|
||||
text: String(modelData).replace(/^\S+\s+/, "")
|
||||
elide: Text.ElideRight
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize
|
||||
color: Theme.text
|
||||
}
|
||||
MouseArea { anchors.fill: parent; onClicked: { if (index === win.selectedIndex) win.choose(); else win.selectIndex(index); search.forceActiveFocus() } }
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: footer
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.bottom: parent.bottom
|
||||
anchors.leftMargin: 42; anchors.rightMargin: 42; anchors.bottomMargin: 22
|
||||
height: 44; radius: 18
|
||||
color: Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.42)
|
||||
border.color: Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.45)
|
||||
Text { anchors.centerIn: parent; text: win.filteredItems.length + " items · type search · ↑/↓ select · Enter copy · Backspace remove · Esc"; font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize - 2; color: Theme.overlay2 }
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: listProcess
|
||||
command: ["bash", "-lc", "cliphist list 2>/dev/null || true"]
|
||||
running: false
|
||||
stdout: StdioCollector { onStreamFinished: { win.items = text.trim().length ? text.trim().split('\n') : []; win.selectedIndex = 0 } }
|
||||
}
|
||||
Process { id: copyProcess; running: false }
|
||||
Process { id: deleteProcess; running: false; onExited: win.refresh() }
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
|
||||
ModuleContainer {
|
||||
id: root
|
||||
|
||||
// Initial state
|
||||
text: "00:00"
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: true
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
var d = new Date();
|
||||
var h = d.getHours().toString().padStart(2, '0');
|
||||
var m = d.getMinutes().toString().padStart(2, '0');
|
||||
root.text = h + ":" + m;
|
||||
}
|
||||
}
|
||||
|
||||
// Embed the MPRIS Popup natively into the pill's slot
|
||||
popupItem: PopupWindow {
|
||||
id: mprisPopup
|
||||
implicitWidth: 260
|
||||
implicitHeight: 80
|
||||
|
||||
anchor.item: root
|
||||
anchor.edges: Edges.Bottom
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Theme.bg
|
||||
radius: Theme.radius
|
||||
border.color: Theme.bgAlt
|
||||
border.width: 1
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: Theme.padding
|
||||
spacing: 4
|
||||
|
||||
Text {
|
||||
text: "Now Playing"
|
||||
color: Theme.fgAlt
|
||||
font: Theme.font
|
||||
}
|
||||
|
||||
Text {
|
||||
id: mprisText
|
||||
text: "Nothing playing"
|
||||
color: Theme.fg
|
||||
font: Theme.fontBold
|
||||
elide: Text.ElideRight
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: mprisProcess
|
||||
command: ["sh", "-c", "playerctl metadata --format '{{title}} - {{artist}}' || echo 'Nothing playing'"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
mprisText.text = text.trim() || "Nothing playing";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 2000
|
||||
running: mprisPopup.visible
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: mprisProcess.running = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import QtQuick.Effects
|
||||
import Quickshell
|
||||
import "../core"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
|
||||
property bool active: true
|
||||
property bool clickable: false
|
||||
|
||||
// Inner content configuration
|
||||
property string icon: ""
|
||||
property string text: ""
|
||||
property Component customContent: null
|
||||
|
||||
// Popup configuration
|
||||
property var popupItem: null
|
||||
|
||||
// Styling
|
||||
property color pillColor: Theme.bgAlt
|
||||
|
||||
// Standard pill dimensions
|
||||
implicitHeight: 28
|
||||
|
||||
// Monitor tracking for exclusive visibility
|
||||
property var monitor: null
|
||||
property bool exclusiveToScreen: false
|
||||
property bool isFocusedMonitor: monitor ? monitor.focused : true
|
||||
property bool effectivelyActive: active && (!exclusiveToScreen || isFocusedMonitor)
|
||||
|
||||
// Fluid auto-hide transitions
|
||||
visible: opacity > 0
|
||||
opacity: effectivelyActive ? 1 : 0
|
||||
implicitWidth: effectivelyActive ? contentRow.implicitWidth + (Theme.padding * 2) : 0
|
||||
clip: false // Turn off clip so shadow isn't cut off
|
||||
|
||||
Behavior on opacity {
|
||||
NumberAnimation { duration: 250; easing.type: Easing.InOutQuad }
|
||||
}
|
||||
Behavior on implicitWidth {
|
||||
NumberAnimation { duration: 250; easing.type: Easing.OutBack }
|
||||
}
|
||||
|
||||
// Shadow Effect
|
||||
MultiEffect {
|
||||
anchors.fill: bgRect
|
||||
source: bgRect
|
||||
shadowEnabled: true
|
||||
shadowColor: "#000000"
|
||||
shadowOpacity: 0.4
|
||||
shadowBlur: 0.8
|
||||
shadowVerticalOffset: 2
|
||||
shadowHorizontalOffset: 0
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: bgRect
|
||||
anchors.fill: parent
|
||||
radius: Theme.radius / 2
|
||||
color: (clickable || popupItem !== null) && mouseArea.containsMouse ? Qt.darker(root.pillColor, 1.2) : root.pillColor
|
||||
|
||||
RowLayout {
|
||||
id: contentRow
|
||||
anchors.centerIn: parent
|
||||
spacing: 6
|
||||
|
||||
Loader {
|
||||
active: root.customContent !== null
|
||||
sourceComponent: root.customContent
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: root.icon !== "" && root.customContent === null
|
||||
text: root.icon
|
||||
color: Theme.fg
|
||||
font: Theme.font
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
|
||||
Text {
|
||||
visible: root.text !== "" && root.customContent === null
|
||||
text: root.text
|
||||
color: Theme.fg
|
||||
font: Theme.fontBold
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouseArea
|
||||
anchors.fill: parent
|
||||
hoverEnabled: root.clickable || root.popupItem !== null
|
||||
cursorShape: (root.clickable || root.popupItem !== null) ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||
onClicked: {
|
||||
if (root.popupItem !== null) {
|
||||
root.popupItem.visible = !root.popupItem.visible;
|
||||
}
|
||||
root.clicked();
|
||||
}
|
||||
}
|
||||
|
||||
signal clicked()
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
import Quickshell
|
||||
import Quickshell.Services.Notifications
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import "../core"
|
||||
|
||||
PanelWindow {
|
||||
id: notifWindow
|
||||
|
||||
// Anchor to top right, just below the bar
|
||||
anchors {
|
||||
top: true
|
||||
right: true
|
||||
}
|
||||
|
||||
// Offset slightly from the screen edges
|
||||
margins {
|
||||
top: 40 // height of top bar (32) + 8 padding
|
||||
right: 8
|
||||
}
|
||||
|
||||
// Dynamic height based on notifications
|
||||
implicitWidth: 320
|
||||
implicitHeight: notifList.contentHeight
|
||||
color: "transparent"
|
||||
|
||||
// Make invisible if no notifications
|
||||
visible: notificationServer.trackedNotifications.values.length > 0
|
||||
|
||||
NotificationServer {
|
||||
id: notificationServer
|
||||
bodySupported: true
|
||||
actionsSupported: false
|
||||
inlineReplySupported: false
|
||||
imageSupported: true
|
||||
actionIconsSupported: false
|
||||
persistenceSupported: false
|
||||
|
||||
onNotification: function(notification) {
|
||||
notification.tracked = true;
|
||||
}
|
||||
}
|
||||
|
||||
ListView {
|
||||
id: notifList
|
||||
anchors.fill: parent
|
||||
spacing: 8
|
||||
model: notificationServer.trackedNotifications.values
|
||||
clip: false // Allow shadows or animations outside
|
||||
|
||||
delegate: Rectangle {
|
||||
id: delegateRect
|
||||
width: notifWindow.width
|
||||
height: layout.height + Theme.padding * 2
|
||||
color: Theme.bg
|
||||
radius: Theme.radius
|
||||
border.color: Theme.bgAlt
|
||||
border.width: 1
|
||||
|
||||
property var notif: modelData
|
||||
|
||||
ColumnLayout {
|
||||
id: layout
|
||||
anchors.top: parent.top
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.margins: Theme.padding
|
||||
spacing: 4
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
|
||||
Text {
|
||||
text: notif.appName || "Notification"
|
||||
color: Theme.primary
|
||||
font: Theme.fontBold
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "✕"
|
||||
color: Theme.fgAlt
|
||||
font: Theme.fontBold
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: notif.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: notif.summary || ""
|
||||
color: Theme.fg
|
||||
font: Theme.fontBold
|
||||
Layout.fillWidth: true
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
Text {
|
||||
text: notif.body || ""
|
||||
color: Theme.fgAlt
|
||||
font: Theme.font
|
||||
Layout.fillWidth: true
|
||||
wrapMode: Text.Wrap
|
||||
maximumLineCount: 4
|
||||
elide: Text.ElideRight
|
||||
visible: text.length > 0
|
||||
}
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: expireTimer
|
||||
interval: notif.expireTimeout > 0 ? (notif.expireTimeout) : 5000
|
||||
running: true
|
||||
onTriggered: notif.expire()
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
// Don't swallow clicks for the close button
|
||||
z: -1
|
||||
onClicked: notif.dismiss()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
|
||||
FloatingWindow {
|
||||
id: win
|
||||
title: "Power Menu"
|
||||
visible: false
|
||||
implicitWidth: 820
|
||||
implicitHeight: 340
|
||||
color: "transparent"
|
||||
|
||||
property int selectedIndex: 0
|
||||
property int armedIndex: -1
|
||||
property bool mouseWasInside: false
|
||||
readonly property var actions: [
|
||||
{ name: "Lock", icon: "", hint: "hyprlock", cmd: "hyprlock", danger: false },
|
||||
{ name: "Logout", icon: "", hint: "hyprctl dispatch exit", cmd: "hyprctl dispatch exit", danger: true },
|
||||
{ name: "Suspend", icon: "", hint: "systemctl suspend", cmd: "systemctl suspend", danger: false },
|
||||
{ name: "Reboot", icon: "", hint: "systemctl reboot", cmd: "systemctl reboot", danger: true },
|
||||
{ name: "Shutdown", icon: "", hint: "systemctl poweroff", cmd: "systemctl poweroff", danger: true }
|
||||
]
|
||||
|
||||
function clampIndex(index) { return ((index % actions.length) + actions.length) % actions.length }
|
||||
function selectIndex(index) { selectedIndex = clampIndex(index); armedIndex = -1 }
|
||||
function open() { mouseWasInside = false; armedIndex = -1; visible = true; keyScope.forceActiveFocus() }
|
||||
function toggle() { visible = !visible; if (visible) { mouseWasInside = false; armedIndex = -1; keyScope.forceActiveFocus() } }
|
||||
function runAction(index) {
|
||||
const action = actions[index]
|
||||
if (action.danger && armedIndex !== index) { armedIndex = index; return }
|
||||
actionProcess.command = ["bash", "-lc", action.cmd]
|
||||
actionProcess.running = true
|
||||
visible = false
|
||||
armedIndex = -1
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "powerMenu"
|
||||
function open() { win.open() }
|
||||
function toggle() { win.toggle() }
|
||||
function lock() { win.runAction(0) }
|
||||
function logout() { win.runAction(1) }
|
||||
function suspend() { win.runAction(2) }
|
||||
function reboot() { win.runAction(3) }
|
||||
function shutdown() { win.runAction(4) }
|
||||
}
|
||||
|
||||
Item {
|
||||
id: keyScope
|
||||
anchors.fill: parent
|
||||
focus: win.visible
|
||||
|
||||
Keys.onPressed: function(event) {
|
||||
if (event.key === Qt.Key_Left || event.key === Qt.Key_H) { win.selectIndex(win.selectedIndex - 1); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Right || event.key === Qt.Key_L) { win.selectIndex(win.selectedIndex + 1); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter || event.key === Qt.Key_Space) { win.runAction(win.selectedIndex); event.accepted = true }
|
||||
else if (event.key === Qt.Key_Escape) { win.visible = false; event.accepted = true }
|
||||
}
|
||||
|
||||
MouseArea { anchors.fill: parent; hoverEnabled: true; acceptedButtons: Qt.NoButton; onEntered: win.mouseWasInside = true; onExited: if (win.mouseWasInside) win.visible = false }
|
||||
|
||||
Rectangle { anchors.fill: parent; radius: 34; color: Qt.rgba(Theme.base.r, Theme.base.g, Theme.base.b, 0.13); border.color: Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.38); border.width: 1 }
|
||||
|
||||
Row {
|
||||
id: row
|
||||
anchors.centerIn: parent
|
||||
spacing: 16
|
||||
Repeater {
|
||||
model: win.actions.length
|
||||
Rectangle {
|
||||
id: card
|
||||
property var action: win.actions[index]
|
||||
property bool selected: index === win.selectedIndex
|
||||
property bool armed: index === win.armedIndex
|
||||
width: selected ? 150 : 126
|
||||
height: selected ? 190 : 162
|
||||
radius: selected ? 28 : 24
|
||||
y: selected ? -10 : 4
|
||||
color: armed ? Qt.rgba(Theme.red.r, Theme.red.g, Theme.red.b, 0.28) : Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.70)
|
||||
border.color: armed ? Theme.red : selected ? Theme.mauve : Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.60)
|
||||
border.width: selected ? 3 : 1
|
||||
antialiasing: true
|
||||
|
||||
Behavior on width { NumberAnimation { duration: 130; easing.type: Easing.OutCubic } }
|
||||
Behavior on height { NumberAnimation { duration: 130; easing.type: Easing.OutCubic } }
|
||||
Behavior on y { NumberAnimation { duration: 130; easing.type: Easing.OutCubic } }
|
||||
Behavior on border.color { ColorAnimation { duration: 100 } }
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 14
|
||||
spacing: 8
|
||||
Text { Layout.alignment: Qt.AlignHCenter; text: card.action.icon; font.family: Theme.fontFamily; font.pixelSize: card.selected ? 46 : 36; color: card.armed ? Theme.red : Theme.text }
|
||||
Text { Layout.alignment: Qt.AlignHCenter; text: card.action.name; font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize + 2; font.bold: true; color: Theme.text }
|
||||
Text { Layout.fillWidth: true; text: card.armed ? "Press Enter again" : card.action.hint; horizontalAlignment: Text.AlignHCenter; wrapMode: Text.WordWrap; font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize - 3; color: card.armed ? Theme.red : Theme.overlay2 }
|
||||
}
|
||||
MouseArea { anchors.fill: parent; onClicked: { if (card.selected) win.runAction(index); else win.selectIndex(index); keyScope.forceActiveFocus() } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left; anchors.right: parent.right; anchors.bottom: parent.bottom
|
||||
anchors.leftMargin: 42; anchors.rightMargin: 42; anchors.bottomMargin: 22
|
||||
height: 44; radius: 18
|
||||
color: Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.42)
|
||||
border.color: Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.45)
|
||||
Text { anchors.centerIn: parent; text: "←/→ select · Enter apply" + (win.armedIndex >= 0 ? " again · Esc cancel" : " · Esc close"); font.family: Theme.fontFamily; font.pixelSize: Theme.fontPixelSize - 1; color: Theme.text }
|
||||
}
|
||||
}
|
||||
|
||||
Process { id: actionProcess; running: false }
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../core"
|
||||
|
||||
RowLayout {
|
||||
spacing: 8
|
||||
|
||||
// State properties
|
||||
property string wifiSsid: ""
|
||||
property bool btConnected: false
|
||||
property string batteryPct: ""
|
||||
property bool isCharging: false
|
||||
|
||||
// Visibility
|
||||
property var monitor: null
|
||||
property bool exclusiveToScreen: false
|
||||
|
||||
// Poller
|
||||
Timer {
|
||||
interval: 3000
|
||||
running: true
|
||||
repeat: true
|
||||
triggeredOnStart: true
|
||||
onTriggered: {
|
||||
wifiProcess.running = true
|
||||
btProcess.running = true
|
||||
batProcess.running = true
|
||||
}
|
||||
}
|
||||
|
||||
// Wifi
|
||||
Process {
|
||||
id: wifiProcess
|
||||
command: ["sh", "-c", "nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -d: -f2"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
wifiSsid = text.trim();
|
||||
}
|
||||
}
|
||||
onExited: function(code, status) {
|
||||
if (code !== 0) wifiSsid = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Bluetooth
|
||||
Process {
|
||||
id: btProcess
|
||||
command: ["sh", "-c", "bluetoothctl info | grep 'Connected: yes'"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
btConnected = text.trim().length > 0;
|
||||
}
|
||||
}
|
||||
onExited: function(code, status) {
|
||||
if (code !== 0) btConnected = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Battery
|
||||
Process {
|
||||
id: batProcess
|
||||
command: ["sh", "-c", "if ls /sys/class/power_supply/BAT* >/dev/null 2>&1; then cat /sys/class/power_supply/BAT*/capacity | head -n1; cat /sys/class/power_supply/BAT*/status | head -n1; fi"]
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
var lines = text.trim().split("\n");
|
||||
if (lines.length >= 2) {
|
||||
batteryPct = lines[0];
|
||||
isCharging = (lines[1] === "Charging");
|
||||
} else {
|
||||
batteryPct = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UI Elements
|
||||
ModuleContainer {
|
||||
monitor: parent.monitor
|
||||
exclusiveToScreen: parent.exclusiveToScreen
|
||||
active: wifiSsid !== ""
|
||||
pillColor: Theme.primary
|
||||
icon: ""
|
||||
text: wifiSsid
|
||||
}
|
||||
|
||||
ModuleContainer {
|
||||
monitor: parent.monitor
|
||||
exclusiveToScreen: parent.exclusiveToScreen
|
||||
active: btConnected
|
||||
pillColor: Theme.primary
|
||||
icon: ""
|
||||
text: "Connected"
|
||||
}
|
||||
|
||||
ModuleContainer {
|
||||
monitor: parent.monitor
|
||||
exclusiveToScreen: parent.exclusiveToScreen
|
||||
active: batteryPct !== ""
|
||||
pillColor: Theme.accent
|
||||
icon: isCharging ? "" : ""
|
||||
text: batteryPct + "%"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Hyprland
|
||||
import "../core"
|
||||
|
||||
RowLayout {
|
||||
id: root
|
||||
spacing: 4
|
||||
|
||||
property var monitor: null
|
||||
|
||||
Repeater {
|
||||
model: Hyprland.workspaces
|
||||
|
||||
delegate: Rectangle {
|
||||
property var ws: modelData
|
||||
|
||||
// Only show workspaces belonging to the specific monitor
|
||||
visible: root.monitor === null || (ws.monitor && ws.monitor.name === root.monitor.name)
|
||||
|
||||
width: visible ? 28 : 0
|
||||
height: visible ? 28 : 0
|
||||
radius: Theme.radius / 2
|
||||
|
||||
// Highlight if active
|
||||
color: ws.isActive ? Theme.primary : Theme.bgAlt
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: ws.id
|
||||
color: ws.isActive ? Theme.bg : Theme.fg
|
||||
font: Theme.fontBold
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: Hyprland.dispatch("workspace", ws.id)
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
Workspaces Workspaces.qml
|
||||
Clock Clock.qml
|
||||
StatusIndicators StatusIndicators.qml
|
||||
NotificationDaemon NotificationDaemon.qml
|
||||
ModuleContainer ModuleContainer.qml
|
||||
AppLauncherWindow AppLauncherWindow.qml
|
||||
ClipboardPickerWindow ClipboardPickerWindow.qml
|
||||
PowerMenuWindow PowerMenuWindow.qml
|
||||
Reference in new issue
Block a user