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

查看:632
本文介绍了请从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.

我已经使用了与苹果脚本的通知中心,但它的东西是不是足够惊人。是否有可能运行和AppleScript或命令行命令来让屏幕闪烁。 A加会用不同的颜色(绿色为正常,红色为构建失败)闪烁。

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).

推荐答案

我有几个想法......

I have a couple of ideas...

最简单的:

转到终端 - > preferences->高级,并更改为视觉贝尔然后执行

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

tput bel

最酷的:

下面是一个小素文字我写保存当前的桌面背景,然后将其设置为绿色3秒钟,然后复位它回到它是什么。当然,如果你喜欢它,你可以把它做红色只是失败pretty。所有你需要做的是保存red.jpg及以下免费,JPG文件在/库/桌面图片文件夹,red.jpg和green.jpg。然后保存以下脚本,如通知并使其可执行:

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天全站免登陆