Notifications n shi

This commit is contained in:
2026-02-26 16:18:06 -08:00
parent a3ffbc80c5
commit 3ed2df2cd5
19 changed files with 331 additions and 17 deletions

View File

@@ -50,7 +50,7 @@ Item {
anchors.verticalCenter: parent.verticalCenter
x: 10
color: "white"
text: `${Math.round(UPower.displayDevice.percentage * 100)}% · ${Math.round(UPower.displayDevice.changeRate)}W`
text: `${Math.round(UPower.displayDevice.percentage * 100)}% · ${UPower.displayDevice.changeRate.toPrecision(2)}W`
}
}
HoverHandler {id: hover}

83
Widgets/Notification.qml Normal file
View File

@@ -0,0 +1,83 @@
import Quickshell
import Quickshell.Widgets
import Quickshell.Services.Notifications
import QtQuick
import QtQuick.Controls
import QtQuick.Effects
Rectangle {
id: notifRect
required property var modelData
property bool exiting: false
width: parent?.width ?? 0
height: notifContent.childrenRect.height + 20
radius: 8
color: "#181818"
Rectangle {
antialiasing: true
color: "transparent"
anchors {
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 12
}
radius: 8
width: 40
height: 40
Image {
id: notifIcon
anchors.fill: parent
source: modelData?.image ?? source
}
}
Column {
id: notifContent
anchors {
left: parent.left
right: parent.right
top: parent.top
topMargin: 10
leftMargin: 16 + (notifIcon.source == "" ? 0 : 44)
rightMargin: 16
}
spacing: 4
Text {
anchors {
left: parent.left
right: parent.right
}
color: "white"
font.family: "Comfortaa"
font.pixelSize: 16
text: modelData?.summary ?? text
elide: Text.ElideRight
wrapMode: Text.Wrap
maximumLineCount: 2
}
Text {
anchors {
left: parent.left
right: parent.right
}
color: "white"
font.family: "Comfortaa"
font.pixelSize: 12
text: modelData?.body ?? text
elide: Text.ElideRight
wrapMode: Text.Wrap
maximumLineCount: 4
}
}
Timer {
running: modelData?.expireTimeout > 0
interval: (modelData?.expireTimeout > 0) ? modelData?.expireTimeout : 0
onTriggered: modelData.tracked = false
}
TapHandler {
acceptedButtons: Qt.MiddleButton
onTapped: modelData.tracked = false
}
}

48
Widgets/Time.qml Normal file
View File

@@ -0,0 +1,48 @@
import QtQuick
import Quickshell
import Quickshell.Widgets
import Quickshell.Services.Mpris
Item {
id: root
property var player: Mpris.players.values[0]
anchors {
top: parent.top
bottom: parent.bottom
}
width: children[1].width + 24
Rectangle {
anchors.fill: parent
anchors.margins: 4
radius: 8
bottomRightRadius: 12
color: hover.hovered ? "#11ffffff" : "#00ffffff"
Behavior on color {ColorAnimation {duration: 100}}
}
Row {
spacing: 12
anchors.verticalCenter: parent.verticalCenter
x: 12
ClippingRectangle {
visible: !!root.player
anchors.verticalCenter: parent.verticalCenter
width: 24
height: width
radius: 6
Image {
anchors.fill: parent
source: root.player?.trackArtUrl ?? source
}
opacity: root.player?.isPlaying ? 1 : 0.5
Behavior on opacity {NumberAnimation {duration: 150}}
}
Text {
anchors.verticalCenter: parent.verticalCenter
property var clock: SystemClock {}
color: "white"
text: Qt.formatDateTime(clock.date, "ddd MMM dd · hh:mm")
}
}
HoverHandler {id: hover}
TapHandler {onTapped: background.index = 3}
}

View File

@@ -18,7 +18,9 @@ Item {
width: 24
property var workspace: Hyprland.workspaces.values.find(ws => ws.id === modelData+1)
property var icon: {
const appId = workspace?.toplevels.values[0]?.wayland?.appId
const appId = workspace ? Array.from(workspace.toplevels.values).sort(
(a, b) => b.lastIpcObject.focusHistoryId - a.lastIpcObject.focusHistoryId
)[0]?.wayland?.appId : undefined
return DesktopEntries.applications.values.find(
app => app.startupClass === appId || app.id === appId
)?.icon;