-
-
Save truebit/31396bb2f48c75285d724c9e9e037bcd to your computer and use it in GitHub Desktop.
| window: | |
| # Window dimensions (changes require restart) | |
| # | |
| # Number of lines/columns (not pixels) in the terminal. The number of columns | |
| # must be at least `2`, while using a value of `0` for columns and lines will | |
| # fall back to the window manager's recommended size. | |
| dimensions: | |
| columns: 500 | |
| lines: 30 | |
| # Window position (changes require restart) | |
| # | |
| # Specified in number of pixels. | |
| # If the position is not set, the window manager will handle the placement. | |
| position: | |
| x: 0 | |
| y: 0 | |
| # Window padding (changes require restart) | |
| # | |
| # Blank space added around the window in pixels. This padding is scaled | |
| # by DPI and the specified value is always added at both opposing sides. | |
| #padding: | |
| # x: 0 | |
| # y: 0 | |
| # Spread additional padding evenly around the terminal content. | |
| #dynamic_padding: false | |
| # Window decorations | |
| # | |
| # Values for `decorations`: | |
| # - full: Borders and title bar | |
| # - none: Neither borders nor title bar | |
| # | |
| # Values for `decorations` (macOS only): | |
| # - transparent: Title bar, transparent background and title bar buttons | |
| # - buttonless: Title bar, transparent background and no title bar buttons | |
| decorations: none | |
| key_bindings: | |
| - { key: Return, mods: Command, action: ToggleSimpleFullscreen } |
| local spaces = require("hs.spaces") -- https://github.com/asmagill/hs._asm.spaces | |
| -- Switch alacritty | |
| hs.hotkey.bind({'command'}, 'escape', function () | |
| local BUNDLE_ID = 'org.alacritty' -- more accurate to avoid mismatching on browser titles | |
| function moveWindow(alacritty, space, mainScreen) | |
| -- move to main space | |
| local win = nil | |
| while win == nil do | |
| win = alacritty:mainWindow() | |
| end | |
| print("win="..tostring(win)) | |
| print("space="..tostring(space)) | |
| print("screen="..tostring(win:screen())) | |
| print("mainScr="..tostring(mainScreen)) | |
| if win:isFullScreen() then | |
| hs.eventtap.keyStroke('cmd', 'return', 0, alacritty) | |
| end | |
| winFrame = win:frame() | |
| scrFrame = mainScreen:fullFrame() | |
| winFrame.w = scrFrame.w | |
| winFrame.y = scrFrame.y | |
| winFrame.x = scrFrame.x | |
| print("winFrame="..tostring(winFrame)) | |
| win:setFrame(winFrame, 0) | |
| print("win:frame=" .. tostring(win:frame())) | |
| spaces.moveWindowToSpace(win, space) | |
| if win:isFullScreen() then | |
| hs.eventtap.keyStroke('cmd', 'return', 0, alacritty) | |
| end | |
| win:focus() | |
| end | |
| local alacritty = hs.application.get(BUNDLE_ID) | |
| if alacritty ~= nil and alacritty:isFrontmost() then | |
| alacritty:hide() | |
| else | |
| local space = spaces.activeSpaceOnScreen() | |
| local mainScreen = hs.screen.mainScreen() | |
| if alacritty == nil and hs.application.launchOrFocusByBundleID(BUNDLE_ID) then | |
| local appWatcher = nil | |
| print('create app watcher') | |
| appWatcher = hs.application.watcher.new(function(name, event, app) | |
| print('name='..name) | |
| print('event='..event) | |
| if event == hs.application.watcher.launched and app:bundleID() == BUNDLE_ID then | |
| app:hide() | |
| moveWindow(app, space, mainScreen) | |
| print("stop watcher") | |
| appWatcher:stop() | |
| end | |
| end) | |
| print('start watcher') | |
| appWatcher:start() | |
| end | |
| if alacritty ~= nil then | |
| moveWindow(alacritty, space, mainScreen) | |
| end | |
| end | |
| end) |
What key combinations should I press to enable quake mode?
What key combinations should I press to enable quake mode?
This snippet is only tested and intended for Mac OS X, not Linux.
What key combinations should I press to enable quake mode?
This snippet is only tested and intended for Mac OS X, not Linux.
I am talking about macOS. What's the key combination?
@sksundram the key combination is command + escape, you can find it on the fourth line hs.hotkey.bind({'command'}, 'escape', function ().
@truebit do you happen know how I could get this to come out of the right side rather than the top? I'm digging into Hammerspoon's docs but there's a lot to go through and it's all new to me, so a point in the right direction would be very appreciated.
After remembering that Spaces are Workspaces/Desktop this was much less confusing :-) I needed to be looking at setFrame.
In case anyone interested comes across this, I did this:
local screen = win:screen();
local max = screen:frame();
winFrame.x = max.x + (max.w / 3 * 2)
winFrame.y = max.y
winFrame.w = max.w / 3
winFrame.h = max.h
print("winFrame="..tostring(winFrame))
win:setFrame(winFrame, 0)Thanks for the script!
Do you happen to know if it is possible to apply this rule only to a specific alacritty window? I bascially want to have one window that acts as a drop-down and have the script ignore all other windows. Could we maybe mark one specific window with a certain title and then filter for that title?
Version 0.9.100(6815)with built-inhs.spacesmodules;hs.application.findfunction would also return true when browser titles containing "alacritty" word