logoalt Hacker News

p2haritoday at 10:41 AM1 replyview on HN

I think there is too much customization and options. Maybe having a .*aml/json file would be good.

I have a few hammerspoon customization for me to choose and open the applications I have. I put those on different desktop but use this to open applications. Whereas for the tiling itself use either aerospace or Loop.

Here is the hammerspoon code for opening the apps using keyboard more like vim jump options.

```

----show all windows of the clicked application

local function showAppWindows(window) local app = window:application() local appWindows = app:allWindows() if #appWindows > 1 then hs.hints.windowHints(appWindows, function(selectedWindow) selectedWindow:focus() local frame = selectedWindow:frame() hs.mouse.setAbsolutePosition({ x = frame.x + frame.w / 2, y = frame.y + frame.h / 2 }) end) else window:focus() local frame = window:frame() hs.mouse.setAbsolutePosition({ x = frame.x + frame.w / 2, y = frame.y + frame.h / 2 }) end end

hs.hotkey.bind({ "cmd", "ctrl", "alt", "shift" }, "p", function() hs.hints.windowHints(nil, showAppWindows) end)

----window search modal

local function createWindowSearchModal() local allWindows = hs.window.allWindows() local windowChoices = {}

    for i, window in ipairs(allWindows) do
        if window:title() and window:title() ~= "" then
            local app = window:application()
            local appName = app and app:name() or "Unknown"
            table.insert(windowChoices, {
                text = appName .. " - " .. window:title(),
                subText = "Window " .. i,
                window = window,
                id = i
            })
        end
    end

    local chooser = hs.chooser.new(function(choice)
        if choice and choice.window then
            choice.window:focus()
            local frame = choice.window:frame()
            hs.mouse.absolutePosition({ x = frame.x + frame.w / 2, y = frame.y + frame.h / 2 })
        end
    end)

    chooser:choices(windowChoices)
    chooser:searchSubText(true)
    chooser:show()
end

hs.hotkey.bind({ "cmd", "ctrl", "alt", "shift" }, "o", function() createWindowSearchModal() end)

---- window search modal for active application only

local function createActiveAppWindowSearchModal()

local frontmostApp = hs.application.frontmostApplication() if not frontmostApp then hs.alert.show("No active application detected") return end local appWindows = frontmostApp:allWindows() local windowChoices = {} for i, window in ipairs(appWindows) do if window:title() and window:title() ~= "" then table.insert(windowChoices, { text = window:title(), subText = "Window " .. i, window = window, id = i }) end end if #windowChoices == 0 then hs.alert.show("No windows found for active application") return end local chooser = hs.chooser.new(function(choice) if choice and choice.window then choice.window:focus() local frame = choice.window:frame() hs.mouse.absolutePosition({ x = frame.x + frame.w / 2, y = frame.y + frame.h / 2 }) end end) chooser:choices(windowChoices) chooser:searchSubText(true) chooser:show() end

hs.hotkey.bind({ "cmd" }, "1", function() createActiveAppWindowSearchModal() end) ```


Replies

crefiztoday at 3:13 PM

You cannot seriosly think that dropping a whole snippet as a comment is a smart move