summaryrefslogtreecommitdiff
path: root/toggle-screencast.sh
diff options
context:
space:
mode:
Diffstat (limited to 'toggle-screencast.sh')
-rwxr-xr-xtoggle-screencast.sh39
1 files changed, 28 insertions, 11 deletions
diff --git a/toggle-screencast.sh b/toggle-screencast.sh
index b8050da..0088cea 100755
--- a/toggle-screencast.sh
+++ b/toggle-screencast.sh
@@ -1,12 +1,34 @@
#!/bin/sh
-
-## Config
output_dir=~/videos/screencasts
#sound_device=/dev/dsp4.0
#-thread_queue_size 512 -f oss -i "$sound_device" \
+prompt_transcode() {
+ choice=$(dmenu -p "Transcode now?" << EOF
+no
+yes
+EOF
+ )
+ output_file="$output_dir"/cast_"$(date '+%F-%H-%M-%S')"
+ if [ $choice == "yes" ]
+ then
+ transcode_now "$output_file".mp4
+ else
+ transcode_later "$output_file".mkv
+ fi
+}
+
+transcode_now() {
+ notify-send "Transcoding..." "$1"
+ ffmpeg -i /tmp/cast.mkv "$1" && rm /tmp/cast.mkv
+ notify-send "Transcode done!" "$1"
+}
+
+transcode_later() {
+ mv /tmp/cast.mkv "$1"
+ notify-send "Screencast saved!" "$1"
+}
-## Start recording
start_recording() {
touch /tmp/cast.mkv
notify-send -t 3000 "Starting screencast." "3...2...1..."
@@ -22,19 +44,14 @@ start_recording() {
/tmp/cast.mkv
}
-
-## Stop recording
stop_recording() {
pkill -2 ffmpeg
- output_file="$output_dir"/cast_"$(date '+%F-%H-%M-%S')".mp4
- notify-send "Screencast stopped, transcoding..." "$output_file"
- ffmpeg -i /tmp/cast.mkv "$output_file" && rm /tmp/cast.mkv
+ notify-send "Screencast stopped."
+ prompt_transcode
pkill -76 i3blocks
- notify-send "Transcode done!" "$output_file"
exit
}
-
-## Main
+# main
mkdir -p "$output_dir"
[ -f /tmp/cast.mkv ] && stop_recording || start_recording