Skip to content

Instantly share code, notes, and snippets.

@replete
Created April 17, 2025 21:46
Show Gist options
  • Save replete/245986ddfb5a912f0bc71f5708beeecd to your computer and use it in GitHub Desktop.
Save replete/245986ddfb5a912f0bc71f5708beeecd to your computer and use it in GitHub Desktop.
TotalFinder Visor applescript replacement

It was driving me bananas not having this functionality. It's just not worht disabling SIP and other fundamental system security issues just to get this feature.

This is how you can replicate the visor functionality using just applescript and Karabiner.

  1. Save the following to ~/finder_trigger.scpt:
on run
  tell application "System Events"
    set finderIsVisible to visible of process "Finder"
  end tell

  tell application "Finder"
    set screenBounds to bounds of window of desktop
    set screenWidth to item 3 of screenBounds
    set screenHeight to item 4 of screenBounds

    if finderIsVisible then
      tell application "System Events" to set visible of process "Finder" to false
    else
      activate
      if (count of windows) is 0 then
        make new Finder window to home
        set sidebar width of window 1 to 200
        set current view of window 1 to column view
        set bounds of window 1 to {0, (screenHeight - 500), screenWidth, screenHeight}
      else
        set oldestWindow to window 1
        set oldestID to id of window 1

        repeat with i from 1 to count of windows
          try
            set currentID to id of window i
            if currentID < oldestID then
              set oldestID to currentID
              set oldestWindow to window i
            end if
          end try
        end repeat

        set index of oldestWindow to 1

        set currentBounds to bounds of oldestWindow
        set leftEdge to item 1 of currentBounds
        set rightEdge to item 3 of currentBounds
        set windowHeight to (item 4 of currentBounds) - (item 2 of currentBounds)

        set bounds of oldestWindow to {0, (screenHeight - windowHeight), screenWidth, screenHeight}
      end if
    end if
  end tell
end run

Add a Complex Modification to Karabiner, to run this script when you press the keybind:

{
    "description": "Alt+` to toggle Finder Visor",
    "manipulators": [
        {
            "from": {
                "key_code": "non_us_backslash",
                "modifiers": {
                    "mandatory": ["option"],
                    "optional": ["any"]
                }
            },
            "to": [{ "shell_command": "osascript ~/finder_trigger.scpt" }],
            "type": "basic"
        }
    ]
}

I have some remapped keys so you probably need to use grave_tilde_accent or something for the keycode to get option+backtick working as a keybind

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment