agzam / spacehammer

Hammerspoon config inspired by Spacemacs
MIT License
567 stars 70 forks source link

Icons and app previews too big, overflow the screen? #109

Closed taquangtrung closed 3 years ago

taquangtrung commented 3 years ago

Hi,

I'm using the newest Spacehammer and when pressing Option-n/p to select apps, the app icons and previews appear too big, overflow the screen (see attached screenshot).

Could you advise how to make them smaller so that I can see the full icons?

Screenshot 2021-09-03 at 11 56 06 PM
jaidetree commented 3 years ago

That does look odd, will see if I can reproduce.

jaidetree commented 3 years ago

Wasn't able to reproduce the issue, but did find some insight as to the cause.

If you open ~/.hammerspoon/apps.fnl you should see:

{:textSize 12
 :showTitles false
 :showThumbnails false
 :showSelectedTitle false
 :selectedThumbnailSize 800
 :backgroundColor [0 0 0 0]}

Which are options for https://www.hammerspoon.org/docs/hs.window.switcher.html#ui.

Maybe you can try changing those around, see what works for you, and I can give them a shot then we can either make a PR or I can make it a bit smarter to calculate based on screen size.

jaidetree commented 3 years ago

Though after more testing the :selectedThumbnailSize 800 is the likely culprit. Try using:

{:textSize 12
         :showTitles false
         :showThumbnails false
         :showSelectedTitle false
         :selectedThumbnailSize (let [screen (hs.screen.mainScreen)
                                      {: h} (: screen :currentMode)]
                                  (/ h 2))
         :backgroundColor [0 0 0 0]}

And if that doesn't work try replacing (/ h 2) with (/ h 4) and let us know if one of those works better

taquangtrung commented 3 years ago

Great! Thanks for your patch. Using (/ h 2) is nicer.

Here is a screenshoot for your reference. ((/ h 4) will produce smaller thumbnails)

Screenshot 2021-09-05 at 2 47 37 PM
taquangtrung commented 3 years ago

Btw, I noticed that some minimized windows didn't appear when switching windows by Opt-n, Opt-p. Is it possible to include them too?

jaidetree commented 3 years ago

Looked into this briefly:

(local filter (hs.window.filter.new))

(doto filter
  (: :setCurrentSpace true)
  (: :setDefaultFilter {}))

(global switcher
       (hs.window.switcher.new
        filter
        {:textSize 12
         :showTitles false
         :showThumbnails false
         :showSelectedTitle false
         :selectedThumbnailSize (let [screen (hs.screen.mainScreen)
                                      {: h} (: screen :currentMode)]
                                  (/ h 2))
         :backgroundColor [0 0 0 0]}))

This combo seems like a reasonable balance of catching usable windows, but without excluding minimized windows. Feel free to tweak it further to fir your use case.

Thinking of making two PRs:

  1. That will default the thumbnail size to 1/2 of screen height
  2. That adds a config option :app-switcher-filter to set a custom app-switcher-filter instance that could be defined in config.fnl instead of changing the apps definition.
jaidetree commented 3 years ago

One note is sometimes the filter can be inconsistent, and you may need to press alt+n once or twice to get the filter to take effect. I think it caches the window list to avoid expensive re-queries based on some hints from the docs.

taquangtrung commented 3 years ago
  1. That adds a config option :app-switcher-filter to set a custom app-switcher-filter instance that could be defined in config.fnl instead of changing the apps definition.

Great! I think this will be very useful since the current Alt-Tab of macOS doesn't show minimized windows.