Hammerspoon / Spoons

The official repository of Spoon plugins
https://www.hammerspoon.org/Spoons/
450 stars 141 forks source link

WindowSigils not working with default configuration #238

Closed R0dri closed 2 years ago

R0dri commented 3 years ago

I downloaded the spoon and loaded the default configuration. I removed my personal configuration in case it was interfering and I can't get it to work. I don't know how to debug either.

Here is the behavior:

It seems to me like keys are not binding after "entering" sigil mode. But I'm not sure if I follow correctly the logic behind sigil mode. Does the "." event is what sort of "triggers" the window I typed after doing ctrl-w? or does the expected behavior is similar to Vim where you enter the mode, do whatever you please. Exit the mode and continue your work?

eraserhd commented 3 years ago

When Hammerspoon starts, key suggestions appear without doing anything. I'm not sure if this is expected behavior, or it is "pre-triggering" itself.

This is intentional. I would be open to an option to hide these until the mode is entered, but how I use it is to keep aware of which windows have which sigils, so that switching windows is very quick.

When I press control-w. Console shows hotkey: Disabled hotkey ⌃W but nothing happens, I can type anything and nothing else will display.

^W should enter the mode (and do nothing else). The next key should do something and exit the mode.

Looking at the docs I wrote, I think they could be clarified. They assume that you have several functions (focus_window, swap_window, paste_as_keystrokes) that aren't part of the WindowSigils plugin, but the user should supply. I'm going to guess the error caused by these missing is causing it to behave weirdly.

My current config is here, and it has those functions.

If I go back (ctrl-w ing), and then press "." then eventtap is loaded. But nothing happens whatever I do in between ctrl-w and '.'

^W followed by . is supposed to send a ^W to the focused application. I use this to delete the previous word in the shell, for example. This is not supposed to be a "sticky" mode, like say Vim's insert mode, but a "one-shot" mode.

After ^W, the next key should do some thing and leave the mode. In the default config, ^w a would focus window "a", and ^w ^b would take the currently focused window and move it on top of b.

Let me know if this helps. If so, I'll update the docs with inline code for those functions so that the default config is at least not baffling.

codeanpeace commented 2 years ago

Just managed to add WindowSigils to my spoons collection – thanks for the nifty interaction @eraserhd! Pegging the sigils to the titlebar by the traffic light buttons makes it very easy to search for :)

I'd definitely like the option of hiding the sigils until the sigil mode is activated via the enter hotkey. I often have overlapping windows so find them distracting at times as they peek through.

It'd also be great if the spoon accepted a windowfilter for applications that sneakily hide windows off screen for quicker responses ala Contexts, a window switcher application.

More of a curiosity, but every time I hit the enter hotkey, the following pops up in the Hammerspoon console but doesn't really seem to be an issue.

ERROR:   LuaSkin: This hotkey is already registered. It may be a duplicate in your Hammerspoon config, or it may be registered by macOS. See System Preferences->Keyboard->Shortcuts
hotkey: Enabled hotkey ___

Another interesting "edge" case I've come across is windows that are aligned and stacked such that their titlebars directly overlap mean their sigils overlap as well. Not sure what the best approach would be but thought I'd bring it up.

eraserhd commented 2 years ago

@codeanpeace What if we only hid sigils which appear underneath the "body" of other windows, until the mode is activated, and then we show them? I think this might be a good balance to be the default behavior. E.g.:

Regarding sneaky applications, the current version has some hard-coded exceptions for sneaky applications. This should probably also be a configuration option, but if you know of sneaky apps, please give me a pull request to this branch. https://github.com/eraserhd/Spoons/blob/WindowSigils-empty-spaces/Source/WindowSigils.spoon/init.lua#L268-L273

Nobody is responding to get this merged here, currently. Not sure what to do about that.

And ... What is the "enter" hotkey?

codeanpeace commented 2 years ago

@eraserhd Hey there, thanks for responding!

By "enter" hotkey I was referring to the docs, specifically "If the 'enter' action is bound to control-w..." Personally, I'm used to and would prefer the vimium style of link hints where the hints/sigils only appear when you activate/enter it explicitly. It helps me see that I've hit the right shortcut to enter the mode correctly.

Is there a way of easily checking if the window sigil is not covered by another window? Personally, if I can't see the titlebar, than I wouldn't be reaching for Window Sigils to switch to it in the first place and naturally wouldn't want to see the sigil to begin with regardless if I've entered the mode or not. While I think your proposed strategy would be neat, it may not be worth the amount of work. ¯\_(ツ)_/¯
edit: I see that hs.window has a topLeft function that could be very useful for this.

I'm more bothered by the overlapping/stacking sigils as it makes those windows impossible to accurately select. For example I always keep the top half of my off to the side vertical side monitor to reference applications like calendar/notes/todos but sometimes will also a full height window for code reference, but because the code window and reference applications share the same titlebar space, the sigils stack. This basically happens whenever the top left point of window title bars are the same. Ideally, any windows below should just never show unless there's a way of spreading the sigils out, which sounds like a lot more work than its worth 'cause I'd be tab switching or using a window fuzzy search bar at that point. image ^ example: an r and a q stacked on top of another

Added the sneaky app in this PR!

eraserhd commented 2 years ago

Oh, wow. It's been so long since I fixed the overlapping sigils problem, that I forgot it ever existed. Please try the branch I linked to. I really wish someone would merge this.

Overlapping sigils are now bumped rightward, which makes stacked windows act somewhat like tabs. I use this all the time these days, and it is nice:

sigils

It just occurred to me that I can outline one of the sigils to indicate which one is focused. That's not implemented yet, but maybe in a couple weeks.