diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..e69de29 diff --git a/modules/wlogout/LogoutButton.qml b/modules/wlogout/LogoutButton.qml new file mode 100644 index 0000000..ad8e9a3 --- /dev/null +++ b/modules/wlogout/LogoutButton.qml @@ -0,0 +1,22 @@ +import QtQuick +import Quickshell.Io + +QtObject { + required property string command + required property string text + required property string icon + required property string icon_text + property var keybind: null + + id: button + + readonly property var process: Process { + command: ["sh", "-c", button.command] + } + + function exec() { + process.startDetached(); + console.log("Picked Logout Option, closing WLogout"); + wlogoutLoader.active = false; + } +} diff --git a/modules/wlogout/WLogout.qml b/modules/wlogout/WLogout.qml new file mode 100644 index 0000000..4f575fa --- /dev/null +++ b/modules/wlogout/WLogout.qml @@ -0,0 +1,133 @@ +import QtQuick +import QtQuick.Layouts +import Quickshell +import Quickshell.Io +import Quickshell.Wayland + +import "../../colors" + +Variants { + id: root + property color buttonColor: Colors.secondaryContainer + property color buttonHoverColor: Colors.primary + property color borderColor: Colors.secondaryContainer_fg + property color borderHoverColor: Colors.primaryContainer_fg + default property list buttons + + model: Quickshell.screens + PanelWindow { + id: w + + property var modelData + screen: modelData + + exclusionMode: ExclusionMode.Ignore + WlrLayershell.layer: WlrLayer.Overlay + WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive + + color: "transparent" + + contentItem { + focus: true + Keys.onPressed: event => { + if (event.key == Qt.Key_Escape) { + console.log("Pressed Escape, closing Wallpaper Picker") + wlogoutLoader.active = false + } else { + for (let i = 0; i < buttons.length; i++) { + let button = buttons[i]; + if (event.key == button.keybind) button.exec(); + } + } + } + } + + anchors { + top: true + left: true + bottom: true + right: true + } + + Rectangle { + anchors.fill: parent + Image { + anchors.fill: parent + source: "/home/honney/Pictures/Wallpapers/Static/blurred.jpg" + fillMode: Image.PreserveAspectCrop + } + + MouseArea { + anchors.fill: parent + onClicked: { + console.log("Pressed Escape, closing Wallpaper Picker") + wlogoutLoader.active = false + } + GridLayout { + anchors.centerIn: parent + + width: parent.width * 0.75 + height: parent.height * 0.75 + + columns: 3 + columnSpacing: 20 + rowSpacing: 20 + + Repeater { + model: buttons + delegate: Rectangle { + required property LogoutButton modelData; + + Layout.fillWidth: true + Layout.fillHeight: true + + color: ma.containsMouse ? buttonHoverColor : buttonColor + radius: 10 + border.color: ma.containsMouse ? borderColor : borderHoverColor + border.width: 2 + + MouseArea { + id: ma + anchors.fill: parent + hoverEnabled: true + onClicked: modelData.exec() + } + + Image { + id: icon + anchors.centerIn: parent + source: `icons/${modelData.icon}.svg` + width: parent.width * 0.3 + height: parent.width * 0.3 + + sourceSize.width: width + sourceSize.height: height + } + + // Text { + // id: icon + // anchors.centerIn: parent + + // text: modelData.icon_text ?? "?" + // font.pointSize: parent.height * 0.4 + // color: "white" + // } + + Text { + anchors { + top: icon.bottom + topMargin: 20 + horizontalCenter: parent.horizontalCenter + } + + text: modelData.text + font.pointSize: 20 + color: "white" + } + } + } + } + } + } + } +} diff --git a/modules/wlogout/Wlogout.qml b/modules/wlogout/Wlogout.qml new file mode 100644 index 0000000..2f6844b --- /dev/null +++ b/modules/wlogout/Wlogout.qml @@ -0,0 +1,54 @@ +import QtQuick +import Quickshell + +ShellRoot { + WLogout { + LogoutButton { + command: "loginctl lock-session" + keybind: Qt.Key_L + text: "Lock" + icon: "lock" + icon_text: "" + } + + LogoutButton { + command: "loginctl terminate-user $USER" + keybind: Qt.Key_E + text: "Logout" + icon: "logout" + icon_text: "󰗽" + } + + LogoutButton { + command: "systemctl suspend" + keybind: Qt.Key_U + text: "Suspend" + icon: "suspend" + icon_text: "" + } + + LogoutButton { + command: "systemctl hibernate" + keybind: Qt.Key_H + text: "Hibernate" + icon: "hibernate" + icon_text: "󰰂" + } + + LogoutButton { + command: "systemctl poweroff" + keybind: Qt.Key_K + text: "Shutdown" + icon: "shutdown" + icon_text: "⏻" + } + + LogoutButton { + command: "systemctl reboot" + keybind: Qt.Key_R + text: "Reboot" + icon: "reboot" + icon_text: "󰜉 " + } + } +} diff --git a/modules/wlogout/WlogoutLoader.qml b/modules/wlogout/WlogoutLoader.qml new file mode 100644 index 0000000..de04d1d --- /dev/null +++ b/modules/wlogout/WlogoutLoader.qml @@ -0,0 +1,29 @@ +import QtQuick +import Quickshell +import Quickshell.Hyprland +import Quickshell.Io + + +Item { // container, invisible + id: wlLoader + + Loader { + id: wlogoutLoader + active: false + sourceComponent: Wlogout { id: wLogout } + } + + GlobalShortcut { + name: "WLogout" + description: "Open WLogout" + + onPressed: { + console.log("Pressed Meta+Shift+W (Hyprland global shortcut)") + wlogoutLoader.active = !wlogoutLoader.active + } + } + + function closeWlogout() { + wlogoutLoader.active = false + } +} \ No newline at end of file diff --git a/shell.qml b/shell.qml index 682e35c..291f31c 100644 --- a/shell.qml +++ b/shell.qml @@ -5,6 +5,7 @@ import Quickshell.Hyprland import QtQuick //for Text import "./modules/bar" import "./modules/wp" +import "./modules/wlogout" import "./modules/jl" ShellRoot { @@ -18,5 +19,8 @@ ShellRoot { //Japanese Lerner JLearnerLoader {} + + //Wlogout + WlogoutLoader {} } \ No newline at end of file