当我接到电话时,如何让 Skype 运行命令?

7 sound skype hdmi

我想让我的基于 Linux 的机器在 Skype 接到电话时运行一个命令。这可能吗?

用例:将 HDMI 音频用于 Raspberry Pi,但通过模拟插孔播放通知音频,以防电视在 HDMI 开关上使用不同的 HDMI 设备。

小智 1

实现此目的的一种Hack 式方法是找出有来电时出现的窗口标题,并使用 wmctrl 检查是否存在这样的窗口。

您可以编写一个脚本,然后使用 cron 或您自己的逻辑以固定的时间间隔运行该脚本。

我不知道 Skype 来电窗口标题的格式,但整体脚本可能是这样的(如果用 python 编写)

#!/usr/bin/python
import subprocess

# Change below line according to skype window title
# You might need to use regex in case the title has usernames 
command = r"wmctrl -xl | grep 'Skype - Incoming'"
output = system.exec_command(command, getOutput=True)

if output != "":
    # Play sound here
    pass
Run Code Online (Sandbox Code Playgroud)