feat: add power menu & clipboard

This commit is contained in:
johannes committed 2026-09-17 19:56:15 +02:00
1 parent 6d583b4616
commit 9ca3b15764
6 files changed
+536 -88

No files matched your search

-53
View File
@@ -1,53 +0,0 @@
-- Generated by HyprMod
-- Settings
hl.config({
ecosystem = {
enforce_permissions = true,
no_donation_nag = true,
no_update_news = true,
},
misc = {
animate_mouse_windowdragging = true,
disable_splash_rendering = true,
vrr = 1,
},
xwayland = {
force_zero_scaling = true,
},
})
-- Monitors
hl.monitor({
output = "desc:Samsung Electric Company Odyssey G85SB H1AK500000",
disabled = false,
mode = "3440x1440@174.96Hz",
position = "1920x180",
scale = 1,
bitdepth = 10,
vrr = 1,
cm = "hdr",
sdrbrightness = 0.5,
sdr_min_luminance = 0,
sdr_max_luminance = 400,
min_luminance = 0,
max_luminance = 400,
max_avg_luminance = 248,
})
hl.monitor({
output = "desc:Iiyama North America PL2730H 1153680901995",
disabled = false,
mode = "1920x1080@74.97Hz",
position = "0x360",
scale = 1,
cm = "srgb",
})
hl.monitor({
output = "HDMI-A-2",
disabled = true,
})
-- Autostart
hl.on("hyprland.start", function()
hl.exec_cmd("hyprpm reload -n")
end)
+4 -3
View File
@@ -3,7 +3,7 @@
require("hyprland-gui") require("hyprland-gui")
local hypr_dir = (os.getenv("XDG_CONFIG_HOME") or (os.getenv("HOME") .. "/.config")) .. "/hypr"
---------------- ----------------
--- MONITORS --- --- MONITORS ---
@@ -27,7 +27,7 @@ local fileManager = "nemo"
local menu = "quickshell ipc call commandPalette toggle" local menu = "quickshell ipc call commandPalette toggle"
local clipboard = "qs ipc call clipboardPicker open" local clipboard = "qs ipc call clipboardPicker open"
local lock = "hyprlock" local lock = "hyprlock"
local powermenu = "qs ipc call powerMenu open"
----------------- -----------------
--- AUTOSTART --- --- AUTOSTART ---
@@ -176,10 +176,11 @@ local mainMod = "SUPER"
-- Apps -- Apps
hl.bind(mainMod .. " + Return", hl.dsp.exec_cmd(terminal)) hl.bind(mainMod .. " + Return", hl.dsp.exec_cmd(terminal))
hl.bind(mainMod .. " + Q", hl.dsp.window.close()) hl.bind(mainMod .. " + Q", hl.dsp.window.close())
hl.bind(mainMod .. " + M", hl.dsp.exec_cmd(powermenu)) hl.bind(mainMod .. " + M", hl.dsp.exec_cmd("quickshell ipc call logoutMenu toggle"))
hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(fileManager)) hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(fileManager))
hl.bind(mainMod .. " + H", hl.dsp.window.float({ action = "toggle" })) hl.bind(mainMod .. " + H", hl.dsp.window.float({ action = "toggle" }))
hl.bind(mainMod .. " + Space", hl.dsp.exec_cmd(menu)) hl.bind(mainMod .. " + Space", hl.dsp.exec_cmd(menu))
hl.bind(mainMod .. " + V", hl.dsp.exec_cmd("quickshell ipc call clipboardManager toggle"))
hl.bind(mainMod .. " + P", hl.dsp.window.pseudo()) hl.bind(mainMod .. " + P", hl.dsp.window.pseudo())
hl.bind(mainMod .. " + F", hl.dsp.window.fullscreen({ action = "toggle" })) hl.bind(mainMod .. " + F", hl.dsp.window.fullscreen({ action = "toggle" }))
hl.bind(mainMod .. " + L", hl.dsp.exec_cmd(lock)) hl.bind(mainMod .. " + L", hl.dsp.exec_cmd(lock))
@@ -0,0 +1,241 @@
import QtQuick
import Quickshell
import Quickshell.Wayland
import Quickshell.Io
import "../Shared"
PanelWindow {
id: clipboardWindow
property QtObject rootState
visible: rootState.clipboardManagerOpen
anchors {
top: true
bottom: true
left: true
right: true
}
exclusiveZone: 0
color: "transparent"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.namespace: "quickshell-clipboard"
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
MouseArea {
anchors.fill: parent
onClicked: rootState.clipboardManagerOpen = false
}
Rectangle {
id: container
width: 800
height: Math.min(600, (clipList.count > 0 ? clipList.contentHeight : 0) + (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0) + Theme.geometry.padding * 2)
anchors.centerIn: parent
radius: Theme.geometry.radius
color: Theme.colors.background
border.color: Theme.colors.border
border.width: 1
Behavior on scale { SpringAnimation { spring: 3; damping: 0.2 } }
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast; easing.type: Easing.OutCubic } }
opacity: rootState.clipboardManagerOpen ? 1 : 0
MouseArea {
anchors.fill: parent
}
Column {
anchors.fill: parent
anchors.margins: Theme.geometry.padding
spacing: searchInput.text.length > 0 ? Theme.geometry.spacing : 0
Rectangle {
width: parent.width
height: searchInput.text.length > 0 ? 50 : 0
opacity: searchInput.text.length > 0 ? 1 : 0
clip: true
color: Theme.colors.surface
radius: Theme.geometry.radius
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
TextInput {
id: searchInput
anchors.fill: parent
anchors.margins: Theme.geometry.padding
verticalAlignment: TextInput.AlignVCenter
font.family: Theme.font.family
font.pixelSize: 18
color: Theme.colors.text
clip: true
Text {
text: "Search clipboard..."
color: Theme.colors.textMuted
font.family: Theme.font.family
font.pixelSize: 18
anchors.verticalCenter: parent.verticalCenter
visible: searchInput.text.length === 0
}
onVisibleChanged: {
if (visible) forceActiveFocus();
}
onTextChanged: {
loadProcess.restart();
}
Keys.onEscapePressed: (event) => {
rootState.clipboardManagerOpen = false;
event.accepted = true;
}
Keys.onUpPressed: (event) => {
if (clipList.currentIndex > 0) {
clipList.currentIndex--;
clipList.positionViewAtIndex(clipList.currentIndex, ListView.Contain);
}
event.accepted = true;
}
Keys.onDownPressed: (event) => {
if (clipList.currentIndex < clipList.count - 1) {
clipList.currentIndex++;
clipList.positionViewAtIndex(clipList.currentIndex, ListView.Contain);
}
event.accepted = true;
}
Keys.onReturnPressed: (event) => {
if (clipList.currentIndex >= 0 && clipList.currentIndex < clipModel.count) {
let item = clipModel.get(clipList.currentIndex);
copyToClipboard(item.id);
}
event.accepted = true;
}
Keys.onPressed: (event) => {
if (event.key === Qt.Key_Delete || (event.key === Qt.Key_Backspace && searchInput.text.length === 0)) {
if (clipList.currentIndex >= 0 && clipList.currentIndex < clipModel.count) {
let item = clipModel.get(clipList.currentIndex);
deleteFromClipboard(item.id, item.rawLine, clipList.currentIndex);
}
event.accepted = true;
}
}
}
}
ListView {
id: clipList
width: parent.width
height: parent.height - (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0)
clip: true
spacing: Theme.geometry.spacing
model: ListModel { id: clipModel }
delegate: Rectangle {
width: clipList.width
height: 36
color: ListView.isCurrentItem ? Theme.colors.surfaceHover : "transparent"
radius: Theme.geometry.radius
Item {
anchors.fill: parent
anchors.leftMargin: Theme.geometry.padding
anchors.rightMargin: Theme.geometry.padding
Text {
text: model.content
color: Theme.colors.text
font.family: Theme.font.family
font.pixelSize: 14
anchors.fill: parent
verticalAlignment: Text.AlignVCenter
elide: Text.ElideRight
}
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
onEntered: clipList.currentIndex = index
onClicked: {
clipList.currentIndex = index;
copyToClipboard(model.id);
}
}
}
}
}
}
Process {
id: loadProcess
command: [
"bash", "-c",
"cliphist list | ( [ -z \"$1\" ] && cat || rg -i \"$1\" ) | head -n 50",
"_", searchInput.text
]
running: false
function restart() { running = false; running = true; }
stdout: StdioCollector {
onStreamFinished: {
let lines = this.text.split('\n').filter(l => l.trim() !== "");
clipModel.clear();
for (let i = 0; i < lines.length; i++) {
let firstTab = lines[i].indexOf('\t');
if (firstTab !== -1) {
let id = lines[i].substring(0, firstTab);
// Clean up newlines for multiline strings natively copied
let content = lines[i].substring(firstTab + 1).replace(/\n/g, ' ').replace(/\\n/g, ' ');
clipModel.append({ "id": id, "content": content, "rawLine": lines[i] });
}
}
clipList.currentIndex = 0;
}
}
}
Process {
id: actionProcess
running: false
function execute(cmdArray) {
command = cmdArray;
running = false;
running = true;
}
}
function copyToClipboard(id) {
actionProcess.execute(["bash", "-c", "cliphist decode '" + id + "' | wl-copy"]);
rootState.clipboardManagerOpen = false;
}
function deleteFromClipboard(id, rawLine, index) {
actionProcess.execute(["bash", "-c", "printf '%s\\n' \"$1\" | cliphist delete", "_", rawLine]);
clipModel.remove(index);
if (clipList.currentIndex >= clipModel.count) {
clipList.currentIndex = Math.max(0, clipModel.count - 1);
}
}
onVisibleChanged: {
if (visible) {
container.scale = 1.0;
searchInput.text = "";
clipModel.clear();
loadProcess.restart();
} else {
container.scale = 0.95;
}
}
}
@@ -8,9 +8,28 @@ import "../Shared"
PanelWindow { PanelWindow {
id: paletteWindow id: paletteWindow
property QtObject rootState property QtObject rootState
property bool enterQueued: false
property var usageCounts: ({}) property var usageCounts: ({})
property string lastUsedApp: "" property string lastUsedApp: ""
function launchApp(index) {
if (index < 0 || index >= appModel.count) return;
let item = appModel.get(index);
let desktopName = item.desktopName;
let appPath = item.appPath;
logHistoryProcess.command = ["bash", "-c", "echo '" + desktopName + "' >> ~/.cache/quickshell-app-history.txt"];
logHistoryProcess.restart();
launchProcess.command = [
"bash", "-c",
"EXEC=$(awk -F= '/^Exec=/ {print $2; exit}' \"$1\" | sed 's/ %[a-zA-Z]//g'); if command -v uwsm &>/dev/null; then eval \"uwsm app -- $EXEC\"; elif command -v niri &>/dev/null; then eval \"niri msg action spawn -- $EXEC\"; else nohup eval \"$EXEC\" </dev/null >/dev/null 2>&1 & fi",
"_", appPath
];
launchProcess.restart();
rootState.commandPaletteOpen = false;
}
visible: rootState.commandPaletteOpen visible: rootState.commandPaletteOpen
anchors { anchors {
@@ -39,7 +58,7 @@ PanelWindow {
id: container id: container
// Sized appropriately for a 2560x1440 screen // Sized appropriately for a 2560x1440 screen
width: 800 width: 800
height: Math.min(600, (appList.count > 0 ? appList.contentHeight : 0) + 50 + Theme.geometry.padding * 2 + Theme.geometry.spacing) height: Math.min(600, (appList.count > 0 ? appList.contentHeight : 0) + (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0) + Theme.geometry.padding * 2)
anchors.centerIn: parent anchors.centerIn: parent
radius: Theme.geometry.radius radius: Theme.geometry.radius
color: Theme.colors.background color: Theme.colors.background
@@ -60,14 +79,19 @@ PanelWindow {
Column { Column {
anchors.fill: parent anchors.fill: parent
anchors.margins: Theme.geometry.padding anchors.margins: Theme.geometry.padding
spacing: Theme.geometry.spacing spacing: searchInput.text.length > 0 ? Theme.geometry.spacing : 0
Rectangle { Rectangle {
width: parent.width width: parent.width
height: 50 height: searchInput.text.length > 0 ? 50 : 0
opacity: searchInput.text.length > 0 ? 1 : 0
clip: true
color: Theme.colors.surface color: Theme.colors.surface
radius: Theme.geometry.radius radius: Theme.geometry.radius
Behavior on height { NumberAnimation { duration: Theme.animation.durationFast } }
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationFast } }
TextInput { TextInput {
id: searchInput id: searchInput
anchors.fill: parent anchors.fill: parent
@@ -117,21 +141,10 @@ PanelWindow {
} }
Keys.onReturnPressed: (event) => { Keys.onReturnPressed: (event) => {
if (appList.currentIndex >= 0 && appList.currentIndex < appModel.count) { if (appList.count > 0 && appList.currentIndex >= 0 && appList.currentIndex < appModel.count) {
let item = appModel.get(appList.currentIndex); paletteWindow.launchApp(appList.currentIndex);
let desktopName = item.desktopName; } else {
let appPath = item.appPath; paletteWindow.enterQueued = true;
logHistoryProcess.command = ["bash", "-c", "echo '" + desktopName + "' >> ~/.cache/quickshell-app-history.txt"];
logHistoryProcess.restart();
launchProcess.command = [
"bash", "-c",
"EXEC=$(awk -F= '/^Exec=/ {print $2; exit}' \"$1\" | sed 's/ %[a-zA-Z]//g'); if command -v uwsm &>/dev/null; then eval \"uwsm app -- $EXEC\"; elif command -v niri &>/dev/null; then eval \"niri msg action spawn -- $EXEC\"; else nohup eval \"$EXEC\" </dev/null >/dev/null 2>&1 & fi",
"_", appPath
];
launchProcess.restart();
rootState.commandPaletteOpen = false;
} }
event.accepted = true; event.accepted = true;
} }
@@ -223,6 +236,11 @@ PanelWindow {
} }
appList.currentIndex = 0; appList.currentIndex = 0;
if (paletteWindow.enterQueued && appModel.count > 0) {
paletteWindow.enterQueued = false;
paletteWindow.launchApp(0);
}
} }
} }
} }
@@ -230,7 +248,7 @@ PanelWindow {
ListView { ListView {
id: appList id: appList
width: parent.width width: parent.width
height: parent.height - 50 - Theme.geometry.spacing height: parent.height - (searchInput.text.length > 0 ? 50 + Theme.geometry.spacing : 0)
clip: true clip: true
spacing: Theme.geometry.spacing spacing: Theme.geometry.spacing
@@ -289,19 +307,7 @@ PanelWindow {
onEntered: appList.currentIndex = index onEntered: appList.currentIndex = index
onClicked: { onClicked: {
appList.currentIndex = index; appList.currentIndex = index;
let desktopName = model.desktopName; paletteWindow.launchApp(index);
let appPath = model.appPath;
logHistoryProcess.command = ["bash", "-c", "echo '" + desktopName + "' >> ~/.cache/quickshell-app-history.txt"];
logHistoryProcess.restart();
launchProcess.command = [
"bash", "-c",
"EXEC=$(awk -F= '/^Exec=/ {print $2; exit}' \"$1\" | sed 's/ %[a-zA-Z]//g'); if command -v uwsm &>/dev/null; then eval \"uwsm app -- $EXEC\"; elif command -v niri &>/dev/null; then eval \"niri msg action spawn -- $EXEC\"; else nohup eval \"$EXEC\" </dev/null >/dev/null 2>&1 & fi",
"_", appPath
];
launchProcess.restart();
rootState.commandPaletteOpen = false;
} }
} }
} }
@@ -331,6 +337,7 @@ PanelWindow {
if (visible) { if (visible) {
container.scale = 1.0; container.scale = 1.0;
searchInput.text = ""; searchInput.text = "";
paletteWindow.enterQueued = false;
appModel.clear(); // Clear so it re-populates clean appModel.clear(); // Clear so it re-populates clean
// Read history first, then search // Read history first, then search
@@ -0,0 +1,212 @@
import QtQuick
import Quickshell
import Quickshell.Wayland
import Quickshell.Io
import "../Shared"
PanelWindow {
id: logoutWindow
property QtObject rootState
property int currentIndex: 2 // Default to Logout in the middle
property var actions: [
{ cmd: "loginctl lock-session" },
{ cmd: "systemctl suspend" },
{ cmd: "loginctl terminate-user $USER" },
{ cmd: "systemctl reboot" },
{ cmd: "systemctl poweroff" }
]
visible: rootState.logoutMenuOpen
anchors {
top: true
bottom: true
left: true
right: true
}
exclusiveZone: 0
color: "transparent"
WlrLayershell.layer: WlrLayer.Overlay
WlrLayershell.namespace: "quickshell-logout"
WlrLayershell.keyboardFocus: WlrKeyboardFocus.Exclusive
MouseArea {
anchors.fill: parent
onClicked: rootState.logoutMenuOpen = false
}
Rectangle {
anchors.fill: parent
color: Theme.colors.background // Full screen dim/blur
Behavior on opacity { NumberAnimation { duration: Theme.animation.durationNormal } }
opacity: rootState.logoutMenuOpen ? 1 : 0
MouseArea {
anchors.fill: parent
onClicked: rootState.logoutMenuOpen = false
}
Item {
id: container
width: buttonRow.width
height: buttonRow.height
anchors.centerIn: parent
Behavior on scale { SpringAnimation { spring: 3; damping: 0.2 } }
Row {
id: buttonRow
spacing: Theme.geometry.spacing * 3
// Lock
LogoutButton {
icon: "🔒"
label: "Lock"
isSelected: logoutWindow.currentIndex === 0
onClicked: executeAction(logoutWindow.actions[0].cmd)
onHovered: logoutWindow.currentIndex = 0
}
// Suspend
LogoutButton {
icon: "🌙"
label: "Suspend"
isSelected: logoutWindow.currentIndex === 1
onClicked: executeAction(logoutWindow.actions[1].cmd)
onHovered: logoutWindow.currentIndex = 1
}
// Logout
LogoutButton {
icon: "🚪"
label: "Logout"
isSelected: logoutWindow.currentIndex === 2
onClicked: executeAction(logoutWindow.actions[2].cmd)
onHovered: logoutWindow.currentIndex = 2
}
// Reboot
LogoutButton {
icon: "🔄"
label: "Reboot"
isSelected: logoutWindow.currentIndex === 3
onClicked: executeAction(logoutWindow.actions[3].cmd)
onHovered: logoutWindow.currentIndex = 3
}
// Poweroff
LogoutButton {
icon: "⏻"
label: "Shutdown"
isDestructive: true
isSelected: logoutWindow.currentIndex === 4
onClicked: executeAction(logoutWindow.actions[4].cmd)
onHovered: logoutWindow.currentIndex = 4
}
}
}
}
// Key handling
Item {
anchors.fill: parent
focus: true
Keys.onEscapePressed: (event) => {
rootState.logoutMenuOpen = false;
event.accepted = true;
}
Keys.onLeftPressed: (event) => {
if (logoutWindow.currentIndex > 0) {
logoutWindow.currentIndex--;
}
event.accepted = true;
}
Keys.onRightPressed: (event) => {
if (logoutWindow.currentIndex < 4) {
logoutWindow.currentIndex++;
}
event.accepted = true;
}
Keys.onReturnPressed: (event) => {
executeAction(logoutWindow.actions[logoutWindow.currentIndex].cmd);
event.accepted = true;
}
}
Process {
id: actionProcess
running: false
}
function executeAction(cmd) {
actionProcess.command = ["bash", "-c", cmd];
actionProcess.running = true;
rootState.logoutMenuOpen = false;
}
onVisibleChanged: {
if (visible) {
container.scale = 1.0;
logoutWindow.currentIndex = 2; // Reset to center
} else {
container.scale = 0.95;
}
}
// Inline component for the big buttons
component LogoutButton: Rectangle {
property string icon: ""
property string label: ""
property bool isDestructive: false
property bool isSelected: false
signal clicked()
signal hovered()
width: 120
height: 120
radius: Theme.geometry.radius
color: Theme.colors.surface
border.color: isSelected ? (isDestructive ? Theme.colors.alert : Theme.colors.primary) : Theme.colors.border
border.width: isSelected ? 2 : 1
Behavior on scale { SpringAnimation { spring: 4; damping: 0.3 } }
scale: isSelected ? 1.05 : 1.0
Column {
anchors.centerIn: parent
spacing: Theme.geometry.spacing
Text {
text: parent.parent.icon
font.pixelSize: 36
anchors.horizontalCenter: parent.horizontalCenter
color: Theme.colors.text
}
Text {
text: parent.parent.label
font.family: Theme.font.family
font.pixelSize: 16
font.bold: true
color: Theme.colors.text
anchors.horizontalCenter: parent.horizontalCenter
}
}
MouseArea {
id: hoverArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: parent.hovered()
onClicked: parent.clicked()
}
}
}
+40
View File
@@ -6,17 +6,47 @@ import "components/Bar"
import "components/CommandPalette" import "components/CommandPalette"
import "components/OSD" import "components/OSD"
import "components/Shared" import "components/Shared"
import "components/LogoutMenu"
import "components/ClipboardManager"
ShellRoot { ShellRoot {
id: root id: root
// --- Global State --- // --- Global State ---
property bool commandPaletteOpen: false property bool commandPaletteOpen: false
property bool logoutMenuOpen: false
property bool clipboardManagerOpen: false
IpcHandler { IpcHandler {
target: "commandPalette" target: "commandPalette"
function toggle() { function toggle() {
commandPaletteOpen = !commandPaletteOpen; commandPaletteOpen = !commandPaletteOpen;
if (commandPaletteOpen) {
logoutMenuOpen = false;
clipboardManagerOpen = false;
}
}
}
IpcHandler {
target: "logoutMenu"
function toggle() {
logoutMenuOpen = !logoutMenuOpen;
if (logoutMenuOpen) {
commandPaletteOpen = false;
clipboardManagerOpen = false;
}
}
}
IpcHandler {
target: "clipboardManager"
function toggle() {
clipboardManagerOpen = !clipboardManagerOpen;
if (clipboardManagerOpen) {
commandPaletteOpen = false;
logoutMenuOpen = false;
}
} }
} }
@@ -40,6 +70,16 @@ ShellRoot {
rootState: root rootState: root
} }
LogoutMenu {
id: logoutMenu
rootState: root
}
ClipboardManager {
id: clipboardManager
rootState: root
}
OSD { OSD {
id: osd id: osd
} }