See quickshell/48156a55b30c68cade2d28588e8f04f9080e54d1.
This is a mostly faithful clone of wlogout.
You can run the example with quickshell -p shell.qml.
quickshell -p shell.qml