我不久前遇到了同样的问题,这就是我所做的:
首先,我已经建议镜像显示器。在做完这个之后不久,我意识到将macbook的点亮屏幕放在眼角是非常分散注意力的。这要求我杀死macbook屏幕上的亮度。但是,作为一个懒惰的人,我讨厌每次取消/插入外接显示器时都必须手动调节亮度。所以我想知道是否有办法自动化这个过程。我找到了这个名为Control Plane的免费应用程序,让我根据某些设备(显示器,硬盘驱动器等)是否插入,某些Wi-Fi网络是否在范围内等设置“上下文”; 并基于这些上下文,运行某些shell脚本。所以我所要做的就是写一个AppleScript(叫做killBrightness.scpt
)杀死macbook屏幕上的亮度和要调用的shell脚本killBrightness.scpt
; 并在所需的上下文中调用此shell脚本。
killBrightness.scpt
tell application "System Preferences" to set current pane to pane "Displays"
tell application "System Events"
tell process "System Preferences"
repeat with theWindow in windows
if title of theWindow as string is "Color LCD" then
tell tab group 1 of theWindow
tell slider 1 of group 2
set value to 0
end tell
end tell
end if
end repeat
end tell
end tell
tell application "System Preferences" to quit
shell脚本
#!/bin/sh
osascript /path/to/killBrightness.scpt
由于我将许多不同的显示器插入我的macbook,我注意到当插入一个具有不同宽高比的显示器时,我的窗口悬挂在屏幕边缘。解决这个问题的方法是调整窗口大小,但是当你像我一样使用大量的应用程序和窗口时效率非常低; 而且,我和我一样懒惰,不喜欢那个解决方案。所以,在Stack Overflow上的优秀人员的帮助下,我能够提出这个AppleScript(被称为resizer.scpt
)来自动调整(几乎)所有应用程序的所有窗口(需要注意的是,某些应用程序不使用正确的UI框架挂钩,所以很难调整它们的大小):
resizer.scpt
:
property blacklist : {"Finder", "Preview", "Console", "AppleScript Editor", "Spotify", "TaskCoach", "Skype", "VirtualBox"}
property buttonApps : {"LyX", "Eclipse"}
property buttonMaps : {{name:"LyX", Button:1, pname:"lyx"}, {name:"Eclipse", Button:2, pname:"eclipse"}, {name:"Spotify", Button:3, pname:"Spotify"}, {name:"TaskCoach", Button:3, pname:"TaskCoach"}}
tell application "Finder" to set theBounds to bounds of window of desktop
tell application "System Events"
set bids to bundle identifier of processes where background only is false
end tell
repeat with bid in bids
tell application id bid
if name is not in blacklist then
set appName to name as string
if name is "Terminal" then
set newBounds to {0, 0, (item 3 of theBounds) - 10, item 4 of theBounds}
repeat with theWindow in windows
if visible of theWindow is true then
set bounds of theWindow to newBounds
end if
end repeat
else if name is not in buttonApps then
try
repeat with theWindow in windows
if visible of theWindow is true then
set bounds of theWindow to theBounds
end if
end repeat
end try
else if name is in buttonApps then
-- get the buttonNumber
repeat with buttonApp in buttonMaps
if (name of buttonApp as string) is appName then
set theButton to Button of buttonApp
end if
end repeat
tell application "System Events"
repeat with theProcess in (processes where bundle identifier is bid)
try
tell theProcess to tell window 1 to click button theButton
end try
end repeat
end tell
end if
end if
end tell
end repeat
现在,我所要做的就是编写一个类似的shell脚本来调用resizer.scpt
并将其放入ControlPlane中,我已经准备好再次懒惰了!
希望这可以帮助
PS:我之前忘了提到所有这些都是在我的15英寸MacBook Pro上完成的,运行Lion