feat: initial commit
This commit is contained in:
commit
4b3cd1d2b1
453 files changed
+52428
No files matched your search
@@ -0,0 +1,185 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import Quickshell.Widgets as QSW
|
||||
import qs.Theme
|
||||
|
||||
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 hist = Quickshell.env("HOME") + "/.cache/quickshell/app-launcher-history"
|
||||
launchProcess.command = ["bash", "-lc", "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) + "; gtk-launch " + shellQuote(id)]
|
||||
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=glob.glob('/usr/share/applications/*.desktop')+glob.glob(os.path.expanduser('~/.local/share/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,'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 }
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
Item {
|
||||
implicitWidth: label.implicitWidth
|
||||
implicitHeight: label.implicitHeight
|
||||
|
||||
Text {
|
||||
id: label
|
||||
text: "\uF028 —%"
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.peach
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Process {
|
||||
id: process
|
||||
command: ["sh", "-c", "wpctl get-volume @DEFAULT_AUDIO_SINK@ 2>/dev/null"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: function() {
|
||||
var s = text.trim()
|
||||
var muted = s.indexOf("MUTED") >= 0
|
||||
var m = s.match(/[\d.]+/)
|
||||
var vol = m ? parseFloat(m[0]) : 0
|
||||
var pct = Math.round(vol * 100)
|
||||
label.text = (muted ? "\uF6A9 " : "\uF028 ") + pct + "%"
|
||||
label.color = muted ? Theme.overlay0 : Theme.peach
|
||||
}
|
||||
}
|
||||
onExited: restartTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restartTimer
|
||||
interval: 2000
|
||||
repeat: false
|
||||
onTriggered: process.running = true
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||
onClicked: function(mouse) {
|
||||
if (mouse.button === Qt.RightButton)
|
||||
Quickshell.execDetached(["wpctl", "set-mute", "@DEFAULT_AUDIO_SINK@", "toggle"])
|
||||
else
|
||||
Quickshell.execDetached(["pavucontrol"])
|
||||
process.running = false
|
||||
process.running = true
|
||||
}
|
||||
}
|
||||
|
||||
Component.onCompleted: process.running = true
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
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,231 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import qs.Theme
|
||||
|
||||
Item {
|
||||
id: clockRoot
|
||||
property bool popupOpen: false
|
||||
property var panelWindow: null
|
||||
implicitWidth: label.implicitWidth
|
||||
implicitHeight: label.implicitHeight
|
||||
|
||||
Text {
|
||||
id: label
|
||||
text: "\uF017 " + Qt.formatDateTime(new Date(), "HH:mm d MMM")
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.mauve
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Timer {
|
||||
interval: 1000
|
||||
running: true
|
||||
repeat: true
|
||||
onTriggered: label.text = "\uF017 " + Qt.formatDateTime(new Date(), "HH:mm d MMM")
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton
|
||||
onClicked: clockRoot.popupOpen = !clockRoot.popupOpen
|
||||
}
|
||||
|
||||
PopupWindow {
|
||||
id: popup
|
||||
visible: clockRoot.popupOpen
|
||||
implicitWidth: 280
|
||||
implicitHeight: 320
|
||||
anchor.item: clockRoot
|
||||
anchor.rect: Qt.rect(0, clockRoot.height, clockRoot.width, 1)
|
||||
anchor.edges: Qt.AlignTop | Qt.AlignLeft
|
||||
anchor.gravity: Qt.AlignBottom | Qt.AlignRight
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: Qt.rgba(Theme.base.r, Theme.base.g, Theme.base.b, 0.85)
|
||||
border.color: Theme.surface1
|
||||
radius: 8
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
spacing: 6
|
||||
|
||||
// Header: close only
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Item { Layout.fillWidth: true }
|
||||
Text {
|
||||
text: "×"
|
||||
font.pixelSize: Theme.fontPixelSize + 4
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.subtext0
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
anchors.margins: -4
|
||||
onClicked: clockRoot.popupOpen = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Month navigation
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Layout.topMargin: 4
|
||||
spacing: 4
|
||||
Text {
|
||||
text: "‹"
|
||||
font.pixelSize: Theme.fontPixelSize + 2
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.subtext0
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
anchors.margins: -6
|
||||
onClicked: calendar.prevMonth()
|
||||
}
|
||||
}
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: Qt.formatDate(calendar.viewDate, "MMMM yyyy")
|
||||
font.pixelSize: Theme.fontPixelSize + 1
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.text
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
}
|
||||
Text {
|
||||
text: "›"
|
||||
font.pixelSize: Theme.fontPixelSize + 2
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.subtext0
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
anchors.margins: -6
|
||||
onClicked: calendar.nextMonth()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Item { Layout.fillWidth: true }
|
||||
Text {
|
||||
text: "Today"
|
||||
font.pixelSize: Theme.fontPixelSize - 2
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.sky
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
anchors.margins: -4
|
||||
onClicked: {
|
||||
calendar.viewDate = new Date()
|
||||
calendar.refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
Item { Layout.fillWidth: true }
|
||||
}
|
||||
// Day names (Mon–Sun)
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
Repeater {
|
||||
model: ["M", "T", "W", "T", "F", "S", "S"]
|
||||
Text {
|
||||
Layout.preferredWidth: 32
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
text: modelData
|
||||
font.pixelSize: Theme.fontPixelSize - 2
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.overlay0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calendar grid
|
||||
GridLayout {
|
||||
id: calGrid
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
columns: 7
|
||||
rowSpacing: 2
|
||||
columnSpacing: 2
|
||||
Repeater {
|
||||
model: calendar.daysModel
|
||||
Rectangle {
|
||||
Layout.preferredWidth: 32
|
||||
Layout.preferredHeight: 24
|
||||
Layout.alignment: Qt.AlignHCenter
|
||||
color: modelData.isToday ? Theme.surface1 : "transparent"
|
||||
radius: 4
|
||||
border.color: modelData.isToday ? Theme.mauve : "transparent"
|
||||
border.width: 1
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: modelData.day > 0 ? modelData.day : ""
|
||||
font.pixelSize: Theme.fontPixelSize - 1
|
||||
font.family: Theme.fontFamily
|
||||
color: modelData.isCurrentMonth ? Theme.text : Theme.overlay0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: calendar
|
||||
property date viewDate: new Date()
|
||||
property var daysModel: []
|
||||
|
||||
function refresh() {
|
||||
var d = new Date(viewDate.getFullYear(), viewDate.getMonth(), 1)
|
||||
var year = d.getFullYear(), month = d.getMonth()
|
||||
var firstWeekday = (d.getDay() + 6) % 7 // Mon=0
|
||||
var daysInMonth = new Date(year, month + 1, 0).getDate()
|
||||
var today = new Date()
|
||||
var todayDate = today.getDate()
|
||||
var todayMonth = today.getMonth()
|
||||
var todayYear = today.getFullYear()
|
||||
var list = []
|
||||
var i
|
||||
for (i = 0; i < firstWeekday; i++)
|
||||
list.push({ day: 0, isToday: false, isCurrentMonth: false })
|
||||
for (i = 1; i <= daysInMonth; i++)
|
||||
list.push({
|
||||
day: i,
|
||||
isToday: i === todayDate && month === todayMonth && year === todayYear,
|
||||
isCurrentMonth: true
|
||||
})
|
||||
var total = list.length
|
||||
var remainder = total % 7
|
||||
if (remainder) {
|
||||
for (i = 0; i < 7 - remainder; i++)
|
||||
list.push({ day: 0, isToday: false, isCurrentMonth: false })
|
||||
}
|
||||
daysModel = list
|
||||
}
|
||||
|
||||
function prevMonth() {
|
||||
viewDate = new Date(viewDate.getFullYear(), viewDate.getMonth() - 1, 1)
|
||||
refresh()
|
||||
}
|
||||
function nextMonth() {
|
||||
viewDate = new Date(viewDate.getFullYear(), viewDate.getMonth() + 1, 1)
|
||||
refresh()
|
||||
}
|
||||
|
||||
Component.onCompleted: refresh()
|
||||
onViewDateChanged: refresh()
|
||||
}
|
||||
|
||||
Connections {
|
||||
target: clockRoot
|
||||
function onPopupOpenChanged() {
|
||||
if (clockRoot.popupOpen)
|
||||
calendar.viewDate = new Date()
|
||||
calendar.refresh()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
Item {
|
||||
id: root
|
||||
implicitWidth: label.implicitWidth
|
||||
implicitHeight: label.implicitHeight
|
||||
|
||||
Text {
|
||||
id: label
|
||||
text: "\uE266 —%"
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.rosewater
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Process {
|
||||
id: process
|
||||
command: ["sh", "-c", "read cpu user nice sys idle iowait irq softirq steal guest guest_nice < /proc/stat; idle1=$((idle+iowait)); nonidle1=$((user+nice+sys+irq+softirq+steal)); total1=$((idle1+nonidle1)); sleep 1; read cpu user nice sys idle iowait irq softirq steal guest guest_nice < /proc/stat; idle2=$((idle+iowait)); nonidle2=$((user+nice+sys+irq+softirq+steal)); total2=$((idle2+nonidle2)); totald=$((total2-total1)); idled=$((idle2-idle1)); [ \"$totald\" -gt 0 ] && printf '%s\\n' $(((1000*(totald-idled)/totald + 5)/10)) || printf '0\\n'"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: function() {
|
||||
var v = text.trim()
|
||||
label.text = "\uE266 " + (v || "—") + "%"
|
||||
}
|
||||
}
|
||||
onExited: restartTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restartTimer
|
||||
interval: 2000
|
||||
repeat: false
|
||||
onTriggered: process.running = true
|
||||
}
|
||||
|
||||
Component.onCompleted: process.running = true
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
Row {
|
||||
id: root
|
||||
spacing: Theme.spacing
|
||||
|
||||
property ListModel workspaces: ListModel {}
|
||||
|
||||
Process {
|
||||
id: process
|
||||
command: ["sh", "-c", "hyprctl activeworkspace -j | jq .id; hyprctl workspaces -j | jq -c ."]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: function() {
|
||||
var lines = text.trim().split('\n');
|
||||
if (lines.length < 2) return;
|
||||
var activeId = parseInt(lines[0], 10);
|
||||
var workspacesData = JSON.parse(lines[1]);
|
||||
|
||||
workspaces.clear();
|
||||
workspacesData.forEach(workspace => {
|
||||
workspaces.append({
|
||||
"tagId": workspace.id,
|
||||
"output": workspace.monitor,
|
||||
"isOccupied": workspace.windows > 0,
|
||||
"isActive": workspace.id === activeId,
|
||||
"isUrgent": false
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
onExited: restartTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restartTimer
|
||||
interval: 500
|
||||
repeat: false
|
||||
onTriggered: process.running = true
|
||||
}
|
||||
|
||||
Component.onCompleted: process.running = true
|
||||
|
||||
Repeater {
|
||||
model: workspaces
|
||||
delegate: Rectangle {
|
||||
height: Theme.barHeight - 16
|
||||
width: height
|
||||
radius: width / 2
|
||||
color: model.isActive ? Theme.mauve : (model.isOccupied ? Theme.surface1 : Theme.surface0)
|
||||
border.color: model.isUrgent ? Theme.red : "transparent"
|
||||
border.width: 2
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: model.tagId
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
Quickshell.execDetached(["hyprctl", "dispatch", "workspace", model.tagId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
Item {
|
||||
implicitWidth: label.implicitWidth
|
||||
implicitHeight: label.implicitHeight
|
||||
|
||||
Text {
|
||||
id: label
|
||||
text: "\uF2DB —/—GB"
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.rosewater
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Process {
|
||||
id: process
|
||||
command: ["sh", "-c", "free -g | awk '/^Mem:/ {print $3 \" \" $2}'"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: function() {
|
||||
var parts = text.trim().split(/\s+/)
|
||||
var used = parts[0] || "—", total = parts[1] || "—"
|
||||
label.text = "\uF2DB " + used + "/" + total + "GB"
|
||||
}
|
||||
}
|
||||
onExited: restartTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restartTimer
|
||||
interval: 30000
|
||||
repeat: false
|
||||
onTriggered: process.running = true
|
||||
}
|
||||
|
||||
Component.onCompleted: process.running = true
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
Item {
|
||||
id: root
|
||||
implicitWidth: row.implicitWidth
|
||||
implicitHeight: row.implicitHeight
|
||||
|
||||
property string downText: "—"
|
||||
property string upText: "—"
|
||||
|
||||
// Internal state for delta calculation
|
||||
property real prevRx: 0
|
||||
property real prevTx: 0
|
||||
property var lastUpdate: 0
|
||||
|
||||
RowLayout {
|
||||
id: row
|
||||
anchors.fill: parent
|
||||
spacing: 8
|
||||
|
||||
Text {
|
||||
text: "\uF437"
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.peach
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "\uF0AB"
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.peach
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
Text {
|
||||
Layout.preferredWidth: 44
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text: downText
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.peach
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
|
||||
Text {
|
||||
text: "\uF0AA"
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.peach
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
Text {
|
||||
Layout.preferredWidth: 44
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
text: upText
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.peach
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
horizontalAlignment: Text.AlignLeft
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: process
|
||||
command: ["sh", "-c", "awk 'NR>2 && $1!~/^lo:/ {rx+=$2; tx+=$10} END{print rx+0, tx+0}' /proc/net/dev"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: function() {
|
||||
var now = Date.now();
|
||||
var parts = text.trim().split(/\s+/);
|
||||
|
||||
if (parts.length >= 2) {
|
||||
var rx = parseInt(parts[0], 10) || 0;
|
||||
var tx = parseInt(parts[1], 10) || 0;
|
||||
|
||||
// Only calculate speed if we have a previous data point
|
||||
if (root.prevRx > 0) {
|
||||
var elapsed = (now - root.lastUpdate) / 1000;
|
||||
if (elapsed <= 0) elapsed = 1; // Prevent division by zero
|
||||
|
||||
var down = (rx - root.prevRx) / elapsed;
|
||||
var up = (tx - root.prevTx) / elapsed;
|
||||
|
||||
function fmt(bytesPerSec) {
|
||||
var bps = bytesPerSec * 8; // Convert to bits per second
|
||||
if (bps >= 1e6) return (bps / 1e6).toFixed(1) + "Mb";
|
||||
if (bps >= 1e3) return (bps / 1e3).toFixed(0) + "Kb";
|
||||
return bps.toFixed(0) + "b";
|
||||
}
|
||||
|
||||
root.downText = fmt(down);
|
||||
root.upText = fmt(up);
|
||||
}
|
||||
|
||||
root.prevRx = rx;
|
||||
root.prevTx = tx;
|
||||
root.lastUpdate = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
onExited: restartTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restartTimer
|
||||
interval: 2000
|
||||
repeat: false
|
||||
onTriggered: process.running = true
|
||||
}
|
||||
|
||||
Component.onCompleted: process.running = true
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
import QtQuick
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
Row {
|
||||
id: root
|
||||
spacing: Theme.spacing
|
||||
|
||||
property ListModel workspaces: ListModel {}
|
||||
|
||||
Process {
|
||||
id: workspaceProcess
|
||||
running: true
|
||||
command: ["mmsg", "-w"]
|
||||
|
||||
stdout: SplitParser {
|
||||
onRead: line => {
|
||||
parseWorkspaceLine(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function parseWorkspaceLine(line) {
|
||||
const tagBinary = /^(\S+)\s+tags\s+([01]+)\s+([01]+)\s+([01]+)$/
|
||||
const match = line.match(tagBinary);
|
||||
|
||||
if (match) {
|
||||
const outputName = match[1];
|
||||
const occ = match[2];
|
||||
const sel = match[3];
|
||||
const urg = match[4];
|
||||
|
||||
workspaces.clear();
|
||||
|
||||
for (let i = 0; i < occ.length; i++) {
|
||||
const tagId = i + 1;
|
||||
const charIdx = occ.length - 1 - i;
|
||||
|
||||
const isOccupied = occ[charIdx] === '1';
|
||||
const isActive = sel[charIdx] === '1';
|
||||
const isUrgent = urg[charIdx] === '1';
|
||||
|
||||
workspaces.append({
|
||||
"tagId": tagId,
|
||||
"output": outputName,
|
||||
"isOccupied": isOccupied,
|
||||
"isActive": isActive,
|
||||
"isUrgent": isUrgent
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: workspaces
|
||||
delegate: Rectangle {
|
||||
height: Theme.barHeight - 16
|
||||
width: height
|
||||
radius: width / 2
|
||||
color: model.isActive ? Theme.mauve : (model.isOccupied ? Theme.surface1 : Theme.surface0)
|
||||
border.color: model.isUrgent ? Theme.red : "transparent"
|
||||
border.width: 2
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: model.tagId
|
||||
color: Theme.text
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
Quickshell.execDetached(["mmsg", "-s", "-t", model.tagId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
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: "Hyprland 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,48 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
Item {
|
||||
implicitWidth: label.implicitWidth
|
||||
implicitHeight: label.implicitHeight
|
||||
|
||||
Text {
|
||||
id: label
|
||||
text: "\uF0A0 —"
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.text
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Process {
|
||||
id: process
|
||||
command: ["sh", "-c", "df -h -P -l / | awk 'NR==2 {gsub(/%/,\"\",$5); print $5 \" \" $4}'"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: function() {
|
||||
var parts = text.trim().split(/\s+/)
|
||||
var pct = parts[0] || "—"
|
||||
var avail = parts[1] || ""
|
||||
label.text = "\uF0A0 " + (avail ? avail : pct + "%")
|
||||
var n = parseInt(pct, 10)
|
||||
if (!isNaN(n)) {
|
||||
if (n >= 90) label.color = Theme.red
|
||||
else if (n >= 80) label.color = Theme.yellow
|
||||
else label.color = Theme.text
|
||||
}
|
||||
}
|
||||
}
|
||||
onExited: restartTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restartTimer
|
||||
interval: 60000
|
||||
repeat: false
|
||||
onTriggered: process.running = true
|
||||
}
|
||||
|
||||
Component.onCompleted: process.running = true
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import QtQuick
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property string hwmonPath: "" // e.g. /sys/class/hwmon/hwmon2/temp1_input
|
||||
implicitWidth: label.implicitWidth
|
||||
implicitHeight: label.implicitHeight
|
||||
|
||||
Text {
|
||||
id: label
|
||||
text: "\uF2C8 —°C"
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
font.family: Theme.fontFamily
|
||||
color: Theme.rosewater
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
Process {
|
||||
id: process
|
||||
command: root.hwmonPath ? ["bash", "/home/johannes/.config/quickshell/scripts/cpu-temp.sh", root.hwmonPath] : ["bash", "/home/johannes/.config/quickshell/scripts/cpu-temp.sh"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: function() {
|
||||
var v = text.trim()
|
||||
label.text = "\uF2C8 " + (v ? v + "°C" : "—°C")
|
||||
}
|
||||
}
|
||||
onExited: restartTimer.start()
|
||||
}
|
||||
|
||||
Timer {
|
||||
id: restartTimer
|
||||
interval: 4000
|
||||
repeat: false
|
||||
onTriggered: process.running = true
|
||||
}
|
||||
|
||||
Component.onCompleted: process.running = true
|
||||
}
|
||||
@@ -0,0 +1,383 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
FloatingWindow {
|
||||
id: win
|
||||
title: "Theme Switcher"
|
||||
visible: false
|
||||
implicitWidth: 920
|
||||
implicitHeight: 460
|
||||
color: "transparent"
|
||||
|
||||
property string scriptsDir: Quickshell.env("HOME") + "/.config/nushell/scripts"
|
||||
property string currentTheme: "—"
|
||||
property int selectedIndex: currentTheme === "latte" ? 2 : currentTheme === "mocha" ? 1 : 0
|
||||
property bool mouseWasInside: false
|
||||
readonly property var modes: ["auto", "mocha", "latte"]
|
||||
readonly property var names: ["Auto", "Mocha", "Latte"]
|
||||
readonly property var subtitles: ["Follow darkman / system", "Catppuccin dark", "Catppuccin light"]
|
||||
|
||||
function clampIndex(index) {
|
||||
return ((index % modes.length) + modes.length) % modes.length
|
||||
}
|
||||
|
||||
function selectIndex(index) {
|
||||
selectedIndex = clampIndex(index)
|
||||
}
|
||||
|
||||
function selectedMode() {
|
||||
return modes[selectedIndex]
|
||||
}
|
||||
|
||||
function selectedName() {
|
||||
return names[selectedIndex]
|
||||
}
|
||||
|
||||
function modeForOffset(offset) {
|
||||
return modes[clampIndex(selectedIndex + offset)]
|
||||
}
|
||||
|
||||
function nameForMode(mode) {
|
||||
const idx = modes.indexOf(mode)
|
||||
return idx >= 0 ? names[idx] : mode
|
||||
}
|
||||
|
||||
function subtitleForMode(mode) {
|
||||
const idx = modes.indexOf(mode)
|
||||
return idx >= 0 ? subtitles[idx] : ""
|
||||
}
|
||||
|
||||
function open() {
|
||||
mouseWasInside = false
|
||||
visible = true
|
||||
refresh()
|
||||
keyScope.forceActiveFocus()
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
visible = !visible
|
||||
if (visible) {
|
||||
mouseWasInside = false
|
||||
refresh()
|
||||
keyScope.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
function refresh() { themeState.running = true }
|
||||
|
||||
function runTheme(mode) {
|
||||
themeApply.command = [scriptsDir + "/theme-switch.nu", "--" + mode]
|
||||
themeApply.running = true
|
||||
visible = false
|
||||
}
|
||||
|
||||
function applySelected() {
|
||||
runTheme(selectedMode())
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "themeSwitcher"
|
||||
function open() { win.open() }
|
||||
function toggle() { win.toggle() }
|
||||
function autoTheme() { win.runTheme("auto") }
|
||||
function mocha() { win.runTheme("mocha") }
|
||||
function latte() { win.runTheme("latte") }
|
||||
}
|
||||
|
||||
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.applySelected()
|
||||
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
|
||||
}
|
||||
|
||||
Item {
|
||||
id: carousel
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
anchors.topMargin: 24
|
||||
anchors.bottomMargin: 76
|
||||
clip: false
|
||||
|
||||
Repeater {
|
||||
model: [-1, 0, 1]
|
||||
|
||||
ThemeCard {
|
||||
id: card
|
||||
property int offset: modelData
|
||||
property string mode: win.modeForOffset(offset)
|
||||
property bool centered: offset === 0
|
||||
|
||||
width: centered ? 430 : 330
|
||||
height: centered ? 300 : 230
|
||||
x: carousel.width / 2 - width / 2 + offset * 260
|
||||
y: carousel.height / 2 - height / 2
|
||||
z: centered ? 20 : 10
|
||||
|
||||
modeName: win.nameForMode(mode)
|
||||
subtitle: win.subtitleForMode(mode)
|
||||
themeMode: mode
|
||||
active: mode === win.currentTheme
|
||||
selected: centered
|
||||
|
||||
Behavior on x { NumberAnimation { duration: 140; easing.type: Easing.OutCubic } }
|
||||
Behavior on y { NumberAnimation { duration: 140; easing.type: Easing.OutCubic } }
|
||||
Behavior on width { NumberAnimation { duration: 130; easing.type: Easing.OutCubic } }
|
||||
Behavior on height { NumberAnimation { duration: 130; easing.type: Easing.OutCubic } }
|
||||
|
||||
onClicked: {
|
||||
if (centered) win.applySelected()
|
||||
else win.selectIndex(win.selectedIndex + offset)
|
||||
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: 48
|
||||
radius: 20
|
||||
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)
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 14
|
||||
anchors.rightMargin: 14
|
||||
spacing: 12
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: win.selectedName() + " · Current: " + win.currentTheme
|
||||
elide: Text.ElideMiddle
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
color: Theme.text
|
||||
}
|
||||
|
||||
Text {
|
||||
text: (win.selectedIndex + 1) + " / 3 · ←/→ select · Enter apply · Esc"
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontPixelSize - 2
|
||||
color: Theme.overlay2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component ThemeCard: Rectangle {
|
||||
id: card
|
||||
property string modeName: ""
|
||||
property string subtitle: ""
|
||||
property string themeMode: "mocha"
|
||||
property bool active: false
|
||||
property bool selected: false
|
||||
signal clicked()
|
||||
|
||||
radius: selected ? 30 : 26
|
||||
color: card.themeMode === "latte" ? "#eff1f5" : card.themeMode === "mocha" ? "#1e1e2e" : Qt.rgba(Theme.crust.r, Theme.crust.g, Theme.crust.b, 0.88)
|
||||
border.color: selected ? Theme.mauve : active ? Theme.green : Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.65)
|
||||
border.width: selected ? 3 : 1
|
||||
opacity: selected ? 1.0 : 0.86
|
||||
antialiasing: true
|
||||
|
||||
property color fg: themeMode === "latte" ? "#4c4f69" : "#cdd6f4"
|
||||
property color sub: themeMode === "latte" ? "#6c6f85" : "#bac2de"
|
||||
property color base: themeMode === "latte" ? "#eff1f5" : "#1e1e2e"
|
||||
property color crust: themeMode === "latte" ? "#dce0e8" : "#11111b"
|
||||
property color surface: themeMode === "latte" ? "#ccd0da" : "#313244"
|
||||
property color accent: themeMode === "latte" ? "#8839ef" : "#cba6f7"
|
||||
property color blue: themeMode === "latte" ? "#1e66f5" : "#89b4fa"
|
||||
property color green: themeMode === "latte" ? "#40a02b" : "#a6e3a1"
|
||||
property color peach: themeMode === "latte" ? "#fe640b" : "#fab387"
|
||||
property int dotSize: selected ? 28 : 18
|
||||
property int dotGap: selected ? 8 : 5
|
||||
|
||||
Behavior on opacity { NumberAnimation { duration: 120; easing.type: Easing.OutCubic } }
|
||||
Behavior on border.color { ColorAnimation { duration: 100 } }
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 12
|
||||
radius: card.radius - 8
|
||||
color: Qt.rgba(card.crust.r, card.crust.g, card.crust.b, 0.72)
|
||||
border.color: Qt.rgba(card.surface.r, card.surface.g, card.surface.b, 0.88)
|
||||
|
||||
ColumnLayout {
|
||||
anchors.fill: parent
|
||||
anchors.margins: card.selected ? 18 : 14
|
||||
spacing: card.selected ? 12 : 9
|
||||
|
||||
RowLayout {
|
||||
Layout.fillWidth: true
|
||||
spacing: 10
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: card.modeName
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontPixelSize + (card.selected ? 8 : 3)
|
||||
font.bold: true
|
||||
color: card.fg
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: card.active
|
||||
width: 34
|
||||
height: 34
|
||||
radius: 17
|
||||
color: Qt.rgba(card.green.r, card.green.g, card.green.b, 0.92)
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "✓"
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontPixelSize + 2
|
||||
color: card.base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Text {
|
||||
text: card.subtitle
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontPixelSize - 1
|
||||
color: card.sub
|
||||
}
|
||||
|
||||
Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: 18
|
||||
color: card.base
|
||||
border.color: card.surface
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.margins: 12
|
||||
width: parent.width * 0.24
|
||||
radius: 13
|
||||
color: card.crust
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.margins: 12
|
||||
height: 26
|
||||
radius: 13
|
||||
color: card.surface
|
||||
}
|
||||
|
||||
Column {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.leftMargin: parent.width * 0.32
|
||||
anchors.rightMargin: 16
|
||||
anchors.topMargin: 52
|
||||
anchors.bottomMargin: 16
|
||||
spacing: 10
|
||||
|
||||
Rectangle { width: parent.width * 0.78; height: 18; radius: 9; color: card.accent }
|
||||
Rectangle { width: parent.width; height: 16; radius: 8; color: card.surface }
|
||||
Rectangle { width: parent.width * 0.64; height: 16; radius: 8; color: card.surface }
|
||||
|
||||
}
|
||||
|
||||
Row {
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.rightMargin: 16
|
||||
anchors.bottomMargin: card.selected ? 16 : 30
|
||||
spacing: card.dotGap
|
||||
Rectangle { width: card.dotSize; height: card.dotSize; radius: card.dotSize / 2; color: card.accent }
|
||||
Rectangle { width: card.dotSize; height: card.dotSize; radius: card.dotSize / 2; color: card.blue }
|
||||
Rectangle { width: card.dotSize; height: card.dotSize; radius: card.dotSize / 2; color: card.green }
|
||||
Rectangle { width: card.dotSize; height: card.dotSize; radius: card.dotSize / 2; color: card.peach }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: card.themeMode === "auto"
|
||||
anchors.fill: parent
|
||||
radius: 18
|
||||
gradient: Gradient {
|
||||
orientation: Gradient.Horizontal
|
||||
GradientStop { position: 0.0; color: "#eff1f5" }
|
||||
GradientStop { position: 0.48; color: "#eff1f5" }
|
||||
GradientStop { position: 0.52; color: "#1e1e2e" }
|
||||
GradientStop { position: 1.0; color: "#1e1e2e" }
|
||||
}
|
||||
opacity: 0.28
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
onClicked: card.clicked()
|
||||
}
|
||||
}
|
||||
|
||||
Process { id: themeApply; running: false; onExited: win.refresh() }
|
||||
Process {
|
||||
id: themeState
|
||||
command: ["sh", "-c", "cat ~/.config/current-theme 2>/dev/null || echo unknown"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
win.currentTheme = text.trim()
|
||||
win.selectedIndex = win.currentTheme === "latte" ? 2 : win.currentTheme === "mocha" ? 1 : win.selectedIndex
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Services.SystemTray
|
||||
import qs.Theme
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property var panelWindow: null
|
||||
implicitWidth: trayRow.implicitWidth
|
||||
implicitHeight: trayRow.implicitHeight
|
||||
|
||||
RowLayout {
|
||||
id: trayRow
|
||||
anchors.fill: parent
|
||||
spacing: 4
|
||||
|
||||
Repeater {
|
||||
model: SystemTray.items
|
||||
|
||||
delegate: Item {
|
||||
Layout.preferredWidth: 24
|
||||
Layout.preferredHeight: 24
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
|
||||
Image {
|
||||
id: icon
|
||||
anchors.centerIn: parent
|
||||
width: 20
|
||||
height: 20
|
||||
source: modelData.icon || ""
|
||||
sourceSize: Qt.size(width, height)
|
||||
smooth: true
|
||||
mipmap: true
|
||||
visible: !!modelData.icon
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: ma
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
|
||||
onClicked: function(mouse) {
|
||||
if (mouse.button === Qt.LeftButton)
|
||||
modelData.activate()
|
||||
else if (mouse.button === Qt.RightButton && root.panelWindow) {
|
||||
var p = ma.mapToItem(root.panelWindow.contentItem, mouse.x, mouse.y)
|
||||
modelData.display(root.panelWindow, p.x, p.y)
|
||||
} else if (mouse.button === Qt.MiddleButton)
|
||||
modelData.secondaryActivate()
|
||||
}
|
||||
onWheel: function(wheel) {
|
||||
modelData.scroll(wheel.angleDelta.y, false)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,285 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Widgets as QSW
|
||||
import Quickshell.Io
|
||||
import qs.Theme
|
||||
|
||||
FloatingWindow {
|
||||
id: win
|
||||
title: "Wallpaper Switcher"
|
||||
visible: false
|
||||
implicitWidth: 1120
|
||||
implicitHeight: 520
|
||||
color: "transparent"
|
||||
|
||||
property string scriptsDir: Quickshell.env("HOME") + "/.config/nushell/scripts"
|
||||
property var wallpapers: []
|
||||
property string currentWallpaper: "—"
|
||||
property int selectedIndex: 0
|
||||
property string selectedWallpaper: wallpapers.length > 0 ? wallpapers[selectedIndex] : ""
|
||||
readonly property int cellWidth: 520
|
||||
property bool mouseWasInside: false
|
||||
|
||||
function fileUrl(path) {
|
||||
if (!path || path === "—") return ""
|
||||
return "file://" + path
|
||||
}
|
||||
|
||||
function clampIndex(index) {
|
||||
if (wallpapers.length === 0) return 0
|
||||
return ((index % wallpapers.length) + wallpapers.length) % wallpapers.length
|
||||
}
|
||||
|
||||
function selectIndex(index) {
|
||||
if (wallpapers.length === 0) return
|
||||
selectedIndex = clampIndex(index)
|
||||
}
|
||||
|
||||
function selectPath(path) {
|
||||
const idx = wallpapers.indexOf(path)
|
||||
if (idx >= 0) selectIndex(idx)
|
||||
}
|
||||
|
||||
function open() {
|
||||
mouseWasInside = false
|
||||
visible = true
|
||||
refresh()
|
||||
keyScope.forceActiveFocus()
|
||||
}
|
||||
|
||||
function toggle() {
|
||||
visible = !visible
|
||||
if (visible) {
|
||||
mouseWasInside = false
|
||||
refresh()
|
||||
keyScope.forceActiveFocus()
|
||||
}
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
wallpaperState.running = true
|
||||
wallpaperList.running = true
|
||||
}
|
||||
|
||||
function applySelected() {
|
||||
if (selectedWallpaper) runWallpaper(["--set", selectedWallpaper])
|
||||
}
|
||||
|
||||
function runWallpaper(args) {
|
||||
wallpaperApply.command = [scriptsDir + "/wallpaper-switch.nu"].concat(args)
|
||||
wallpaperApply.running = true
|
||||
}
|
||||
|
||||
IpcHandler {
|
||||
target: "wallpaperSwitcher"
|
||||
function open() { win.open() }
|
||||
function toggle() { win.toggle() }
|
||||
function random() { win.runWallpaper(["--random"]) }
|
||||
}
|
||||
|
||||
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.applySelected()
|
||||
event.accepted = true
|
||||
} else if (event.key === Qt.Key_Escape) {
|
||||
win.visible = false
|
||||
event.accepted = true
|
||||
} else if (event.key === Qt.Key_R) {
|
||||
win.runWallpaper(["--random"])
|
||||
event.accepted = true
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
acceptedButtons: Qt.NoButton
|
||||
onEntered: win.mouseWasInside = true
|
||||
onExited: if (win.mouseWasInside) win.visible = false
|
||||
}
|
||||
|
||||
// Transparent glass layer: Hyprland blur handles the background behind this window.
|
||||
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
|
||||
}
|
||||
|
||||
Item {
|
||||
id: carousel
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 8
|
||||
anchors.rightMargin: 8
|
||||
anchors.topMargin: 24
|
||||
anchors.bottomMargin: 70
|
||||
clip: false
|
||||
|
||||
function pathForOffset(offset) {
|
||||
if (win.wallpapers.length === 0) return ""
|
||||
return win.wallpapers[win.clampIndex(win.selectedIndex + offset)]
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: [-1, 0, 1]
|
||||
|
||||
Item {
|
||||
id: cell
|
||||
property int offset: modelData
|
||||
property bool centered: offset === 0
|
||||
property string wallpaperPath: carousel.pathForOffset(offset)
|
||||
property bool current: wallpaperPath === win.currentWallpaper
|
||||
width: centered ? 610 : 500
|
||||
height: centered ? 390 : 320
|
||||
x: carousel.width / 2 - width / 2 + offset * 300
|
||||
y: carousel.height / 2 - height / 2
|
||||
z: centered ? 20 : 10
|
||||
|
||||
Behavior on x { NumberAnimation { duration: 140; easing.type: Easing.OutCubic } }
|
||||
Behavior on y { NumberAnimation { duration: 140; easing.type: Easing.OutCubic } }
|
||||
Behavior on width { NumberAnimation { duration: 130; easing.type: Easing.OutCubic } }
|
||||
Behavior on height { NumberAnimation { duration: 130; easing.type: Easing.OutCubic } }
|
||||
|
||||
QSW.ClippingRectangle {
|
||||
id: card
|
||||
anchors.fill: parent
|
||||
radius: centered ? 30 : 26
|
||||
color: Theme.crust
|
||||
border.color: centered ? Theme.mauve : Qt.rgba(Theme.surface1.r, Theme.surface1.g, Theme.surface1.b, 0.55)
|
||||
border.width: centered ? 3 : 1
|
||||
antialiasing: true
|
||||
contentUnderBorder: true
|
||||
contentInsideBorder: false
|
||||
|
||||
Behavior on border.color { ColorAnimation { duration: 100 } }
|
||||
|
||||
Image {
|
||||
anchors.fill: parent
|
||||
source: win.fileUrl(cell.wallpaperPath)
|
||||
fillMode: Image.PreserveAspectCrop
|
||||
asynchronous: true
|
||||
cache: true
|
||||
retainWhileLoading: true
|
||||
smooth: true
|
||||
mipmap: true
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
visible: cell.current
|
||||
anchors.top: parent.top
|
||||
anchors.right: parent.right
|
||||
anchors.margins: 16
|
||||
width: 36
|
||||
height: 36
|
||||
radius: 18
|
||||
color: Qt.rgba(Theme.green.r, Theme.green.g, Theme.green.b, 0.92)
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "✓"
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontPixelSize + 3
|
||||
color: Theme.base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if (cell.centered) win.applySelected()
|
||||
else win.selectIndex(win.selectedIndex + cell.offset)
|
||||
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: 48
|
||||
radius: 20
|
||||
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)
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 14
|
||||
anchors.rightMargin: 14
|
||||
spacing: 12
|
||||
|
||||
Text {
|
||||
Layout.fillWidth: true
|
||||
text: win.selectedWallpaper ? win.selectedWallpaper.split('/').pop() : "No wallpapers found"
|
||||
elide: Text.ElideMiddle
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontPixelSize
|
||||
color: Theme.text
|
||||
}
|
||||
|
||||
Text {
|
||||
text: (win.wallpapers.length > 0 ? (win.selectedIndex + 1) + " / " + win.wallpapers.length + " · " : "") + "←/→ · Enter apply · R random · Esc"
|
||||
font.family: Theme.fontFamily
|
||||
font.pixelSize: Theme.fontPixelSize - 2
|
||||
color: Theme.overlay2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: wallpaperApply
|
||||
running: false
|
||||
onExited: win.refresh()
|
||||
}
|
||||
|
||||
Process {
|
||||
id: wallpaperState
|
||||
command: [scriptsDir + "/wallpaper-switch.nu", "--current"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
win.currentWallpaper = text.trim() || "—"
|
||||
if (win.wallpapers.length > 0) win.selectPath(win.currentWallpaper)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: wallpaperList
|
||||
command: [scriptsDir + "/wallpaper-switch.nu", "--list"]
|
||||
running: false
|
||||
stdout: StdioCollector {
|
||||
onStreamFinished: {
|
||||
try {
|
||||
const oldSelection = win.selectedWallpaper
|
||||
win.wallpapers = JSON.parse(text.trim())
|
||||
win.selectedIndex = win.clampIndex(win.selectedIndex)
|
||||
if (oldSelection && win.wallpapers.indexOf(oldSelection) >= 0) win.selectPath(oldSelection)
|
||||
else win.selectPath(win.currentWallpaper)
|
||||
} catch (e) {
|
||||
win.wallpapers = []
|
||||
win.selectedIndex = 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
module Widgets
|
||||
Clock 1.0 Clock.qml
|
||||
CpuWidget 1.0 CpuWidget.qml
|
||||
MemoryWidget 1.0 MemoryWidget.qml
|
||||
NetTrafficWidget 1.0 NetTrafficWidget.qml
|
||||
StorageWidget 1.0 StorageWidget.qml
|
||||
TemperatureWidget 1.0 TemperatureWidget.qml
|
||||
AudioWidget 1.0 AudioWidget.qml
|
||||
TrayWidget 1.0 TrayWidget.qml
|
||||
NiriWorkspaceWidget 1.0 NiriWorkspaceWidget.qml
|
||||
HyprlandWorkspaceWidget 1.0 HyprlandWorkspaceWidget.qml
|
||||
ThemeSwitcherWindow 1.0 ThemeSwitcherWindow.qml
|
||||
WallpaperSwitcherWindow 1.0 WallpaperSwitcherWindow.qml
|
||||
PowerMenuWindow 1.0 PowerMenuWindow.qml
|
||||
ClipboardPickerWindow 1.0 ClipboardPickerWindow.qml
|
||||
AppLauncherWindow 1.0 AppLauncherWindow.qml
|
||||
Reference in new issue
Block a user