Last active
November 29, 2024 13:29
-
-
Save programus/d3bf9c6b8f9b7648891d1f59b665b35e 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._asm.undocumented.spaces') -- https://github.com/asmagill/hs._asm.undocumented.spaces | |
-- Switch alacritty | |
hs.hotkey.bind({'alt'}, 'space', function () | |
local APP_NAME = 'Alacritty' | |
function moveWindow(alacritty, space, mainScreen) | |
-- move to main space | |
local win = nil | |
while win == nil do | |
win = alacritty:mainWindow() | |
end | |
print(win) | |
print(space) | |
print(win:screen()) | |
print(mainScreen) | |
local fullScreen = not win:isStandard() | |
if fullScreen then | |
hs.eventtap.keyStroke('cmd', 'return', 0, alacritty) | |
end | |
winFrame = win:frame() | |
scrFrame = mainScreen:fullFrame() | |
print(winFrame) | |
print(scrFrame) | |
winFrame.w = scrFrame.w | |
winFrame.y = scrFrame.y | |
winFrame.x = scrFrame.x | |
print(winFrame) | |
win:setFrame(winFrame, 0) | |
print(win:frame()) | |
win:spacesMoveTo(space) | |
if fullScreen then | |
hs.eventtap.keyStroke('cmd', 'return', 0, alacritty) | |
end | |
win:focus() | |
end | |
local alacritty = hs.application.get(APP_NAME) | |
if alacritty ~= nil and alacritty:isFrontmost() then | |
alacritty:hide() | |
else | |
local space = spaces.activeSpace() | |
local mainScreen = hs.screen.find(spaces.mainScreenUUID()) | |
if alacritty == nil and hs.application.launchOrFocus(APP_NAME) then | |
local appWatcher = nil | |
print('create app watcher') | |
appWatcher = hs.application.watcher.new(function(name, event, app) | |
print(name) | |
print(event) | |
if event == hs.application.watcher.launched and name == APP_NAME then | |
app:hide() | |
moveWindow(app, space, mainScreen) | |
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
I have rewrite this script to use latest
hs.spaces
module, and replaceget app_name
toget bundle id
to avoid mismatching with browser title and I works fine with hammerspoon Version 0.9.100(6815):check my fork for details: https://gist.github.com/truebit/31396bb2f48c75285d724c9e9e037bcd
And here is the Kitty implementation: https://gist.github.com/truebit/d79b8018666d65e95970f208d8f5d149