Add Quickshell power button with reboot/shutdown/logout dropdown

Replaces the removed Waybar custom/power module with a Quickshell-rendered
button anchored to the same spot in the bar, opening a proper anchored
dropdown (Neustart/Herunterfahren/Abmelden, localized via $LANG) instead of
a screen-centered rofi menu. Waybar keeps a blank spacer module reserving
the space. Styled to match the rice's blue accent and the bar's pill look.
This commit is contained in:
nico
2026-07-27 19:15:49 +02:00
parent 3036b996f9
commit 3b1eb02159
6 changed files with 189 additions and 43 deletions

View File

@@ -58,6 +58,7 @@ $mainMod = SUPER
# ----------------------------------------------------------
exec-once = waybar
exec-once = quickshell -c default
exec-once = dunst
exec-once = nm-applet --indicator
exec-once = swaybg -i ~/Pictures/wallpapers/wallpaper.png -m fill

View File

@@ -0,0 +1,40 @@
import QtQuick
import QtQuick.Layouts
Rectangle {
id: root
required property string label
required property string icon
signal triggered()
Layout.fillWidth: true
implicitHeight: 32
radius: 8
color: ma.containsMouse ? "#1793d1" : "transparent"
Row {
anchors.centerIn: parent
spacing: 8
Text {
text: root.icon
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 14
color: ma.containsMouse ? "#0f111a" : "#7aa2f7"
}
Text {
text: root.label
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 13
color: ma.containsMouse ? "#0f111a" : "#c0caf5"
}
}
MouseArea {
id: ma
anchors.fill: parent
hoverEnabled: true
onClicked: root.triggered()
}
}

View File

@@ -0,0 +1,130 @@
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Io
import Quickshell.Wayland
import Quickshell.Hyprland
Variants {
id: root
model: Quickshell.screens
readonly property bool isGerman: Qt.locale().name.startsWith("de")
readonly property string logoutLabel: isGerman ? "Abmelden" : "Logout"
readonly property string restartLabel: isGerman ? "Neustart" : "Restart"
readonly property string shutdownLabel: isGerman ? "Herunterfahren" : "Shutdown"
PanelWindow {
id: panel
required property var modelData
screen: modelData
anchors { top: true; right: true }
implicitWidth: 40
implicitHeight: 34
margins.right: 8
exclusionMode: ExclusionMode.Ignore
color: "transparent"
WlrLayershell.namespace: "power-button"
property bool menuOpen: false
Process { id: logoutProc; command: ["hyprctl", "dispatch", "exit"] }
Process { id: rebootProc; command: ["systemctl", "reboot"] }
Process { id: shutdownProc; command: ["systemctl", "poweroff"] }
// Matches window#waybar's own backdrop tint so the button blends into the bar
// instead of floating over the wallpaper on its own transparent surface.
Rectangle {
anchors.fill: parent
color: Qt.rgba(0.071, 0.075, 0.106, 0.18)
}
Rectangle {
anchors.fill: parent
anchors.margins: 4
radius: 10
color: btnArea.containsMouse ? "#1793d1" : Qt.rgba(0.102, 0.106, 0.149, 0.85)
Text {
anchors.centerIn: parent
text: ""
font.family: "JetBrainsMono Nerd Font"
font.pixelSize: 15
color: btnArea.containsMouse ? "#0f111a" : "#1793d1"
}
MouseArea {
id: btnArea
anchors.fill: parent
hoverEnabled: true
onClicked: panel.menuOpen = !panel.menuOpen
}
}
LazyLoader {
active: panel.menuOpen
PanelWindow {
id: menu
screen: panel.modelData
anchors { top: true; right: true }
margins { top: 34; right: 8 }
implicitWidth: 170
implicitHeight: col.implicitHeight + 16
color: "transparent"
WlrLayershell.namespace: "power-menu"
HyprlandFocusGrab {
windows: [ menu ]
active: true
onCleared: panel.menuOpen = false
}
Rectangle {
anchors.fill: parent
radius: 10
color: "#e61a1b26"
border.width: 1
border.color: Qt.rgba(0.478, 0.635, 0.969, 0.35)
ColumnLayout {
id: col
anchors.fill: parent
anchors.margins: 8
spacing: 4
MenuEntry {
label: root.logoutLabel
icon: ""
onTriggered: {
panel.menuOpen = false
logoutProc.startDetached()
}
}
MenuEntry {
label: root.restartLabel
icon: ""
onTriggered: {
panel.menuOpen = false
rebootProc.startDetached()
}
}
MenuEntry {
label: root.shutdownLabel
icon: ""
onTriggered: {
panel.menuOpen = false
shutdownProc.startDetached()
}
}
}
}
}
}
}
}

View File

@@ -1,44 +1,6 @@
import Quickshell
import QtQuick
import Quickshell.Wayland
import Quickshell
PanelWindow {
color: "transparent"
anchors {
top: true
left: true
right: true
}
implicitHeight: 40
Rectangle {
anchors.fill: parent
// KORREKTUR: Qt.rgba nutzt Werte von 0.0 bis 1.0 statt 0-255
// 30/255 ≈ 0.11, 46/255 ≈ 0.18, Transparenz 0.85
color: Qt.rgba(0.11, 0.11, 0.18, 0.25)
// KORREKTUR: Auch hier das ältere Format für den Rahmen nutzen
border.color: Qt.rgba(1.0, 1.0, 1.0, 0.1)
border.width: 1
Text {
id: clockText
anchors.centerIn: parent
color: "#cdd6f4" // Hex-Codes funktionieren weiterhin einwandfrei
font.pixelSize: 15
font.bold: true
text: Qt.formatDateTime(new Date(), "hh:mm:ss")
}
Timer {
interval: 1000
running: true
repeat: true
onTriggered: {
clockText.text = Qt.formatDateTime(new Date(), "hh:mm:ss")
}
}
}
ShellRoot {
PowerMenu {}
}

View File

@@ -19,7 +19,8 @@
"custom/gpu",
"network",
"pulseaudio",
"clock"
"clock",
"custom/power-spacer"
],
"custom/arch": {
"format": "",
@@ -104,5 +105,10 @@
"interval": 3,
"return-type": "text",
"tooltip": true
},
"custom/power-spacer": {
"format": " ",
"tooltip": false,
"interval": "once"
}
}

View File

@@ -82,5 +82,12 @@ window#waybar {
#clock {
color: @bright_white;
margin-right: 8px;
}
/* Reserved blank space where the Quickshell power button/menu renders on top. */
#custom-power-spacer {
min-width: 48px;
padding: 0;
margin: 0;
background: transparent;
}