Hammerspoon / hammerspoon

Staggeringly powerful macOS desktop automation with Lua

Home Page:http://www.hammerspoon.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Can the animations be turned off when using `hs.application:activate`?

NightMachinery opened this issue · comments

I use Hammerspoon to move between apps, but the slow animation is bothering me.

Here is the code I use:

hyper = {"cmd","ctrl","alt","shift"}
hs.window.animationDuration = 0;

function toggleFocus(appName)
  local app = hs.application.get(appName)

  if app then
    if app:isFrontmost() then
      app:hide()
    else
      app:activate()
    end
  else
    if o.launch then
      hs.application.launchOrFocus(appName)
      app = hs.application.get(appName)
    end
  end
end

function appHotkey(o)
  hs.hotkey.bind(o.modifiers or hyper, o.key, function()
                   toggleFocus(o.appName)
  end)
end

The applications are usually in different spaces; I put each app in fullscreen in its space. So to change focus to it, an space change must also occur.


I have seen #3297, and I have ran

for _, app in ipairs(hs.application.runningApplications()) do
	local axApp = hs.axuielement.applicationElement(app)
	if axApp.AXEnhancedUserInterface then
		return "yes"
	end
end
return "no"

It returns no for me.

I disabled SIP to install yabai, and the animations stopped. Is this a feature of Hammerspoon, or was it sth yabai did?

# If you're on Apple Silicon macOS 13.x.x
# Requires Filesystem Protections, Debugging Restrictions and NVRAM Protection to be disabled
# (printed warning can be safely ignored)
csrutil enable --without fs --without debug --without nvram

As far as I know there's no official way to get rid of those Spaces animations. (Although it changes from 'slide' to 'fade' if you turn on the system-wide 'Reduce motion' setting. But that affects various other things too.)

However…

I disabled SIP to install yabai, and the animations stopped. Is this a feature of Hammerspoon, or was it sth yabai did?

…yes, apparently yabai disables the Spaces animations when SIP is disabled. (And it doesn't sound like that can be configured.)

Thanks. Feel free to close the issue.