使用slate快捷控制窗口

我在开发和日常使用都会有一些快速控制窗口的需求,尤其是使用大屏幕,这种需求更多。比如将一个网页快速行程左右各占一半的两个网页,比如将屏幕缩小到1/4放在某个角度,比如全屏和居中,比如快速将应用移到下一个显示器。

之前用了一款软件sizeup来实现,但是这货用了一段时间偶尔会弹出purchse,而且自定义有限。最后在各种搜索求教下找到了slate

slate是一个免费开源软件,但是没有gui窗口进行具体的配置,必须通过配置文件来实现控制,配置文件放在个人目录的~/.slate位置,通过配置就可以很快做到很方便的快捷控制,所以最强大的地方也就在把玩配置。

配置

它的配置基本分为以下几种:

  • config (全局内置的设置)
  • alias (将一些数值做个名称保存)
  • layout (布局)
  • default (默认布局配置)
  • bind (快捷键绑定)
  • source (配置引用)

功能

使用它的配置可以做到:

  • 窗口缩放和自定义尺寸
  • 窗口位置
  • 定义布局方式
  • 指定应用默认打开布局
  • 很强大的自定义快捷键
  • 多个显示器切换

更多

  • slate也有一些简单的配置来控制开机启动和menu bar
  • slate是开源的,代码托管在github上。https://github.com/jigish/slate
  • slate配置应该可以有很多玩法,有时间的同学可以自己玩玩。

最后附上我简单的配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Config
config defaultToCurrentScreen true
config windowHintsFontSize 200
config nudgePercentOf screenSize
config resizePercentOf screenSize
config windowHintsTopLeftX (windowSizeX/2)-(windowHintsWidth/2)
config windowHintsTopLeftY (windowSizeY/2)-(windowHintsHeight/2)

# General aliases
alias sox screenOriginX
alias soy screenOriginY
alias ssx screenSizeX
alias ssy screenSizeY

# Position aliases
alias centered ${sox}+${ssx}/8;${soy}+${ssy}/8 ${ssx}/8*6;${ssy}/8*6
alias fullscreen ${sox};${soy} ${ssx};${ssy}
alias leftHalf ${sox};${soy} ${ssx}/2;${ssy}
alias bottomHalf ${sox};${soy}+${ssy}/2 ${ssx};${ssy}/2
alias topHalf ${sox};${soy} ${ssx};${ssy}/2
alias rightHalf ${sox}+${ssx}/2;${soy} ${ssx}/2;${ssy}
alias topLeftQuarter ${sox};${soy} ${ssx}/2;${ssy}/2
alias topRightQuarter ${sox}+${ssx}/2;${soy} ${ssx}/2;${ssy}/2
alias bottomLeftQuarter ${sox};${soy}+${ssy}/2 ${ssx}/2;${ssy}/2
alias bottomRightQuarter ${sox}+${ssx}/2;${soy}+${ssy}/2 ${ssx}/2;${ssy}/2

# Bindings
bind c:cmd;ctrl;alt move ${centered}
bind m:cmd;ctrl;alt move ${fullscreen}
bind left:cmd;alt move ${leftHalf}
bind down:cmd;alt move ${bottomHalf}
bind up:cmd;alt move ${topHalf}
bind right:cmd;alt move ${rightHalf}
bind left:cmd;ctrl;alt move ${topLeftQuarter}
bind up:cmd;ctrl;alt move ${topRightQuarter}
bind down:cmd;ctrl;alt move ${bottomLeftQuarter}
bind right:cmd;ctrl;alt move ${bottomRightQuarter}

# Resize Bindings
bind right:alt;ctrl       resize +20% +0
bind left:alt;ctrl        resize -20% +0
bind up:alt;ctrl          resize +0   -20%
bind down:alt;ctrl        resize +0   +20%

# Nudge Bindings
bind right:shift;alt nudge +20% +0
bind left:shift;alt  nudge -20% +0
bind up:shift;alt    nudge +0   -20%
bind down:shift;alt  nudge +0   +20%

# Throw Bindings
bind 1:ctrl;alt         throw 0 resize
bind 2:ctrl;alt         throw 1 resize
bind 3:ctrl;alt         throw 2 resize

# Window Hints
bind esc:cmd hint

Comments