GnomeSnapExtensions / gSnap

Gnome-shell extension that allows you to move windows into specific regions similiar to FancyZones on windows.
https://extensions.gnome.org/extension/4442/gsnap/
Other
166 stars 23 forks source link

gSnap will no longer enable #40

Closed SamKingDev closed 1 year ago

SamKingDev commented 2 years ago

I turned on my PC today and for some reason gSnap won't enable. It just gives the following error:

this.layouts.workspaces[currentWorkspaceIdx][m.index] is undefined

I'm running the latest version of PopOS 22.04

meronz commented 1 year ago

Hi! Thanks for opening an issue, and sorry for the response delay. Do you still have this problem and the related logs + layouts.json file? Otherwise it will be impossible to replicate!

SamKingDev commented 1 year ago

This error comes and goes, where are the logs and layouts.json file stored?

meronz commented 1 year ago

Both are written in the README.

rsaffi commented 1 year ago

@meronz Since @SamKingDev hasn't replied in 18 days, let me provide some further info, since I also face the same error:

this.layouts.workspaces[currentWorkspaceIdx][m.index] is undefined

I'm running Manjaro 22.0.0 (and I confirm everything is up-to-date as of today, 2022-12-09, after running yay -Syyuu). Gnome version is 43.1.

A few notes (with the attached files as requested):

  1. Ever since I first installed the extension, I could never enable it due to the exact error quoted above, so I never got to actually edit/change the layouts, so the attached one is the one that was there after installing the extension for the first time. File: layouts.json.gz

  2. I have an unconventional display setup, so I also wonder if that could play a part into the problem. Display setup shown in the image below. Also, my workspace settings in Gnome "Multitasking" is set for 3 fixed workspaces and only on the primary display (the one in the middle from the image below).

image

  1. I forced the logs to be newly generated by removing the extension and re-installing it (confirming that the config files under ~/.local/share/gnome-shell/extensions/gSnap@micahosborne were gone in between). After reinstallation the error was already being displayed on the Extensions application on Gnome. File: gSnap.log.gz

  2. I'm running X11 instead of Wayland, but I've ruled that out as a potential issue because I have an Arch VM that is also using X11, also with Gnome 43.1, same settings for the "Multitasking" config under Gnome Preferences, and gSnap works perfectly there.

meronz commented 1 year ago

Also, my workspace settings in Gnome "Multitasking" is set for 3 fixed workspaces and only on the primary display (the one in the middle from the image below).

Oh. I wonder if this could be related to that. I'll check this as soon as possible.

meronz commented 1 year ago

I reproduced this bug by enabling the "Workspaces on primary display only" setting, and logging out. I triaged it and created a pull request that should fix it. Could you try if this works for you? I'll wait before merging it.

rsaffi commented 1 year ago

@meronz Had to install typescript and rollup, but after doing that I still got this when running npm run install-extension from the issues/40 branch:

Sa Dez 24 16:29:36 ricardo@viserion [0] ~/git/github/gSnap  (issues/40)
$ npm run install-extension 

> gsnap@0.0.1 install-extension
> npm run build && sh install-extension.sh

> gsnap@0.0.1 build
> tsc && rollup --config rollup.config.js

(node:3205996) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
[!] RollupError: Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this, change the extension of your configuration to ".mjs", set "type": "module" in your package.json file or pass the "--bundleConfigAsCjs" flag.

Original error: Cannot use import statement outside a module
https://rollupjs.org/guide/en/#--bundleconfigascjs
/home/ricardo/git/github/gSnap/rollup.config.js:1
import { defineConfig } from 'rollup';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:74:18)
    at wrapSafe (node:internal/modules/cjs/loader:1141:20)
    at Module._compile (node:internal/modules/cjs/loader:1182:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:169:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:194:25)

As I'm neither a nodejs nor typescript guy, I'll need some further instructions from you! >.<

meronz commented 1 year ago

Ok, maybe the docs are lacking on this side. Try running npm ci before the install-extension

rsaffi commented 1 year ago

Ok, that did the trick and it installed. I logged off and back in and saw that the extension was working, but I have a follow-up question: I set up the layouts as (in this order):

I noticed that gSnap respected the choice for Monitors 0 and 2, but on monitor 1 it screwed up the layout the moment I set the center one as "3 column (focused)".

This is what happened:

image

EDIT:

Ok, I seem to have figured out rows, but the issue for me is that it's using some very odd percentages and going overboard with the boundaries (like 112,5% instead of 100% for left screen, so the zone ends up going over the center screen).

image

meronz commented 1 year ago

So, if I understood that correctly, the bug is that the extension allows for percentages to be set to more than 100%? Does this make the extension unusable for you?

rsaffi commented 1 year ago

No, it's not about that, but perhaps I failed to explain in a clearer manner. It's just that I am unable to setup a layout that is respecting the monitor's boundaries. And also if you look at the first screenshot from my previous message the zone on the right monitor does not go all the way to the right edge.

meronz commented 1 year ago

Ok, I'll try to replicate and fix this. Sorry if I did not understand before, I can see now the problem.

meronz commented 1 year ago

I should have fixed it in the linked PR (#54). Try to build it to see if it works for you.

rsaffi commented 1 year ago

Hi @meronz, thanks for the feedback! Just tested the branch issues/editor-fixes and everything is working perfectly! Thanks for the great work and effort you put into getting these addressed! 💪🏻

Screenshot from 2022-12-29 13-10-00

meronz commented 1 year ago

You're welcome. The merge in main will need some time though, since I'm working these holidays.

meronz commented 1 year ago

Merged! I'll try to release on extensions.gnome.org ASAP.