-
-
Save truebit/31396bb2f48c75285d724c9e9e037bcd to your computer and use it in GitHub Desktop.
pull down from top alacritty (like iTerm2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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: