MacOs 安装 HammerSpoon 窗口全屏、2分屏、4分屏
2023-09-14 09:09:53 时间
1,安装HammerSpoon
- Hammerspoon-0.9.73.zip 解压,把Hammerspoon移动到应用程序
2,配置HammerSpoon
$ cd ~/.hammerspoon/
$ vim init.lua
- 目录结构
├── init.lua
└── modules
├── hotkey.lua
└── windows.lua
- init.lua配置
require "modules/hotkey"
require "modules/windows"
- hotkey.lua配置
hyper = {"ctrl","cmd"}
- windows.lua配置
require "hs.application"
local hotkey = require "hs.hotkey"
local window = require "hs.window"
-- 屏幕显示Hello world
hotkey.bind(hyper, "h", function()
hs.alert("Hello World")
end)
-- 通知中心弹出Hello Hammerspoon!
hotkey.bind(hyper, "t", function()
hs.notify.new({title="Hammerspoon", informativeText="Hello Hammerspoon!"}):send()
end)
-- 当前窗口全屏
hs.hotkey.bind(hyper, 'up', function()
hs.grid.maximizeWindow()
end)
-- 当前窗口 2分屏 宽度1/2 左分屏
hs.hotkey.bind(hyper, "Left", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h
win:setFrame(f)
end)
-- 当前窗口 2分屏 宽度1/2 右分屏
hs.hotkey.bind(hyper, "Right", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w/2
f.y = max.y
f.w = max.w / 2
f.h = max.h
win:setFrame(f)
end)
-- 当前窗口 4分屏 宽度1/2 高度1/2 左上分屏
hs.hotkey.bind(hyper,"1", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
-- 当前窗口 4分屏 宽度1/2 高度1/2 左下分屏
hs.hotkey.bind(hyper,"2", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x
f.y = max.y + max.h/2
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
-- 当前窗口 4分屏 宽度1/2 高度1/2 右上分屏
hs.hotkey.bind(hyper,"3", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w/2
f.y = max.y
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
-- 当前窗口 4分屏 宽度1/2 高度1/2 右下分屏
hs.hotkey.bind(hyper,"4", function()
local win = hs.window.focusedWindow()
local f = win:frame()
local screen = win:screen()
local max = screen:frame()
f.x = max.x + max.w/2
f.y = max.y + max.h/2
f.w = max.w / 2
f.h = max.h / 2
win:setFrame(f)
end)
2,窗口分屏快捷键
快捷键 | 窗口分屏 |
---|---|
Ctrl + Cmd + ↑ | 全屏 |
Ctrl + Cmd + ← | 2分屏 左分屏 |
Ctrl + Cmd + → | 2分屏 右分屏 |
Ctrl + Cmd + 1 | 4分屏 左上分屏 |
Ctrl + Cmd + 2 | 4分屏 左下分屏 |
Ctrl + Cmd + 3 | 4分屏 右上分屏 |
Ctrl + Cmd + 4 | 4分屏 右下分屏 |
参考:
相关文章
- MacOS安装Eclipse后启动报错:The JVM shared library "/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/../lib/server/libjvm.dylib" does not contain the JNI_CreateJavaVM symbol.
- JStorm-0.9.6.2安装配置
- 1-3python预备知识-Mac 安装ipython以及使用
- macos安装uni-app开发环境(hbuilderx 3.6.18 / macos12.4)
- FastDFS的安装步骤
- Docker - 在Ubuntu18.04中安装Docker CE
- VMware ESXi 6.7在虚拟机中安装macOS 10.13
- macos(big sur/11.1):安装python3(python 3.9.1)
- Atitit 图像处理类库安装与安装模式的前世今生与未来大趋势attilax总结.docx
- 在线安装eclipse中html/jsp/xml editor插件 eclipseeditor
- 已解决苹果MacOS系统安装使用Python和pip工具安装第三方模块
- windows下安装rabbitmq
- proxmox PVE 6.3 虚拟机 安装 黑苹果 macOS Catalina 10.15.5 opencore 引导
- 在fedora23中安装virtualbox, 然后实现虚拟机irtualbox 或者 vmware 下的xp操作系统
- 【云原生 | 02】分别在CentOS、Ubuntu、macOS、win7、win8、win10等不同操作系统下安装Docker详细教程
- macOS PIL 安装
- macOS 安装 gns3
- MacOS 安装 metasploit
- macOS 安装 Burp Suite 并破解
- macOS 安装 aircrack-ng 破解 wifi,hashcat ,OnlineHashCrack,在线破解握手包
- 安装webpack
- Linux软件包管理— rpm包--安装--启动、升级、卸载