add idle inhib (caffeine)
This commit is contained in:
parent
c754576ca9
commit
1e087a4f2d
5 changed files with 70 additions and 2 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ pragma Singleton
|
|||
import Quickshell
|
||||
|
||||
Singleton {
|
||||
property string coffee: "\u{E09a}"
|
||||
property string triangle: "\u{E192}"
|
||||
property string triangleDashed: "\u{E642}"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
46
modules/bar/components/Caffeine.qml
Normal file
46
modules/bar/components/Caffeine.qml
Normal file
|
|
@ -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"]
|
||||
}
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue