Skip to content

Commit bc279df

Browse files
committed
wlogout: add example
1 parent 56dc798 commit bc279df

File tree

11 files changed

+182
-0
lines changed

11 files changed

+182
-0
lines changed

wlogout/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Wlogout clone
2+
3+
This is a mostly faithful clone of [wlogout](https://github.com/ArtsyMacaw/wlogout).
4+
5+
You can run the example with `quickshell -c shell.qml`.
6+
7+
![](./image.png)

wlogout/WLogout.qml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import QtQuick
2+
import QtQuick.Layouts
3+
import Quickshell
4+
import Quickshell.Io
5+
import Quickshell.Wayland
6+
7+
Variants {
8+
id: root
9+
property color backgroundColor: "#e60c0c0c"
10+
property color buttonColor: "#1e1e1e"
11+
property color buttonHoverColor: "#3700b3"
12+
default property list<WlButton> buttons
13+
14+
variants: Quickshell.screens.map(screen => ({ screen }))
15+
PanelWindow {
16+
id: w
17+
18+
exclusionMode: ExclusionMode.Ignore
19+
WlrLayershell.layer: Layer.Overlay
20+
WlrLayershell.keyboardFocus: KeyboardFocus.Exclusive
21+
22+
color: "transparent"
23+
24+
contentItem {
25+
focus: true
26+
Keys.onPressed: event => {
27+
if (event.key == Qt.Key_Escape) Qt.quit();
28+
else {
29+
for (let i = 0; i < buttons.length; i++) {
30+
let button = buttons[i];
31+
if (event.key == button.keybind) button.exec();
32+
}
33+
}
34+
}
35+
}
36+
37+
anchors {
38+
top: true
39+
left: true
40+
bottom: true
41+
right: true
42+
}
43+
44+
Rectangle {
45+
color: backgroundColor;
46+
anchors.fill: parent
47+
48+
MouseArea {
49+
anchors.fill: parent
50+
onClicked: Qt.quit()
51+
52+
GridLayout {
53+
anchors.centerIn: parent
54+
55+
width: parent.width * 0.75
56+
height: parent.height * 0.75
57+
58+
columns: 3
59+
columnSpacing: 0
60+
rowSpacing: 0
61+
62+
Repeater {
63+
model: buttons
64+
delegate: Rectangle {
65+
required property WlButton modelData;
66+
67+
Layout.fillWidth: true
68+
Layout.fillHeight: true
69+
70+
color: ma.containsMouse ? buttonHoverColor : buttonColor
71+
border.color: "black"
72+
border.width: ma.containsMouse ? 0 : 1
73+
74+
MouseArea {
75+
id: ma
76+
anchors.fill: parent
77+
hoverEnabled: true
78+
onClicked: modelData.exec()
79+
}
80+
81+
Image {
82+
id: icon
83+
anchors.centerIn: parent
84+
source: `icons/${modelData.icon}.png`
85+
width: parent.width * 0.25
86+
height: parent.width * 0.25
87+
}
88+
89+
Text {
90+
anchors {
91+
top: icon.bottom
92+
topMargin: 20
93+
horizontalCenter: parent.horizontalCenter
94+
}
95+
96+
text: modelData.text
97+
font.pointSize: 20
98+
color: "white"
99+
}
100+
}
101+
}
102+
}
103+
}
104+
}
105+
}
106+
}

wlogout/WlButton.qml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import QtQuick
2+
import Quickshell.Io
3+
4+
QtObject {
5+
required property string command
6+
required property string text
7+
required property string icon
8+
property var keybind: null
9+
10+
id: button
11+
12+
readonly property var process: Process {
13+
command: ["sh", "-c", button.command]
14+
manageLifetime: false
15+
}
16+
17+
function exec() {
18+
process.running = true;
19+
Qt.quit();
20+
}
21+
}

wlogout/icons/hibernate.png

17.5 KB
Loading

wlogout/icons/lock.png

7.92 KB
Loading

wlogout/icons/logout.png

6.18 KB
Loading

wlogout/icons/reboot.png

16.1 KB
Loading

wlogout/icons/shutdown.png

15.3 KB
Loading

wlogout/icons/suspend.png

16.9 KB
Loading

wlogout/image.png

110 KB
Loading

0 commit comments

Comments
 (0)