初始化项目

This commit is contained in:
sugood 2020-10-09 17:36:23 +08:00
commit 0466ba9565
11 changed files with 729 additions and 0 deletions

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 greyby
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

77
README.md Normal file
View File

@ -0,0 +1,77 @@
# Hammerspoon Configuration
## Usage
1. Install [Hammerspoon](http://www.hammerspoon.org/)
2. `git clone https://github.com/sugood/hammerspoon.git ~/.hammerspoon`
## Modifier keys
| | Key |
| --------- | -------------- |
| <kbd></kbd> | Shift |
| <kbd></kbd> | Control |
| <kbd></kbd> | Option |
| <kbd></kbd> | Command |
## Features
### Window Management
#### Split Screen Actions
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> Left half
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> Right half
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> Top half
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> Bottom half
#### Quarter Screen Actions
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> Left top quarter
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> Right bottom quarter
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> Right top quarter
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> Left bottom quarter
#### Multiple Monitor
##### Move Cursor
* <kbd></kbd><kbd></kbd> + <kbd></kbd> Move cursor to next monitor
* <kbd></kbd><kbd></kbd> + <kbd></kbd> Move cursor to previous monitor
##### Move Windows
* <kbd></kbd><kbd></kbd> + <kbd></kbd> Move active window to previous monitor
* <kbd></kbd><kbd></kbd> + <kbd></kbd> Move active window to next monitor
* <kbd></kbd><kbd></kbd> + <kbd>1</kbd> Move active window to monitor 1 and maximize the window
* <kbd></kbd><kbd></kbd> + <kbd>2</kbd> Move active window to monitor 2 and maximize the window
#### Other
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd>F</kbd> Full Screen
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd>M</kbd> Maximize Window
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd>C</kbd> Window Center
* <kbd></kbd><kbd></kbd> + <kbd>H</kbd> Switch active window
* <kbd></kbd><kbd></kbd> + <kbd>/</kbd> Display a keyboard hint for switching focus to each window
### System Tools
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd>L</kbd> Lock Screen
### Launch Application
* <kbd></kbd><kbd></kbd> + <kbd>I</kbd> `IntelliJ IDEA`
* <kbd></kbd><kbd></kbd> + <kbd>T</kbd> `Terminal`
* <kbd></kbd><kbd></kbd> + <kbd>Z</kbd> `Calculator`
* <kbd></kbd><kbd></kbd> + <kbd>D</kbd> `Finder`
* <kbd></kbd><kbd></kbd> + <kbd>Q</kbd> `Activity Monitor`
* <kbd></kbd><kbd></kbd> + <kbd>S</kbd> `System Preferences`
* <kbd></kbd><kbd></kbd> + <kbd>C</kbd> `Google Chrome`
* <kbd></kbd><kbd></kbd> + <kbd>A</kbd> `Launchpad`
### Snippet & Memorandum
* <kbd></kbd><kbd></kbd> + <kbd>A</kbd> Add a snippet or memorandum
* <kbd></kbd><kbd></kbd> + <kbd>V</kbd> List snippet or memos and use them

75
README_zh-CN.md Normal file
View File

@ -0,0 +1,75 @@
# Hammerspoon 配置
## 使用方法
1. 安装 [Hammerspoon](http://www.hammerspoon.org/)
2. `git clone https://github.com/greyby/hammerspoon.git ~/.hammerspoon`
## 快捷键图标
| | 键位 |
| --------- | -------------- |
| <kbd></kbd> | Shift |
| <kbd></kbd> | Control |
| <kbd></kbd> | Option |
| <kbd></kbd> | Command |
## 功能
### 窗口管理
#### 1/2 屏幕
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前窗口移动到左半屏
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前窗口移动到右半屏
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前窗口移动到上半屏
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前窗口移动到下半屏
#### 1/4 屏幕
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前窗口移动到左上 1/4 屏
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前窗口移动到右下 1/4 屏
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前窗口移动到右上 1/4 屏
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前窗口移动到左下 1/4 屏
#### 多个显示器
##### 移动光标
* <kbd></kbd><kbd></kbd> + <kbd></kbd> 把光标移动到下一个显示器
* <kbd></kbd><kbd></kbd> + <kbd></kbd> 把光标移动到上一个显示器
##### 移动窗口
* <kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前活动窗口移动到上一个显示器
* <kbd></kbd><kbd></kbd> + <kbd></kbd> 将当前活动窗口移动到下一个显示器
* <kbd></kbd><kbd></kbd> + <kbd>1</kbd> 将当前活动窗口移动到第一个显示器并窗口最大化
* <kbd></kbd><kbd></kbd> + <kbd>2</kbd> 将当前活动窗口移动到第二个显示器并窗口最大化
#### 其它
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd>F</kbd> 全屏
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd>M</kbd> 最大化窗口
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd>C</kbd> 将窗口放到中间
* <kbd></kbd><kbd></kbd> + <kbd>H</kbd> 切换活动窗口
* <kbd></kbd><kbd></kbd> + <kbd>/</kbd> 显示窗口切换的快捷键
### 系统工具
* <kbd></kbd><kbd></kbd><kbd></kbd> + <kbd>L</kbd> 锁屏
### 快速启动
* <kbd></kbd><kbd></kbd> + <kbd>I</kbd> `IntelliJ IDEA`
* <kbd></kbd><kbd></kbd> + <kbd>T</kbd> `Terminal`
* <kbd></kbd><kbd></kbd> + <kbd>Z</kbd> `Calculator`
* <kbd></kbd><kbd></kbd> + <kbd>D</kbd> `Finder`
* <kbd></kbd><kbd></kbd> + <kbd>Q</kbd> `Activity Monitor`
* <kbd></kbd><kbd></kbd> + <kbd>S</kbd> `System Preferences`
* <kbd></kbd><kbd></kbd> + <kbd>C</kbd> `Google Chrome`
* <kbd></kbd><kbd></kbd> + <kbd>A</kbd> `Launchpad`
### 片段和备忘录
* <kbd></kbd><kbd></kbd> + <kbd>A</kbd> 添加一个片段或者备忘
* <kbd></kbd><kbd></kbd> + <kbd>V</kbd> 列出片段或备忘录并使用

146
history.json Normal file
View File

@ -0,0 +1,146 @@
[
{
"subText" : "cmd|cat filename|显示或连接文件",
"text" : "cat"
},
{
"subText" : "cmd|cd dirname|打开当前目录",
"text" : "cd"
},
{
"subText" : "cmd|chgrp staff filename|改变文件或目录的所属组",
"text" : "chgrp"
},
{
"subText" : "cmd|chmod -R 777 filename|改变文件或目录的权限",
"text" : "chmod"
},
{
"subText" : "cmd|chown newowner:newowner filename|改变文件或目录的属主",
"text" : "chown"
},
{
"subText" : "cmd|clear|清屏",
"text" : "clear"
},
{
"subText" : "cmd|cp file1 file2|复制文件或目录",
"text" : "cp"
},
{
"subText" : "cmd|date|显示系统的当前日期和时间",
"text" : "date"
},
{
"subText" : "cmd|diff file1 file2|比较并显示两个文件的差异",
"text" : "diff"
},
{
"subText" : "cmd|kill -9 pid|终止进程",
"text" : "kill"
},
{
"subText" : "cmd|ln -s file1 file2|联接文件",
"text" : "ln"
},
{
"subText" : "cmd|ls -l|显示当前目录的内容",
"text" : "ls"
},
{
"subText" : "cmd|lsof -i:port|查看端口",
"text" : "lsof"
},
{
"subText" : "cmd|mkdir dirname|创建一个目录",
"text" : "mkdir"
},
{
"subText" : "cmd|mv file1 file2|移动文件名或目录、重命名",
"text" : "mv"
},
{
"subText" : "cmd|passwd|修改用户密码",
"text" : "passwd"
},
{
"subText" : "cmd|ping ip|给一个网络主机发送 回应请求",
"text" : "ping"
},
{
"subText" : "cmd|ps u|显示进程当前状态",
"text" : "ps"
},
{
"subText" : "cmd|reboot|重启电脑",
"text" : "reboot"
},
{
"subText" : "cmd|rm -rf filename|删除文件或目录",
"text" : "rm"
},
{
"subText" : "cmd|rmdir dirname|删除一个目录",
"text" : "rmdir"
},
{
"subText" : "cmd|scp -r \/Users\/test username@ip:\/root|从本地将文件夹传输到服务器",
"text" : "scp -r"
},
{
"subText" : "cmd|scp -r username@ip:\/data\/test \/Users\/mac\/Desktop|将服务器上的文件夹传输到本地",
"text" : "scp -r username"
},
{
"subText" : "cmd|scp \/Users\/mac\/test.png username@ip:\/root |从本地将文件传输到服务器",
"text" : "scp"
},
{
"subText" : "cmd|scp username@ip:\/data\/111.png \/Users\/mac\/Desktop|将服务器上的文件传输到本地",
"text" : "scp username"
},
{
"subText" : "cmd|source ~\/.bash_profile|使环境变量生效",
"text" : "source ~\/.bash_profile"
},
{
"subText" : "cmd|ssh username@ip|ssh远程登录",
"text" : "ssh"
},
{
"subText" : "cmd|tail -f file|显示文件的最后几行、实时查看日志文件",
"text" : "tail"
},
{
"subText" : "cmd|tar xvf filename.tar|解压格式tar",
"text" : "tar"
},
{
"subText" : "cmd|telnet ip port|远程连接,需要先安装telnet",
"text" : "telnet"
},
{
"subText" : "cmd|vi ~\/.bash_profile|修改环境变量",
"text" : "vi ~\/.bash_profile"
},
{
"subText" : "code|java|author注释模板",
"text" : "\/** \n* @Title: ${file_name} \n* @Package ${package_name} \n* @Description: ${todo}(用一句话描述该文件做什么) \n* @author sugood\n* @date ${date} ${time} \n* @version V1.0 \n*\/"
},
{
"subText" : "code|java|author注释模板",
"text" : "something"
},
{
"subText" : "key|Command+Option+C|复制路径",
"text" : "Command+Option+C"
},
{
"subText" : "key|Command+Q|关闭程序",
"text" : "Command+Q"
},
{
"subText" : "key|Command+Shift+.|显示隐藏文件",
"text" : "Command+Shift+."
}
]

6
init.lua Normal file
View File

@ -0,0 +1,6 @@
require "modules/reload"
require "modules/hotkey"
require "modules/system"
require "modules/windows"
require "modules/launcher"
require "modules/snippet"

4
modules/hotkey.lua Normal file
View File

@ -0,0 +1,4 @@
hyper = {"cmd", "ctrl", "alt"}
hyperShift = {"alt", "shift"}
hyperCtrl = {"alt", "ctrl"}
hyperAlt = {"ctrl", "alt", "shift"}

45
modules/launcher.lua Normal file
View File

@ -0,0 +1,45 @@
local hotkey = require "hs.hotkey"
local grid = require "hs.grid"
local window = require "hs.window"
local application = require "hs.application"
local appfinder = require "hs.appfinder"
local fnutils = require "hs.fnutils"
grid.setMargins({0, 0})
applist = {
{shortcut = 'I',appname = 'IntelliJ IDEA'},
{shortcut = 'T',appname = 'Terminal'},
{shortcut = 'Z',appname = 'Calculator'},
{shortcut = 'D',appname = 'Finder'},
{shortcut = 'Q',appname = 'Activity Monitor'},
{shortcut = 'S',appname = 'System Preferences'},
{shortcut = 'C',appname = 'Google Chrome'},
{shortcut = 'A',appname = 'Launchpad'},
}
fnutils.each(applist, function(entry)
hotkey.bind({'ctrl', 'shift'}, entry.shortcut, entry.appname, function()
application.launchOrFocus(entry.appname)
-- toggle_application(applist[i].appname)
end)
end)
-- Toggle an application between being the frontmost app, and being hidden
function toggle_application(_app)
local app = appfinder.appFromName(_app)
if not app then
application.launchOrFocus(_app)
return
end
local mainwin = app:mainWindow()
if mainwin then
if mainwin == window.focusedWindow() then
mainwin:application():hide()
else
mainwin:application():activate(true)
mainwin:application():unhide()
mainwin:focus()
end
end
end

18
modules/reload.lua Normal file
View File

@ -0,0 +1,18 @@
local pathwatcher = require "hs.pathwatcher"
local alert = require "hs.alert"
-- http://www.hammerspoon.org/go/#fancyreload
function reloadConfig(files)
doReload = false
for _, file in pairs(files) do
if file:sub(-4) == ".lua" then
doReload = true
end
end
if doReload then
hs.reload()
end
end
pathwatcher.new(os.getenv("HOME") .. "/.hammerspoon", reloadConfig):start()
alert.show("Hammerspoon Config Reloaded")

150
modules/snippet.lua Normal file
View File

@ -0,0 +1,150 @@
local chooser = require("hs.chooser")
local console = require("hs.console")
console.clearConsole()
local historyPath= "~/.hammerspoon/history.json"
local maxLength = 1000
local history = {}
function initData()
if hs.json.read(historyPath) ~= nil then
history = hs.json.read(historyPath)
end
end
-- 初始化,读取本地数据
initData()
-- 查重
function duplicate(tablea,keys)
for k,v in ipairs(tablea) do
if v.text == keys then
return true
end
end
return false
end
-- 清除收尾空格
function trim(input)
return (string.gsub(input, "^%s*(.-)%s*$", "%1"))
end
-- 字符串分割
string.split = function(s, p)
local rt= {}
string.gsub(s, '[^'..p..']+', function(w) table.insert(rt, w) end )
return rt
end
-- 添加片段到记录列表中
function addToHistory()
local item = {}
local str = hs.pasteboard.getContents()
if str == nil then
hs.alert.show("文本为空,请重新选择文本!")
end
local list = string.split(str, "|")
if #list >1 then
item.subText = trim(string.sub(str,#list[1]+2,string.len(str)))
item.text = trim(list[1])
else
item.subText = trim(list[1])
item.text = trim(list[1])
end
if duplicate(history, item.text) then
hs.alert.show("片段已经存在")
return
end
if #history >= maxLength then
hs.alert.show("片段已超过:"..maxLength.."")
return
end
table.insert(history, 1, item)
-- 排序
table.sort(history,function(a,b) return a.subText<b.subText end )
hs.json.write(history,historyPath, true, true)
hs.alert.show("成功添加片段:"..item.text)
end
-- 按下添加快捷键时映射到复制快捷键
function bindCopyKey()
hs.eventtap.keyStroke({ "cmd" }, "C")
end
-- 粘贴选中的片段
local completionFn = function(result)
if result then
hs.pasteboard.setContents(result.text)
hs.eventtap.keyStroke({ "cmd" }, "V")
print("keywords:"..result.text)
end
end
-- 添加片段到记录列表中
function modifyHistory(text, subText, isText, index)
if text and subText then
if isText and duplicate(history, text) then
hs.alert.show("片段已经存在")
return
end
history[index].text = text
history[index].subText = subText
-- 排序
table.sort(history,function(a,b) return a.subText<b.subText end )
hs.json.write(history,historyPath, true, true)
if isText then
hs.alert.show("成功修改片段内容:"..text)
else
hs.alert.show("成功修改片段说明:"..subText)
end
else
hs.alert.show("参数错误")
return
end
end
-- 右键弹出菜单
local menuFn = function(index)
if index then
menubar = hs.menubar.new(false)
menubar:setTitle("Hidden Menu")
menubar:setMenu( {
{ title = "菜单", fn = function() print("you clicked my menu item!") end },
{ title = "-" },
{ title = "修改片段内容", fn = function()
result,text = hs.dialog.textPrompt("修改片段内容", "请输入新的内容", history[index].text, "确定", "取消")
if result == "确定" then
modifyHistory(text,history[index].subText,true,index)
end
end },
{ title = "修改片段说明", fn = function()
result,subText = hs.dialog.textPrompt("修改片段说明", "请输入新的说明", history[index].subText, "确定", "取消")
if result == "确定" then
modifyHistory(history[index].text,subText,false,index)
end
end },
{ title = "-" },
{ title = "删除当前片段", fn = function()
if hs.dialog.blockAlert("确定删除以下片段?",history[index].text,"确定","取消","informational") == "确定" then
table.remove(history,index)
hs.json.write(history,historyPath, true, true)
hs.alert.show("成功删除片段")
end
end },
})
menubar:popupMenu(hs.mouse.getAbsolutePosition(), true)
else
hs.alert.show("错误")
end
end
-- 选取片段内容(按下快捷键时显示片段列表,点击选中的快捷键将自动粘贴)
hs.hotkey.bind({ "ctrl", "cmd" }, "V", function ()
chooser.new(completionFn)
:choices(history)
:rightClickCallback(menuFn)
:searchSubText(true)
:show()
end)
-- 添加片段(按下快捷键时做一个复制操作,并记录复制的内容到片段列表中)
hs.hotkey.bind({"ctrl", "cmd"}, "A", function ()
bindCopyKey()
if hs.dialog.blockAlert("添加片段:‘|’为分隔符,建议按如下格式","内容|keyword|示例|说明","确定","取消","informational") == "确定" then
addToHistory()
end
end)

18
modules/system.lua Normal file
View File

@ -0,0 +1,18 @@
local hotkey = require "hs.hotkey"
local caffeinate = require "hs.caffeinate"
local audiodevice = require "hs.audiodevice"
hotkey.bind(hyper, "L", function()
caffeinate.lockScreen()
-- caffeinate.startScreensaver()
end)
-- mute on sleep
function muteOnWake(eventType)
if (eventType == caffeinate.watcher.systemDidWake) then
local output = audiodevice.defaultOutputDevice()
output:setMuted(true)
end
end
caffeinateWatcher = caffeinate.watcher.new(muteOnWake)
caffeinateWatcher:start()

169
modules/windows.lua Normal file
View File

@ -0,0 +1,169 @@
-- window management
local application = require "hs.application"
local hotkey = require "hs.hotkey"
local window = require "hs.window"
local layout = require "hs.layout"
local grid = require "hs.grid"
local hints = require "hs.hints"
local screen = require "hs.screen"
local alert = require "hs.alert"
local fnutils = require "hs.fnutils"
local geometry = require "hs.geometry"
local mouse = require "hs.mouse"
-- default 0.2
window.animationDuration = 0
-- left half
hotkey.bind(hyper, "Left", function()
if window.focusedWindow() then
window.focusedWindow():moveToUnit(layout.left50)
else
alert.show("No active window")
end
end)
-- right half
hotkey.bind(hyper, "Right", function()
window.focusedWindow():moveToUnit(layout.right50)
end)
-- top half
hotkey.bind(hyper, "Up", function()
window.focusedWindow():moveToUnit'[0,0,100,50]'
end)
-- bottom half
hotkey.bind(hyper, "Down", function()
window.focusedWindow():moveToUnit'[0,50,100,100]'
end)
-- left top quarter
hotkey.bind(hyperAlt, "Left", function()
window.focusedWindow():moveToUnit'[0,0,50,50]'
end)
-- right bottom quarter
hotkey.bind(hyperAlt, "Right", function()
window.focusedWindow():moveToUnit'[50,50,100,100]'
end)
-- right top quarter
hotkey.bind(hyperAlt, "Up", function()
window.focusedWindow():moveToUnit'[50,0,100,50]'
end)
-- left bottom quarter
hotkey.bind(hyperAlt, "Down", function()
window.focusedWindow():moveToUnit'[0,50,50,100]'
end)
-- full screen
hotkey.bind(hyper, 'F', function()
window.focusedWindow():toggleFullScreen()
end)
-- center window
hotkey.bind(hyper, 'C', function()
window.focusedWindow():centerOnScreen()
end)
-- maximize window
hotkey.bind(hyper, 'M', function() toggle_maximize() end)
-- defines for window maximize toggler
local frameCache = {}
-- toggle a window between its normal size, and being maximized
function toggle_maximize()
local win = window.focusedWindow()
if frameCache[win:id()] then
win:setFrame(frameCache[win:id()])
frameCache[win:id()] = nil
else
frameCache[win:id()] = win:frame()
win:maximize()
end
end
-- display a keyboard hint for switching focus to each window
hotkey.bind(hyperShift, '/', function()
hints.windowHints()
-- Display current application window
-- hints.windowHints(hs.window.focusedWindow():application():allWindows())
end)
-- switch active window
hotkey.bind(hyperShift, "H", function()
window.switcher.nextWindow()
end)
-- move active window to previous monitor
hotkey.bind(hyperShift, "Left", function()
window.focusedWindow():moveOneScreenWest()
end)
-- move active window to next monitor
hotkey.bind(hyperShift, "Right", function()
window.focusedWindow():moveOneScreenEast()
end)
-- move cursor to previous monitor
hotkey.bind(hyperCtrl, "Right", function ()
focusScreen(window.focusedWindow():screen():previous())
end)
-- move cursor to next monitor
hotkey.bind(hyperCtrl, "Left", function ()
focusScreen(window.focusedWindow():screen():next())
end)
--Predicate that checks if a window belongs to a screen
function isInScreen(screen, win)
return win:screen() == screen
end
function focusScreen(screen)
--Get windows within screen, ordered from front to back.
--If no windows exist, bring focus to desktop. Otherwise, set focus on
--front-most application window.
local windows = fnutils.filter(
window.orderedWindows(),
fnutils.partial(isInScreen, screen))
local windowToFocus = #windows > 0 and windows[1] or window.desktop()
windowToFocus:focus()
-- move cursor to center of screen
local pt = geometry.rectMidPoint(screen:fullFrame())
mouse.setAbsolutePosition(pt)
end
-- maximized active window and move to selected monitor
moveto = function(win, n)
local screens = screen.allScreens()
if n > #screens then
alert.show("Only " .. #screens .. " monitors ")
else
local toWin = screen.allScreens()[n]:name()
alert.show("Move " .. win:application():name() .. " to " .. toWin)
layout.apply({{nil, win:title(), toWin, layout.maximized, nil, nil}})
end
end
-- move cursor to monitor 1 and maximize the window
hotkey.bind(hyperShift, "1", function()
local win = window.focusedWindow()
moveto(win, 1)
end)
hotkey.bind(hyperShift, "2", function()
local win = window.focusedWindow()
moveto(win, 2)
end)
hotkey.bind(hyperShift, "3", function()
local win = window.focusedWindow()
moveto(win, 3)
end)