从 Mac OS 终端使屏幕闪烁 [英] Make the screen Flash from Mac OS Terminal

查看:24
本文介绍了从 Mac OS 终端使屏幕闪烁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用不同的构建脚本来打包我的应用程序.其中一些运行了一段时间,如果有脚本准备就绪的视觉通知会很棒.

I using different build scripts for package my apps. Some of them running a while and it would be great to have a visual notification the script is ready.

我已经将通知中心与 Apple Script 一起使用,但它不够令人震惊.是否可以运行 Applescript 或命令行命令来让屏幕闪烁.一个加号是闪烁不同的颜色(绿色表示正常,红色表示构建失败).

I already use the notifications center with an Apple Script but something it is not alarming enough. Is it possible to run and Applescript or a command line command to let the screen flashes. A plus would be to flash in different colors (green for OK and red for build failed).

推荐答案

我有几个想法...

最简单:

转到终端->首选项->高级并更改为Visual Bell然后执行

Go to Terminal->Preferences->Advanced and change to Visual Bell then do

tput bel

最酷:

这是我写的一个小脚本,用于保存当前的桌面背景,然后将其设置为绿色 3 秒钟,然后将其重置为原来的样子.当然,如果你喜欢它,你可以很简单地将它设置为红色以表示失败.您需要做的就是将下面的 red.jpg 和 free,jpg 文件保存在/Library/Desktop Pictures 文件夹中,分别为 red.jpg 和 green.jpg.然后将下面的脚本保存为 notify 并使其可执行:

Here is a little scipt I wrote to save the current Desktop background and then set it to green for 3 seconds and then reset it back to what it was. Of course, if you like it you can make it do red for fail pretty simply. All you need to do is save the red.jpg and free,jpg files below in the /Library/Desktop Pictures folders as red.jpg and green.jpg. Then save the script below as notify and make it executable with:

chmod +x notify

并运行它

./notify

这是脚本:

#!/bin/bash

# Function to save current wallpaper
saveWallpaper(){
osascript<<EOF
tell application "Finder"
    set theDesktopPic to desktop picture
    set theName to displayed name of theDesktopPic
    return theName
end tell
EOF
}

# Function to set the wallpaper
setWallpaper(){
echo $1
osascript<<EOF
set desktopImage to POSIX file "/Library/Desktop Pictures/$1"
tell application "Finder"
    set desktop picture to desktopImage
end tell
EOF
}

# Start of actual script

# Save current wallpaper
saved=$(saveWallpaper)
echo Wallpaper is: $saved

# Set wallpaper to green for 3 seconds
setWallpaper "green.jpg"
sleep 3

# Restore wallpaper
setWallpaper "$saved"

使用一些声音:

为了成功:

osascript -e 'beep 1'

失败:

osascript -e 'beep 3'

或者怎么样:

afplay /System/Library/Sounds/Ping.aiff -v 2

这篇关于从 Mac OS 终端使屏幕闪烁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆