1
0
mirror of https://github.com/AvengeMedia/DankMaterialShell.git synced 2026-01-28 23:42:51 -05:00

simplify hyprland

This commit is contained in:
bbedward
2025-08-22 14:08:52 -04:00
parent 586cc61b0e
commit d7c98e73c8
2 changed files with 8 additions and 53 deletions

View File

@@ -188,7 +188,7 @@ Rectangle {
if (CompositorService.isNiri) { if (CompositorService.isNiri) {
NiriService.switchToWorkspace(modelData - 1) NiriService.switchToWorkspace(modelData - 1)
} else if (CompositorService.isHyprland) { } else if (CompositorService.isHyprland) {
HyprlandService.switchToWorkspace(modelData) Hyprland.dispatch(`workspace ${modelData}`)
} }
} }
} }

View File

@@ -7,20 +7,13 @@ import Quickshell.Hyprland
Singleton { Singleton {
id: root id: root
property bool hyprlandAvailable: { property var allWorkspaces: CompositorService.isHyprland && Hyprland.workspaces ? Hyprland.workspaces.values : []
const signature = Quickshell.env("HYPRLAND_INSTANCE_SIGNATURE") property var focusedWorkspace: CompositorService.isHyprland ? Hyprland.focusedWorkspace : null
return signature && signature.length > 0 property var monitors: CompositorService.isHyprland ? Hyprland.monitors : []
} property var focusedMonitor: CompositorService.isHyprland ? Hyprland.focusedMonitor : null
property var allWorkspaces: hyprlandAvailable && Hyprland.workspaces ? Hyprland.workspaces.values : []
property var focusedWorkspace: hyprlandAvailable ? Hyprland.focusedWorkspace : null
property var monitors: hyprlandAvailable ? Hyprland.monitors : []
property var focusedMonitor: hyprlandAvailable ? Hyprland.focusedMonitor : null
function getWorkspacesForMonitor(monitorName) { function getWorkspacesForMonitor(monitorName) {
if (!hyprlandAvailable) return []
const workspaces = Hyprland.workspaces ? Hyprland.workspaces.values : [] const workspaces = Hyprland.workspaces ? Hyprland.workspaces.values : []
if (!workspaces || workspaces.length === 0) return [] if (!workspaces || workspaces.length === 0) return []
@@ -51,8 +44,6 @@ Singleton {
} }
function getCurrentWorkspaceForMonitor(monitorName) { function getCurrentWorkspaceForMonitor(monitorName) {
if (!hyprlandAvailable) return null
// If no monitor name specified, return the globally focused workspace // If no monitor name specified, return the globally focused workspace
if (!monitorName) { if (!monitorName) {
return focusedWorkspace return focusedWorkspace
@@ -72,33 +63,7 @@ Singleton {
return null return null
} }
function switchToWorkspace(workspaceId) { function getWorkspaceDisplayNumbers() {
if (!hyprlandAvailable) return
Hyprland.dispatch(`workspace ${workspaceId}`)
}
function switchToWorkspaceByName(workspaceName) {
if (!hyprlandAvailable) return
Hyprland.dispatch(`workspace name:${workspaceName}`)
}
function moveToWorkspace(workspaceId) {
if (!hyprlandAvailable) return
Hyprland.dispatch(`movetoworkspace ${workspaceId}`)
}
function createWorkspace(workspaceId) {
if (!hyprlandAvailable) return
Hyprland.dispatch(`workspace ${workspaceId}`)
}
function getWorkspaceDisplayNumbers() {
if (!hyprlandAvailable) return [1, 2, 3, 4]
// Get all existing workspaces from Hyprland.workspaces.values // Get all existing workspaces from Hyprland.workspaces.values
const workspaces = Hyprland.workspaces ? Hyprland.workspaces.values : [] const workspaces = Hyprland.workspaces ? Hyprland.workspaces.values : []
if (!workspaces || workspaces.length === 0) { if (!workspaces || workspaces.length === 0) {
@@ -129,16 +94,12 @@ Singleton {
} }
function getCurrentWorkspaceNumber() { function getCurrentWorkspaceNumber() {
if (!hyprlandAvailable) return 1
// Use the focused workspace directly // Use the focused workspace directly
const focused = Hyprland.focusedWorkspace const focused = Hyprland.focusedWorkspace
return focused ? focused.id : 1 return focused ? focused.id : 1
} }
function sortToplevels(toplevels) { function sortToplevels(toplevels) {
if (!hyprlandAvailable || !toplevels) return []
// Create a copy of the array since the original might be readonly // Create a copy of the array since the original might be readonly
const sortedArray = Array.from(toplevels) const sortedArray = Array.from(toplevels)
@@ -166,10 +127,4 @@ Singleton {
onAllWorkspacesChanged: workspacesUpdated() onAllWorkspacesChanged: workspacesUpdated()
onFocusedWorkspaceChanged: focusedWorkspaceUpdated() onFocusedWorkspaceChanged: focusedWorkspaceUpdated()
onFocusedMonitorChanged: focusedMonitorUpdated() onFocusedMonitorChanged: focusedMonitorUpdated()
Component.onCompleted: {
if (hyprlandAvailable) {
console.log("HyprlandService: Initialized with Hyprland support")
}
}
} }