mirror of
https://github.com/end-4/dots-hyprland.git
synced 2026-06-29 12:07:29 -05:00
fix(quickshell): hide lock-screen temp workspace from UI, batch lock/unlock
This commit is contained in:
@@ -11,11 +11,57 @@ import Quickshell.Hyprland
|
||||
LockScreen {
|
||||
id: root
|
||||
|
||||
// Monitor name -> workspace id to restore on unlock (set when locking)
|
||||
property var savedWorkspaces: ({})
|
||||
|
||||
Timer {
|
||||
id: restoreTimer
|
||||
interval: 150
|
||||
repeat: false
|
||||
onTriggered: {
|
||||
var batch = ""
|
||||
for (var j = 0; j < Quickshell.screens.length; ++j) {
|
||||
var monName = Quickshell.screens[j].name
|
||||
var wsId = root.savedWorkspaces[monName]
|
||||
if (wsId !== undefined && wsId >= 1 && wsId <= 100) {
|
||||
batch += "dispatch focusmonitor " + monName + "; dispatch workspace " + wsId + "; "
|
||||
}
|
||||
}
|
||||
if (batch.length > 0) {
|
||||
Quickshell.execDetached(["hyprctl", "--batch", batch + "reload"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
lockSurface: LockSurface {
|
||||
context: root.context
|
||||
}
|
||||
|
||||
// Push everything down
|
||||
// Single batch for lock and unlock so we don't race multiple hyprctl calls
|
||||
Connections {
|
||||
target: GlobalStates
|
||||
function onScreenLockedChanged() {
|
||||
if (GlobalStates.screenLocked) {
|
||||
// Lock: save workspace per monitor and move all to temp workspace in one batch
|
||||
var next = {}
|
||||
var batch = "keyword animation workspaces,1,7,menu_decel,slidevert; "
|
||||
for (var i = 0; i < Quickshell.screens.length; ++i) {
|
||||
var mon = Quickshell.screens[i].name
|
||||
var mData = HyprlandData.monitors.find(m => m.name === mon)
|
||||
var ws = (mData?.activeWorkspace?.id ?? 1)
|
||||
if (ws < 1 || ws > 100) ws = 1
|
||||
next[mon] = ws
|
||||
batch += "dispatch focusmonitor " + mon + "; dispatch workspace " + (2147483647 - ws) + "; "
|
||||
}
|
||||
root.savedWorkspaces = next
|
||||
Quickshell.execDetached(["hyprctl", "--batch", batch + "reload"])
|
||||
} else {
|
||||
restoreTimer.start()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Push everything down (visual only; workspace switch is in Connections above)
|
||||
Variants {
|
||||
model: Quickshell.screens
|
||||
delegate: Scope {
|
||||
@@ -24,18 +70,6 @@ LockScreen {
|
||||
property string targetMonitorName: modelData.name
|
||||
property int verticalMovementDistance: modelData.height
|
||||
property int horizontalSqueeze: modelData.width * 0.2
|
||||
property int lastWorkspaceId
|
||||
onShouldPushChanged: {
|
||||
if (shouldPush) {
|
||||
// Save workspace
|
||||
print(targetMonitorName)
|
||||
lastWorkspaceId = HyprlandData.monitors.find(m => m.name == targetMonitorName).activeWorkspace.id
|
||||
// Set anim to vertical and move to very very big workspace for a sliding up effect
|
||||
Quickshell.execDetached(["hyprctl", "--batch", `keyword animation workspaces,1,7,menu_decel,slidevert; dispatch workspace ${2147483647 - lastWorkspaceId}`]);
|
||||
} else {
|
||||
Quickshell.execDetached(["hyprctl", "--batch", `dispatch workspace ${lastWorkspaceId}; reload`]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user