Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. # This script starts a screencast
  4. DISPLAY="$(~/.local/share/bin/select_focused.sh)"
  5.  
  6. [ "$#" -ne 1 ] && printf "Expected an argument.\n"
  7.  
  8. rec-status() {
  9. [ "$(pidof wf-recorder)" ] && \
  10. printf "RECORDING ACTIVE" || \
  11. printf "recording inactive"
  12. exit 0
  13. }
  14.  
  15. rec-start() {
  16. [ "$(pidof wf-recorder)" ] && \
  17. notify-send -t 1500 "Error: screencast already running" && exit 1
  18.  
  19. notify-send -t 1500 "Starting screencast on $DISPLAY"
  20. wf-recorder -o "$DISPLAY" -f "$HOME/Videos/screencast-$(date +%Y%m%d%h%m).mp4"
  21. }
  22.  
  23. rec-stop() {
  24. [ ! "$(pidof wf-recorder)" ] && \
  25. notify-send -t 1500 "Error: no active screencast to terminate" && exit 1
  26.  
  27. kill -2 $(pidof wf-recorder)
  28. notify-send -t 1500 "Stoped screencast"
  29. exit 0
  30.  
  31. }
  32.  
  33. # Validate user input
  34. if [ "$1" = "start" ]; then
  35. rec-start && exit 0 || exit 1
  36. elif [ "$1" = "stop" ]; then
  37. rec-stop && exit 0 || exit 1
  38. elif [ "$1" = "status" ]; then
  39. rec-status && exit 0 || exit 1
  40. else
  41. printf "ERROR: \"$1\" is not a valid argument.\n" && exit 1
  42. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement