How to make a script toggle between two commands when it is executed?
-2
votes
1
answer
1204
views
I am trying to write a script file and invoke it using XFCE global shortcut. The script should continue the Audacity application if it is in the stopped state and stop it (pause recording) if it is in the run state. This will be useful when I have defined the same keyboard shortcut for VLC's playback/pause. This way, I can do playback/pause (in VLC) and record/pause (in Audacity) at the same time using the same keyboard shortcut. Getting some ideas from [this post](https://askubuntu.com/questions/855893/is-it-possible-to-control-the-recording-if-audacity-is-running-in-the-background) I have written the following script and added it to XFCE's custom keyboard settings. But it does not work.
#!/bin/bash
if pgrep -f "audacity" ;
then
pkill -stop audacity && notify-send "Recording stopped"
else
pkill -cont audacity
Asked by Mehdi Haghgoo
(583 rep)
Jan 7, 2017, 06:22 PM
Last activity: Jan 7, 2017, 10:28 PM
Last activity: Jan 7, 2017, 10:28 PM