diff --git a/config/Dimensions.qml b/config/Dimensions.qml index 6fa759f..81f0a7e 100644 --- a/config/Dimensions.qml +++ b/config/Dimensions.qml @@ -11,6 +11,7 @@ Singleton { property Bar bar: Bar {} property Mpris mpris: Mpris {} property Clock clock: Clock {} + property Caffeine caffeine: Caffeine {} property Workspace workspace: Workspace {} property Tray tray: Tray {} property TrayMenu trayMenu: TrayMenu {} @@ -45,6 +46,15 @@ Singleton { property int verticalPadding: 6 } + component Caffeine: QtObject { + id: clock + + property int iconSize: 14 + property int height: 30 + property int horizontalPadding: 8 + property int verticalPadding: 6 + } + component Workspace: QtObject { id: workspace diff --git a/constants/Icons.qml b/constants/Icons.qml index d7c0930..5c28d27 100644 --- a/constants/Icons.qml +++ b/constants/Icons.qml @@ -3,6 +3,7 @@ pragma Singleton import Quickshell Singleton { + property string coffee: "\u{E09a}" property string triangle: "\u{E192}" property string triangleDashed: "\u{E642}" } diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index cbc77d0..c4b766a 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -75,7 +75,9 @@ Scope { spacing: Dimensions.bar.spacing - Mpris {} + Mpris { + anchors.verticalCenter: parent.verticalCenter + } } Row { @@ -90,7 +92,13 @@ Scope { spacing: Dimensions.bar.spacing - Clock {} + Caffeine { + anchors.verticalCenter: parent.verticalCenter + } + + Clock { + anchors.verticalCenter: parent.verticalCenter + } } } } diff --git a/modules/bar/components/Caffeine.qml b/modules/bar/components/Caffeine.qml new file mode 100644 index 0000000..4e5f1cf --- /dev/null +++ b/modules/bar/components/Caffeine.qml @@ -0,0 +1,46 @@ +import QtQuick +import Quickshell.Io +import "../../../config/" +import "../../../constants/" +import "../../../styled/" + +Clickable { + id: clickable + + implicitWidth: text.width + implicitHeight: Dimensions.caffeine.height + + border.color: process.running ? Theme.palette.secondary : 'transparent' + border.width: 2 + + onClicked: { + if (process.running) { + process.signal(888); + process.running = false; + } else { + process.running = true; + } + } + + StyledText { + id: text + + font.family: Theme.lucide.font.family + font.pixelSize: Dimensions.workspace.iconSize + font.bold: true + text: Icons.coffee + + color: clickable.containsMouse ? Theme.palette.base300 : Theme.palette.basecontent + + anchors.verticalCenter: parent.verticalCenter + topPadding: Dimensions.mpris.verticalPadding + bottomPadding: Dimensions.mpris.verticalPadding + leftPadding: Dimensions.mpris.horizontalPadding + rightPadding: Dimensions.mpris.horizontalPadding + } + + Process { + id: process + command: ["sh", "-c", "systemd-inhibit --what=idle --who=Caffeine --why=Caffeine --mode=block sleep inf"] + } +} diff --git a/styled/Clickable.qml b/styled/Clickable.qml index 7d9158e..c012668 100644 --- a/styled/Clickable.qml +++ b/styled/Clickable.qml @@ -6,8 +6,11 @@ MouseArea { hoverEnabled: true cursorShape: Qt.PointingHandCursor + property alias color: rectangle.color + property alias border: rectangle.border Rectangle { + id: rectangle anchors.fill: parent radius: Dimensions.radius