added quickshell config
This commit is contained in:
114
dotfiles/.config/quickshell/modules/bar/PowerButton.qml
Normal file
114
dotfiles/.config/quickshell/modules/bar/PowerButton.qml
Normal file
@@ -0,0 +1,114 @@
|
||||
import QtQuick
|
||||
import QtQuick.Layouts
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
import "../../config"
|
||||
|
||||
Item {
|
||||
id: root
|
||||
implicitWidth: label.implicitWidth + 4
|
||||
implicitHeight: Appearance.barHeight
|
||||
|
||||
Text {
|
||||
id: label
|
||||
anchors.centerIn: parent
|
||||
font.family: Appearance.iconFontFamily
|
||||
font.variableAxes: Appearance.iconFontAxes
|
||||
font.pixelSize: 16
|
||||
color: Colors.foreground
|
||||
text: "power_settings_new"
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: menu.visible = !menu.visible
|
||||
}
|
||||
|
||||
Process { id: proc }
|
||||
|
||||
PopupWindow {
|
||||
id: menu
|
||||
visible: false
|
||||
color: "transparent"
|
||||
implicitWidth: 170
|
||||
implicitHeight: list.model.length * 32 + (list.model.length - 1) * 2 + 16
|
||||
|
||||
anchor {
|
||||
item: root
|
||||
edges: Edges.Bottom | Edges.Right
|
||||
gravity: Edges.Bottom | Edges.Left
|
||||
margins.top: 4
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
radius: Appearance.radius
|
||||
color: Colors.surface
|
||||
border.color: Colors.muted
|
||||
border.width: 1
|
||||
|
||||
Column {
|
||||
anchors.fill: parent
|
||||
anchors.margins: 8
|
||||
spacing: 2
|
||||
|
||||
Repeater {
|
||||
id: list
|
||||
model: [
|
||||
// "iconSize" is optional — omit it to use the 15px default below.
|
||||
// Material Symbols glyphs aren't all the same visual weight at a
|
||||
// given size (a padlock silhouette reads bulkier than a thin arrow),
|
||||
// so nudge individual icons here to balance them by eye.
|
||||
{ label: "Lock", icon: "lock", iconSize: 13, cmd: ["hyprlock"] },
|
||||
{ label: "Log out", icon: "logout", cmd: ["hyprctl", "dispatch", "exit"] },
|
||||
{ label: "Reboot", icon: "restart_alt", cmd: ["systemctl", "reboot"] },
|
||||
{ label: "Shut down", icon: "power_settings_new", cmd: ["systemctl", "poweroff"] }
|
||||
]
|
||||
|
||||
delegate: Rectangle {
|
||||
id: entry
|
||||
required property var modelData
|
||||
width: parent ? parent.width : 0
|
||||
height: 32
|
||||
radius: Appearance.radiusSmall
|
||||
color: entryMouse.containsMouse ? Colors.primary : "transparent"
|
||||
|
||||
RowLayout {
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: 8
|
||||
spacing: 8
|
||||
Text {
|
||||
Layout.preferredWidth: 20
|
||||
horizontalAlignment: Text.AlignHCenter
|
||||
text: entry.modelData.icon
|
||||
font.family: Appearance.iconFontFamily
|
||||
font.variableAxes: Appearance.iconFontAxes
|
||||
font.pixelSize: entry.modelData.iconSize || 15
|
||||
color: entryMouse.containsMouse ? Colors.primaryText : Colors.foreground
|
||||
}
|
||||
Text {
|
||||
text: entry.modelData.label
|
||||
font.family: Appearance.fontFamily
|
||||
font.pixelSize: Appearance.fontSize
|
||||
color: entryMouse.containsMouse ? Colors.primaryText : Colors.foreground
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: entryMouse
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
proc.command = entry.modelData.cmd
|
||||
proc.running = true
|
||||
menu.visible = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user