MAC使用已经有半年了
为了克服Windows后遗症,先后用hammerspoon写了好些脚本:自动聚焦最上层窗口、回车键打开文件、点击app图标最小化应用窗口…(当然都是委托AI大人完成的)
当然这些功能也许已经有更成熟的解决方案,hammerspoon的强大也远不止于此,所以水上一贴,看看佬友们的MAC上都运行了哪些神奇脚本![]()
MAC使用已经有半年了
为了克服Windows后遗症,先后用hammerspoon写了好些脚本:自动聚焦最上层窗口、回车键打开文件、点击app图标最小化应用窗口…(当然都是委托AI大人完成的)
当然这些功能也许已经有更成熟的解决方案,hammerspoon的强大也远不止于此,所以水上一贴,看看佬友们的MAC上都运行了哪些神奇脚本![]()
local json = require("hs.json")
local APP_FRAME_FILE = hs.configdir .. "/app_frames.json"
local mt = hs.getObjectMetatable("hs.window")
local state = {
appFrames = hs.fs.attributes(APP_FRAME_FILE) and json.read(APP_FRAME_FILE) or {},
winFrames = {},
isFree = {},
needSave = false
}
function state:getSize(win)
return state.winFrames[win:id()] or state.appFrames[win:application():bundleID()]
end
local function eq(l, r)
local EPSILON = 1
return math.abs(l - r) <= EPSILON
end
local layouts = {
topLeft = function(s)
return {
x = s.x,
y = s.y,
w = s.w / 2,
h = s.h / 2
}
end,
topRight = function(s)
return {
x = s.x + s.w / 2,
y = s.y,
w = s.w / 2,
h = s.h / 2
}
end,
bottomLeft = function(s)
return {
x = s.x,
y = s.y + s.h / 2,
w = s.w / 2,
h = s.h / 2
}
end,
bottomRight = function(s)
return {
x = s.x + s.w / 2,
y = s.y + s.h / 2,
w = s.w / 2,
h = s.h / 2
}
end,
left = function(s)
return {
x = s.x,
y = s.y,
w = s.w / 2,
h = s.h
}
end,
right = function(s)
return {
x = s.x + s.w / 2,
y = s.y,
w = s.w / 2,
h = s.h
}
end,
top = function(s)
return {
x = s.x,
y = s.y,
w = s.w,
h = s.h / 2
}
end,
bottom = function(s)
return {
x = s.x,
y = s.y + s.h / 2,
w = s.w,
h = s.h / 2
}
end,
max = function(s)
return {
x = s.x,
y = s.y,
w = s.w,
h = s.h
}
end
}
function mt:setPosition(name)
local layout = layouts[name]
if layout then
self:setFrame(layout(self:screen():frame()))
end
end
function mt:isAtPosition(name)
local layout = layouts[name]
if not layout then
return false
end
local f = self:frame()
local t = layout(self:screen():frame())
return eq(f.x, t.x) and eq(f.y, t.y) and eq(f.w, t.w) and eq(f.h, t.h)
end
function mt:isSnapped()
for name in pairs(layouts) do
if self:isAtPosition(name) then
return true
end
end
return false
end
for name in pairs(layouts) do
local suffix = name:gsub("^%l", string.upper)
mt["is" .. suffix] = function(self)
return self:isAtPosition(name)
end
mt["set" .. suffix] = function(self)
return self:setPosition(name)
end
end
function mt:setSize(s)
local f = self:frame()
self:setFrame({
x = f.x,
y = f.y,
w = s[1],
h = s[2]
})
end
function mt:saveFrame()
local f = self:frame()
if f.w == 0 or f.h == 0 then
return
end
local v = {f.w, f.h}
state.winFrames[self:id()] = v
state.appFrames[self:application():bundleID()] = v
state.needSave = true
end
function mt:restoreFrame()
local s = state:getSize(self)
if s then
self:setSize(s)
end
end
function mt:left()
if self:isTop() or self:isTopRight() then
self:setTopLeft()
elseif self:isBottom() or self:isBottomRight() then
self:setBottomLeft()
else
self:setLeft()
end
end
function mt:right()
if self:isTop() or self:isTopLeft() then
self:setTopRight()
elseif self:isBottom() or self:isBottomLeft() then
self:setBottomRight()
else
self:setRight()
end
end
function mt:up()
if self:isLeft() or self:isBottomLeft() then
self:setTopLeft()
elseif self:isRight() or self:isBottomRight() then
self:setTopRight()
else
self:setMax()
end
end
function mt:down()
if self:isLeft() or self:isTopLeft() then
self:setBottomLeft()
elseif self:isRight() or self:isTopRight() then
self:setBottomRight()
else
self:minimize()
end
end
local function bindWindowAction(event, method)
hs.urlevent.bind(event, function()
local win = hs.window.focusedWindow()
if win then
method(win)
end
end)
end
bindWindowAction("left", mt.left)
bindWindowAction("right", mt.right)
bindWindowAction("up", mt.up)
bindWindowAction("down", mt.down)
bindWindowAction("upAlt", mt.setTop)
bindWindowAction("downAlt", mt.setBottom)
local watcher = hs.pathwatcher.new(hs.configdir, function(paths, _)
for _, file in pairs(paths) do
if file:sub(-4) == ".lua" then
hs.reload()
break
end
end
end):start()
local timer = hs.timer.new(10, function()
if state.needSave then
local file, err = io.open(APP_FRAME_FILE, "w")
if file then
file:write(json.encode(state.appFrames))
file:close()
state.needSave = false
else
print("Error saving app frames: " .. tostring(err))
end
end
end):start()
function hs.shutdownCallback()
timer:fire()
end
hs.window.filter.default:subscribe(hs.window.filter.windowFocused, function(win, _)
if not win:isSnapped() then
win:saveFrame()
end
end)
hs.window.filter.default:subscribe(hs.window.filter.windowMoved, function(win, _)
local id = win:id()
local isFree = not win:isSnapped()
if isFree then
if state.isFree[id] then
win:saveFrame()
else
win:restoreFrame()
end
end
state.isFree[id] = isFree
end)
{
"profiles": [
{
"complex_modifications": {
"rules": [
{
"description": "Home -> Cmd + Left",
"manipulators": [
{
"from": {
"key_code": "home",
"modifiers": { "optional": ["shift", "command"] }
},
"to": [
{
"key_code": "left_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "End -> Cmd + Right",
"manipulators": [
{
"from": {
"key_code": "end",
"modifiers": { "optional": ["shift", "command"] }
},
"to": [
{
"key_code": "right_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "Home -> Fn/Cmd + Left",
"enabled": false,
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^org\\.mozilla\\.nightly$",
"^org\\.pqrs\\.Karabiner-Elements\\.Settings$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "home",
"modifiers": { "optional": ["shift", "command"] }
},
"to": [
{
"key_code": "left_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
},
{
"from": {
"key_code": "home",
"modifiers": { "optional": ["shift", "command"] }
},
"to": [
{
"key_code": "left_arrow",
"modifiers": ["fn"]
}
],
"type": "basic"
}
]
},
{
"description": "End -> Fn/Cmd + Right",
"enabled": false,
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^org\\.mozilla\\.nightly$",
"^org\\.pqrs\\.Karabiner-Elements\\.Settings$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "end",
"modifiers": { "optional": ["shift", "command"] }
},
"to": [
{
"key_code": "right_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
},
{
"from": {
"key_code": "end",
"modifiers": { "optional": ["shift", "command"] }
},
"to": [
{
"key_code": "right_arrow",
"modifiers": ["fn"]
}
],
"type": "basic"
}
]
},
{
"description": "F11 -> Ctrl + Cmd + F (FullScreen)",
"manipulators": [
{
"from": { "key_code": "f11" },
"to_if_alone": [
{
"key_code": "f",
"modifiers": ["control", "command"]
}
],
"type": "basic"
}
]
},
{
"description": "Shift -> Ctrl + Space",
"manipulators": [
{
"from": { "key_code": "left_shift" },
"to": [
{
"key_code": "left_shift",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "spacebar",
"modifiers": ["control"]
}
],
"type": "basic"
},
{
"from": { "key_code": "right_shift" },
"to": [
{
"key_code": "right_shift",
"lazy": true
}
],
"to_if_alone": [
{
"key_code": "spacebar",
"modifiers": ["control"]
}
],
"type": "basic"
}
]
},
{
"description": "LeftCtrl + Up/Down -> PgUp/PgDn",
"manipulators": [
{
"from": {
"key_code": "up_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [{ "key_code": "page_up" }],
"type": "basic"
},
{
"from": {
"key_code": "down_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [{ "key_code": "page_down" }],
"type": "basic"
}
]
},
{
"description": "LeftCtrl + (Left, Right, Up, Down) -> Home/End/PgUp/PgDn",
"enabled": false,
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^org\\.mozilla\\.nightly$",
"^org\\.pqrs\\.Karabiner-Elements\\.Settings$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "left_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$",
"^com\\.microsoft\\.VSCode(Insiders)?$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "left_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [{ "key_code": "home" }],
"type": "basic"
},
{
"from": {
"key_code": "left_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [
{
"key_code": "left_arrow",
"modifiers": ["fn"]
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^org\\.mozilla\\.nightly$",
"^org\\.pqrs\\.Karabiner-Elements\\.Settings$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "right_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.jetbrains\\.intellij$",
"^com\\.microsoft\\.VSCode(Insiders)?$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "right_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [{ "key_code": "end" }],
"type": "basic"
},
{
"from": {
"key_code": "right_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [
{
"key_code": "right_arrow",
"modifiers": ["fn"]
}
],
"type": "basic"
},
{
"from": {
"key_code": "up_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [{ "key_code": "page_up" }],
"type": "basic"
},
{
"from": {
"key_code": "down_arrow",
"modifiers": {
"mandatory": ["left_command"],
"optional": ["shift"]
}
},
"to": [{ "key_code": "page_down" }],
"type": "basic"
}
]
},
{
"description": "Ctrl + C -> Cmd + C & Ctrl + C",
"manipulators": [
{
"from": {
"key_code": "c",
"modifiers": { "mandatory": ["command"] }
},
"to": [
{
"key_code": "c",
"modifiers": ["command"]
},
{
"key_code": "c",
"modifiers": ["control"]
}
],
"type": "basic"
}
]
},
{
"description": "Ctrl + Y -> Cmd + Shift + Z (Redo)",
"manipulators": [
{
"from": {
"key_code": "y",
"modifiers": {
"mandatory": ["command"],
"optional": ["caps_lock", "option", "fn"]
}
},
"to": [
{
"key_code": "z",
"modifiers": ["shift", "command"]
}
],
"type": "basic"
}
]
},
{
"description": "Ctrl + Tab -> Ctrl + Tab",
"manipulators": [
{
"from": {
"key_code": "tab",
"modifiers": {
"mandatory": ["command"],
"optional": ["shift"]
}
},
"to": [
{
"key_code": "tab",
"modifiers": ["control"]
}
],
"type": "basic"
}
]
},
{
"description": "Ctrl + Esc / Win -> Start",
"manipulators": [
{
"from": {
"key_code": "escape",
"modifiers": { "mandatory": ["command"] }
},
"to": [{ "key_code": "launchpad" }],
"type": "basic"
},
{
"from": { "key_code": "left_control" },
"to": [
{
"key_code": "left_control",
"lazy": true
}
],
"to_if_alone": [{ "key_code": "launchpad" }],
"type": "basic"
},
{
"from": { "key_code": "right_control" },
"to": [
{
"key_code": "right_control",
"lazy": true
}
],
"to_if_alone": [{ "key_code": "launchpad" }],
"type": "basic"
}
]
},
{
"description": "Ctrl + Shift + Esc -> TaskMgr",
"manipulators": [
{
"from": {
"key_code": "escape",
"modifiers": { "mandatory": ["shift", "command"] }
},
"to": [{ "software_function": { "open_application": { "bundle_identifier": "com.apple.ActivityMonitor" } } }],
"type": "basic"
}
]
},
{
"description": "Ctrl + Win + T -> Topmost",
"enabled": false,
"manipulators": [
{
"from": {
"key_code": "t",
"modifiers": { "mandatory": ["control", "command"] }
},
"to": [{ "shell_command": "/usr/local/bin/window-topmost toggle" }],
"type": "basic"
}
]
},
{
"description": "Win + (1 - 0)",
"manipulators": [
{
"from": {
"key_code": "1",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:1:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "2",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:2:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "3",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:3:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "4",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:4:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "5",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:5:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "6",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:6:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "7",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:7:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "8",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:8:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "9",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:9:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
},
{
"from": {
"key_code": "0",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -b $(/usr/libexec/PlistBuddy -c 'print :persistent-apps:10:tile-data:bundle-identifier' ~/Library/Preferences/com.apple.dock.plist)" }],
"type": "basic"
}
]
},
{
"description": "Win + (Left, Right, Up, Down) -> Hammerspoon",
"manipulators": [
{
"from": {
"key_code": "left_arrow",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -g hammerspoon://left" }],
"type": "basic"
},
{
"from": {
"key_code": "right_arrow",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -g hammerspoon://right" }],
"type": "basic"
},
{
"from": {
"key_code": "up_arrow",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -g hammerspoon://up" }],
"type": "basic"
},
{
"from": {
"key_code": "down_arrow",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "shell_command": "open -g hammerspoon://down" }],
"type": "basic"
}
]
},
{
"description": "Win + Alt + (Left, Right) -> Ctrl + it",
"manipulators": [
{
"from": {
"key_code": "left_arrow",
"modifiers": { "mandatory": ["control", "option"] }
},
"to": [
{
"key_code": "left_arrow",
"modifiers": ["control"]
}
],
"type": "basic"
},
{
"from": {
"key_code": "right_arrow",
"modifiers": { "mandatory": ["control", "option"] }
},
"to": [
{
"key_code": "right_arrow",
"modifiers": ["control"]
}
],
"type": "basic"
}
]
},
{
"description": "Win + Alt + (Up, Down) -> Hammerspoon",
"manipulators": [
{
"from": {
"key_code": "up_arrow",
"modifiers": { "mandatory": ["control", "option"] }
},
"to": [{ "shell_command": "open -g hammerspoon://upAlt" }],
"type": "basic"
},
{
"from": {
"key_code": "down_arrow",
"modifiers": { "mandatory": ["control", "option"] }
},
"to": [{ "shell_command": "open -g hammerspoon://downAlt" }],
"type": "basic"
}
]
},
{
"description": "Win + (E, I, L, .)",
"manipulators": [
{
"from": {
"key_code": "e",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "software_function": { "open_application": { "bundle_identifier": "com.apple.finder$" } } }],
"type": "basic"
},
{
"from": {
"key_code": "i",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "software_function": { "open_application": { "bundle_identifier": "com.apple.systempreferences" } } }],
"type": "basic"
},
{
"from": {
"key_code": "l",
"modifiers": { "mandatory": ["control"] }
},
"to": [
{
"key_code": "q",
"modifiers": ["control", "command"]
}
],
"type": "basic"
},
{
"from": {
"key_code": "period",
"modifiers": { "mandatory": ["control"] }
},
"to": [
{
"key_code": "spacebar",
"modifiers": ["control", "command"]
}
],
"type": "basic"
}
]
},
{
"description": "Win + T -> Terminal",
"manipulators": [
{
"from": {
"key_code": "t",
"modifiers": { "mandatory": ["control"] }
},
"to": [{ "software_function": { "open_application": { "bundle_identifier": "dev.warp.Warp-Preview" } } }],
"type": "basic"
}
]
},
{
"description": "Win + Tab -> Fn + F3 (Task View)",
"manipulators": [
{
"from": {
"key_code": "tab",
"modifiers": { "mandatory": ["control"] }
},
"to": [
{
"key_code": "f3",
"modifiers": ["fn"]
}
],
"type": "basic"
}
]
},
{
"description": "Win + Down -> Cmd + H",
"manipulators": [
{
"from": {
"key_code": "down_arrow",
"modifiers": { "mandatory": ["control"] }
},
"to": [
{
"key_code": "h",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "Alt + F4 -> Cmd + Q",
"manipulators": [
{
"from": {
"key_code": "f4",
"modifiers": { "mandatory": ["option"] }
},
"to": [
{
"key_code": "q",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "[Browser] F5 -> Cmd + R (Refresh)",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Safari$",
"^com\\.google\\.Chrome(\\.(beta|dev|canary))?$",
"^com\\.microsoft\\.edgemac(\\.(Beta|Canary|Dev))?$",
"^org\\.mozilla\\.nightly$"
],
"type": "frontmost_application_if"
}
],
"from": { "key_code": "f5" },
"to": [
{
"key_code": "r",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "[Browser] Ctrl + H",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Safari$",
"^com\\.google\\.Chrome(\\.(beta|dev|canary))?$",
"^com\\.microsoft\\.edgemac(\\.(Beta|Canary|Dev))?$",
"^org\\.mozilla\\.nightly$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "h",
"modifiers": { "mandatory": ["command"] }
},
"to": [
{
"key_code": "y",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "[Browser w/o Firefox] Ctrl + J",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Safari$",
"^com\\.microsoft\\.edgemac(\\.(Beta|Canary|Dev))?$",
"^com\\.google\\.Chrome(\\.(beta|dev|canary))?$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "j",
"modifiers": { "mandatory": ["command"] }
},
"to": [
{
"key_code": "l",
"modifiers": ["option", "command"]
}
],
"type": "basic"
}
]
},
{
"description": "[Browser] Alt + (Left, Right) -> Cmd + it",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Safari$",
"^com\\.google\\.Chrome(\\.(beta|dev|canary))?$",
"^org\\.mozilla\\.nightly$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "left_arrow",
"modifiers": { "mandatory": ["option"] }
},
"to": [
{
"key_code": "left_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.google\\.Chrome(\\.(beta|dev|canary))?$",
"^org\\.mozilla\\.nightly$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "right_arrow",
"modifiers": { "mandatory": ["option"] }
},
"to": [
{
"key_code": "right_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "[Browser, Finder] Alt + (Left, Right) -> Cmd + ([, ])",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Safari$",
"^com\\.apple\\.finder$",
"^com\\.microsoft\\.edgemac(\\.(Beta|Canary|Dev))?$",
"^org\\.mozilla\\.nightly$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "left_arrow",
"modifiers": { "mandatory": ["option"] }
},
"to": [
{
"key_code": "open_bracket",
"modifiers": ["command"]
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.Safari$",
"^com\\.apple\\.finder$",
"^com\\.microsoft\\.edgemac(\\.(Beta|Canary|Dev))?$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "right_arrow",
"modifiers": { "mandatory": ["option"] }
},
"to": [
{
"key_code": "close_bracket",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "[Finder] F2 -> Enter (Rename)",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.finder$"
],
"type": "frontmost_application_if"
}
],
"from": { "key_code": "f2" },
"to": [{ "key_code": "return_or_enter" }],
"type": "basic"
}
]
},
{
"description": "[Finder] Delete -> Cmd + Backspace (Delete)",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.finder$"
],
"type": "frontmost_application_if"
}
],
"from": { "key_code": "delete_forward" },
"to": [
{
"key_code": "delete_or_backspace",
"modifiers": ["command"]
}
],
"type": "basic"
},
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.finder$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "delete_forward",
"modifiers": { "mandatory": ["shift"] }
},
"to": [
{
"key_code": "delete_or_backspace",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "[Finder] Alt + Up -> Cmd + Up",
"manipulators": [
{
"conditions": [
{
"bundle_identifiers": [
"^com\\.apple\\.finder$"
],
"type": "frontmost_application_if"
}
],
"from": {
"key_code": "up_arrow",
"modifiers": { "mandatory": ["option"] }
},
"to": [
{
"key_code": "up_arrow",
"modifiers": ["command"]
}
],
"type": "basic"
}
]
},
{
"description": "[x] Win + LeftClick",
"manipulators": [
{
"from": {
"modifiers": { "mandatory": ["control"] },
"pointing_button": "button1"
},
"to": [{ "pointing_button": "button1" }],
"type": "basic"
}
]
},
{
"description": "[x] Ctrl + H",
"manipulators": [
{
"from": {
"key_code": "h",
"modifiers": { "mandatory": ["command"] }
},
"type": "basic"
}
]
}
]
},
"devices": [
{
"identifiers": { "is_keyboard": true },
"simple_modifications": [
{
"from": { "apple_vendor_top_case_key_code": "keyboard_fn" },
"to": [{ "key_code": "left_command" }]
},
{
"from": { "key_code": "left_command" },
"to": [{ "key_code": "left_option" }]
},
{
"from": { "key_code": "left_control" },
"to": [{ "apple_vendor_top_case_key_code": "keyboard_fn" }]
},
{
"from": { "key_code": "left_option" },
"to": [{ "key_code": "left_control" }]
},
{
"from": { "key_code": "right_command" },
"to": [{ "key_code": "right_option" }]
},
{
"from": { "key_code": "right_control" },
"to": [{ "key_code": "right_command" }]
},
{
"from": { "key_code": "right_option" },
"to": [{ "key_code": "right_control" }]
}
]
},
{
"identifiers": {
"is_keyboard": true,
"product_id": 49948,
"vendor_id": 1133
},
"ignore_vendor_events": true,
"simple_modifications": [
{
"from": { "key_code": "application" },
"to": [{ "apple_vendor_top_case_key_code": "keyboard_fn" }]
},
{
"from": { "key_code": "left_command" },
"to": [{ "key_code": "left_control" }]
},
{
"from": { "key_code": "left_control" },
"to": [{ "key_code": "left_command" }]
},
{
"from": { "key_code": "right_command" },
"to": [{ "key_code": "right_control" }]
},
{
"from": { "key_code": "right_control" },
"to": [{ "key_code": "right_command" }]
}
]
},
{
"identifiers": {
"is_pointing_device": true,
"product_id": 50498,
"vendor_id": 1133
},
"ignore": false,
"ignore_vendor_events": true,
"mouse_flip_horizontal_wheel": true,
"mouse_flip_vertical_wheel": true
}
],
"name": "Default profile",
"selected": true,
"virtual_hid_keyboard": { "keyboard_type_v2": "ansi" }
}
]
}