mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-04-05 05:12:05 -04:00
Feat/niri workspace names (#1396)
* dankbar: show niri workspace names Keep labels aligned with niri indices and live renames. * dankbar: prefix named workspaces with index Use workspace index toggle to show index: name labels. * workspaces: change size conditions for workspace names --------- Co-authored-by: bbedward <bbedward@gmail.com>
This commit is contained in:
committed by
GitHub
parent
417bf37515
commit
fd2c6a0784
@@ -46,11 +46,24 @@ Item {
|
||||
|
||||
function getRealWorkspaces() {
|
||||
if (CompositorService.isNiri) {
|
||||
const fallbackWorkspaces = [
|
||||
{
|
||||
"id": 1,
|
||||
"idx": 0,
|
||||
"name": ""
|
||||
},
|
||||
{
|
||||
"id": 2,
|
||||
"idx": 1,
|
||||
"name": ""
|
||||
}
|
||||
];
|
||||
if (!barWindow.screenName || SettingsData.workspaceFollowFocus) {
|
||||
return NiriService.getCurrentOutputWorkspaceNumbers();
|
||||
const currentWorkspaces = NiriService.getCurrentOutputWorkspaces();
|
||||
return currentWorkspaces.length > 0 ? currentWorkspaces : fallbackWorkspaces;
|
||||
}
|
||||
const workspaces = NiriService.allWorkspaces.filter(ws => ws.output === barWindow.screenName).map(ws => ws.idx + 1);
|
||||
return workspaces.length > 0 ? workspaces : [1, 2];
|
||||
const workspaces = NiriService.allWorkspaces.filter(ws => ws.output === barWindow.screenName);
|
||||
return workspaces.length > 0 ? workspaces : fallbackWorkspaces;
|
||||
} else if (CompositorService.isHyprland) {
|
||||
const workspaces = Hyprland.workspaces?.values || [];
|
||||
|
||||
@@ -118,7 +131,7 @@ Item {
|
||||
return NiriService.getCurrentWorkspaceNumber();
|
||||
}
|
||||
const activeWs = NiriService.allWorkspaces.find(ws => ws.output === barWindow.screenName && ws.is_active);
|
||||
return activeWs ? activeWs.idx + 1 : 1;
|
||||
return activeWs ? activeWs.idx : 1;
|
||||
} else if (CompositorService.isHyprland) {
|
||||
const monitors = Hyprland.monitors?.values || [];
|
||||
const currentMonitor = monitors.find(monitor => monitor.name === barWindow.screenName);
|
||||
@@ -151,12 +164,16 @@ Item {
|
||||
|
||||
if (CompositorService.isNiri) {
|
||||
const currentWs = getCurrentWorkspace();
|
||||
const currentIndex = realWorkspaces.findIndex(ws => ws === currentWs);
|
||||
const currentIndex = realWorkspaces.findIndex(ws => ws && ws.idx === currentWs);
|
||||
const validIndex = currentIndex === -1 ? 0 : currentIndex;
|
||||
const nextIndex = direction > 0 ? Math.min(validIndex + 1, realWorkspaces.length - 1) : Math.max(validIndex - 1, 0);
|
||||
|
||||
if (nextIndex !== validIndex) {
|
||||
NiriService.switchToWorkspace(realWorkspaces[nextIndex] - 1);
|
||||
const nextWorkspace = realWorkspaces[nextIndex];
|
||||
if (!nextWorkspace || nextWorkspace.idx === undefined) {
|
||||
return;
|
||||
}
|
||||
NiriService.switchToWorkspace(nextWorkspace.idx);
|
||||
}
|
||||
} else if (CompositorService.isHyprland) {
|
||||
const currentWs = getCurrentWorkspace();
|
||||
|
||||
Reference in New Issue
Block a user