Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using HyprPanel with hyprsplit does not work well #560

Open
asjur opened this issue Dec 19, 2024 · 5 comments
Open

Using HyprPanel with hyprsplit does not work well #560

asjur opened this issue Dec 19, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@asjur
Copy link

asjur commented Dec 19, 2024

Describe the bug
I use https://github.com/shezdy/hyprsplit to have separate workspaces per monitor similarly to awesome.

Using waybar they have an implementation that shows things correctly on each bar but in hyprpanel this very clearly does not work.

Screenshots
image

@Gajus84
Copy link

Gajus84 commented Dec 19, 2024

You can use the Workspace Icon Mappings to solve that. Like this:
{"1":"1","2":"2","3":"3","4":"4","5":"5","6":"6","7":"7","8":"8","9":"9","10":"10","11":"1","12":"2","13":"3","14":"4","15":"5","16":"6","17":"7","18":"8","19":"9","20":"10"}

  • Slider Map Workspaces to Icons on
  • Monitor Specific on

Ignore Workspaces

-[1-9][0-9]

to get rid of the Scratchpad

@asjur
Copy link
Author

asjur commented Dec 19, 2024

More of a workaround than a fix but thanks I will give that a go!

@edjubert
Copy link

edjubert commented Dec 23, 2024

I was able to fix it by updating the source code.
You need to update the dispatcher use in src/components/Bar/modules/workspaces/helpers/index.ts:
In the function getWorkspaceRules, there is a call to the workspacerules dispatcher that returns (in my case) an object formatted like:

[{
  "workspaceString": "eDP-1"
},
{
  "workspaceString": "HDMI-1"
}]

The WorkspaceRule looks like this:

type WorkspaceRule {
  "workspaceString": string,
  "monitor": string
}

The function expects workspaceString to be an int but, as we saw, the output is the monitor name and not the monitor ID. Maybe hyprctl updates the dispatcher or hyprsplit modifies it.

Here is a patch to fix this:

AGS v2 (if you're on the latest version of HyprPanel, after this commit: 2ffd602910ef31c9c1a772848935955df568b10c on Dec 21 2024

diff --git a/src/components/bar/modules/workspaces/helpers/index.ts b/src/components/bar/modules/workspaces/helpers/index.ts
index 8403117..5616db7 100644
--- a/src/components/bar/modules/workspaces/helpers/index.ts
+++ b/src/components/bar/modules/workspaces/helpers/index.ts
@@ -1,7 +1,7 @@
 import { exec, Variable } from 'astal';
 import AstalHyprland from 'gi://AstalHyprland?version=0.1';
 import { hyprlandService } from 'src/lib/constants/services';
-import { MonitorMap, WorkspaceMap, WorkspaceRule } from 'src/lib/types/workspace';
+import { HyprctlWorkspace, MonitorMap, WorkspaceMap } from 'src/lib/types/workspace';
 import { range } from 'src/lib/utils';
 import options from 'src/options';

@@ -63,19 +63,15 @@ export const getWorkspacesForMonitor = (
  */
 export const getWorkspaceRules = (): WorkspaceMap => {
     try {
-        const rules = exec('hyprctl workspacerules -j');
+        const rules = exec('hyprctl workspaces -j');

         const workspaceRules: WorkspaceMap = {};

-        JSON.parse(rules).forEach((rule: WorkspaceRule) => {
-            const workspaceNum = parseInt(rule.workspaceString, 10);
-            if (isNaN(workspaceNum)) {
-                return;
-            }
+        JSON.parse(rules).forEach((rule: HyprctlWorkspace) => {
             if (Object.hasOwnProperty.call(workspaceRules, rule.monitor)) {
-                workspaceRules[rule.monitor].push(workspaceNum);
+                workspaceRules[rule.monitor].push(rule.id);
             } else {
-                workspaceRules[rule.monitor] = [workspaceNum];
+                workspaceRules[rule.monitor] = [rule.id];
             }
         });

diff --git a/src/lib/types/workspace.d.ts b/src/lib/types/workspace.d.ts
index 5066332..885c09c 100644
--- a/src/lib/types/workspace.d.ts
+++ b/src/lib/types/workspace.d.ts
@@ -1,3 +1,14 @@
+export type HyprctlWorkspace = {
+    id: number,
+    name: string,
+    monitor: string,
+    monitorID: number,
+    windows: number,
+    hasFullscreen: boolean,
+    lastwindows: string,
+    lastwindowtitle: string
+};
+
 export type WorkspaceRule = {
     workspaceString: string;
     monitor: string;

If you're still on previous version, you should pull the last version.
If you don't want to, the two files modified are the same, the helpers.ts is just located elsewhere:

  • src/components/bar/modules/workspaces/helpers/index.ts -> modules/bar/workspaces/helpers.ts

Once you applied the patch, activate these options:
image

It should be working.

I hope it helps.

Note

I wanted to create a PR but, as I'm not a contributor, I don't think I can.

Warning

I tested this only for my usecase and haven't test without Hyprsplit

@davfsa
Copy link
Contributor

davfsa commented Dec 23, 2024

Can confirm that the above works!

@edjubert Thank you for the (actually quite nice) patch!

I tested this only for my usecase and haven't test without Hyprsplit

I have also tested it without, all good there too :) The only difference is that the workspaces widget will only display the workspaces that are in that monitor, which I personally believe that is nicer (this is config specific)

I wanted to create a PR but, as I'm not a contributor, I don't think I can.

You will need to fork the repository, push your changes there and then create a pull request.

See https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork

@edjubert
Copy link

I'll make a PR linking this thread.
That said, I find the label/description for the option not very clear:
Mask Workspace Numbers On Monitors with For monitor-specific numbering don't make any sense.
I think I'll change the label in the PR.

Thank you @davfsa

@orangci orangci added the bug Something isn't working label Dec 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants