gpt4 book ai didi

macos - 从 Mac OS 终端使屏幕闪烁

转载 作者:行者123 更新时间:2023-12-05 01:02:55 33 4
gpt4 key购买 nike

我使用不同的构建脚本来打包我的应用程序。其中一些运行了一段时间,如果有一个视觉通知脚本已经准备好了,那就太好了。

我已经使用带有 Apple 脚本的通知中心,但它还不够令人担忧。是否可以运行 Applescript 或命令行命令让屏幕闪烁。一个优点是以不同的颜色闪烁(绿色表示正常,红色表示构建失败)。

最佳答案

我有几个想法...

最简单:

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

tput bel

最酷:

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

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

enter image description here enter image description here

关于macos - 从 Mac OS 终端使屏幕闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24588065/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com