ors*_*iro 5 command-line shortcut-keys audacity audio-recording
我想在 Audacity 在后台运行时录制音频,例如因为我专注于另一个窗口。是否可以使用全局键盘快捷键控制录制的开始和停止?
不幸的是,查看man audacity, 并没有显示任何有趣或相关的选项:
OPTIONS
-help display a brief list of command line options
-version display the audacity version number
-test run self diagnostics tests (only present in development
builds)
-blocksize nnn
set the audacity block size for writing files to disk to nnn
bytes
Run Code Online (Sandbox Code Playgroud)
简单地暂停/继续 cli 中的 Audacity 与暂停/继续录音的工作方式完全相似
我使用命令kill -stop <pid>和kill -cont <pid>. 它完美地完成了工作;它立即停止记录,并在该过程继续时立即恢复。即使在 6 或 7 小时后,它也会立即使用这些命令停止/恢复录制。
将这两个命令添加到快捷键完全符合您的描述。
将以下两个命令添加到快捷键中:
/bin/bash -c "kill -stop $(pgrep audacity)"
Run Code Online (Sandbox Code Playgroud)
...停止(暂停)录音,以及
/bin/bash -c "kill -cont $(pgrep audacity)"
Run Code Online (Sandbox Code Playgroud)
...恢复,您有自己的快捷键来开始/停止(实际上是暂停)录制。
只需通过 Audacity GUI 完成录制的初始启动。
选择:系统设置>“键盘”>“快捷方式”>“自定义快捷方式”。单击“+”并将上面的两个命令添加到两个不同的快捷键。
当然我们可以扩展选项,例如
/bin/bash -c "kill -cont $(pgrep audacity) && notify-send Recording"
Run Code Online (Sandbox Code Playgroud)
和
/bin/bash -c "kill -stop $(pgrep audacity) && notify-send Stopped"
Run Code Online (Sandbox Code Playgroud)
...显示当前状态的通知,甚至制作面板图标来显示当前状态。一切皆有可能
下面的脚本将切换录制。将其添加到快捷键或以任何其他方式启动它。
该脚本从文件中读取当前进程状态/proc/<pid>/status,并因此决定目标状态应该是什么。
此外,脚本会通知用户通知中发生的事情(使用notify-send)。
OPTIONS
-help display a brief list of command line options
-version display the audacity version number
-test run self diagnostics tests (only present in development
builds)
-blocksize nnn
set the audacity block size for writing files to disk to nnn
bytes
Run Code Online (Sandbox Code Playgroud)
toggle_record.py使用以下命令测试运行它:
python3 /path/to/toggle_record.py
Run Code Online (Sandbox Code Playgroud)如果一切正常,请将其添加到快捷键中,如前面的答案所述。