Skip to content

Instantly share code, notes, and snippets.

@BirknerAlex
Created May 14, 2025 08:41
Show Gist options
  • Save BirknerAlex/3424073062409d20b9d929abdf56aad4 to your computer and use it in GitHub Desktop.
Save BirknerAlex/3424073062409d20b9d929abdf56aad4 to your computer and use it in GitHub Desktop.
Paste Clipboard to IPMI console
-- Hotkey: Ctrl + Cmd + V
hs.hotkey.bind({"ctrl", "cmd"}, "V", function()
local originalLayout = hs.keycodes.currentLayout()
local targetLayout = "U.S."
local clipboardText = hs.pasteboard.getContents()
if clipboardText == nil or clipboardText == "" then
hs.alert.show("Clipboard is empty!")
return
end
-- Show what's being typed
hs.alert.show("Typing clipboard as " .. targetLayout .. " layout...\n\nStarting in 5 seconds")
hs.timer.doAfter(5, function()
hs.keycodes.setLayout(targetLayout)
hs.timer.usleep(500000) -- wait for layout to apply
for c in clipboardText:gmatch"." do
hs.eventtap.keyStrokes(c)
hs.timer.usleep(50000) -- 50ms between keystrokes
end
-- Restore original layout
hs.keycodes.setLayout(originalLayout)
hs.alert.show("Done. Layout restored to " .. originalLayout)
end)
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment