From f94c1e96038705e30dac14c30de38de0c815e176 Mon Sep 17 00:00:00 2001 From: Philipp Schaffrath Date: Wed, 5 Jun 2019 03:15:46 +0200 Subject: [PATCH] removed zenity and therefore also the -i and --interface arguments, removed zenity dependency and updated documentation, fixes #5 --- README.md | 1 - man/giph.1 | 10 ------- src/giph | 80 ++---------------------------------------------------- 3 files changed, 3 insertions(+), 88 deletions(-) diff --git a/README.md b/README.md index 2b37477..c2843c9 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,6 @@ Optionally, install the following dependencies: - slop (`--select`) - libnotify (`--notify`) - - zenity (`--interface zenity`) Clone the giph repository: diff --git a/man/giph.1 b/man/giph.1 index 958243b..e98dc67 100644 --- a/man/giph.1 +++ b/man/giph.1 @@ -9,7 +9,6 @@ giph \- record gif from desktop, window or selection [\fB-g\fR \fIGEOMETRY\fR | \fB-w\fR \fIINT\fR | \fB-s\fR [\fB-l\fR] [\fB-c\fR \fIFLOAT,FLOAT,FLOAT,FLOAT\fR] [\fB-p\fR \fIFLOAT\fR] [\fB-b\fR \fIFLOAT\fR]] -[\fB-i\fR \fIINTERFACE\fR] [\fB-d\fR \fIINT\fR] [\fB-t\fR \fIINT\fR] [\fB-f\fR \fIINT\fR] @@ -77,15 +76,6 @@ Sets a fixed time to record. The format is a timeduration as described in the ff .BR \-f ", " \-\-framerate " \fIINT\fR (default: \fI15\fR)" Sets the desired framerate of the recorded gif. A higher framerate will result in a larger filesize. .TP -.BR \-i ", " \-\-interface " \fISTRING\fR (default: \fIcli\fR)" -Selects the user interface method that is used for countdown, timer and to stop the recording. The possible values are: -.in +2 -\(bu -.IR cli ": uses the terminal as a user interface" -.br -\(bu -.IR zenity ": displays control-windows using zenity" -.TP .BR \-y ", " \-\-notify Uses notify-send to send an urgent notification if an error happens, or a normal notification when the final gif was saved successfully. .SH SLOP OPTIONS diff --git a/src/giph b/src/giph index 8a034bf..f39e761 100755 --- a/src/giph +++ b/src/giph @@ -11,7 +11,6 @@ VERBOSITY=0 SLOP=0 DELAY=0 FRAMERATE=15 -INTERFACE="cli" function print_version() { echo $VERSION @@ -37,7 +36,6 @@ OPTIONS -d, --delay=INT Time in seconds before the recording starts. -t, --timer=TIMEDURATION Time of the recording. (e.g. 10 for 10 seconds or 1:30 for 1 minute 30 seconds) -f, --framerate=INT Set the framerate. - -i, --interface=STRING Set the user interface that should be used. ("cli" or "zenity") -y, --notify Send notification on error or success. SLOP OPTIONS @@ -140,10 +138,6 @@ while [[ "$1" == -* ]]; do shift FRAMERATE="$1" ;; - -i|--interface) - shift - INTERFACE="$1" - ;; -y|--notify) NOTIFY=1 ;; @@ -312,7 +306,7 @@ function start_video_recording() { ffmpeg+=("$TEMP_DIRECTORY/recording.mkv") - [ -n "$DELAY" ] && [ "$DELAY" -gt 0 ] && delay "$DELAY" + [ -n "$DELAY" ] && [ "$DELAY" -gt 0 ] && countdown_cli "$DELAY" "recording starts in" ffmpeg_command=${ffmpeg[*]} log "ffmpeg command: '$ffmpeg_command'" 2 true @@ -323,9 +317,9 @@ function start_video_recording() { log "started recording video with ffmpeg" 1 true if [ -n "$TIMER" ] && [ "$TIMER" -gt 0 ]; then - timer "$TIMER" + countdown_cli "$TIMER" "recording stops in" else - stop_video_recording_handler + stop_recording_handler_cli fi wait $FFMPEG_PID @@ -334,17 +328,6 @@ function start_video_recording() { log "completed ffmpeg video recording" 1 true } -function delay() { - case "$INTERFACE" in - "cli") - countdown_cli "$1" "recording starts in" - ;; - "zenity") - delay_zenity "$1" - ;; - esac -} - function countdown_cli() { seconds=$1 while [ "$seconds" -ge 0 ]; do @@ -358,68 +341,11 @@ function countdown_cli() { done } -function delay_zenity() { - counter=$1 - while [ "$counter" -ge "0" ]; do - percent=$((100-100*counter/$1)) - echo "#recording will start in $counter" - echo $percent - ((counter-=1)) - sleep 1 - done | zenity --progress "$1" --no-cancel --extra-button="Cancel" --auto-close &> /dev/null - [ $? = 1 ] && log_error "recording canceled by user" -} - -function timer() { - case "$INTERFACE" in - "cli") - countdown_cli "$1" "recording stops in" - ;; - "zenity") - timer_zenity "$1" - ;; - esac -} - -function timer_zenity() { - counter=$1 - while [ "$counter" -ge "0" ]; do - percent=$((100-100*counter/$1)) - echo "#recording stops in $counter" - echo $percent - ((counter-=1)) - sleep 1 - done | zenity --progress "$1" --no-cancel --auto-close &> /dev/null -} - -function stop_video_recording_handler() { - case "$INTERFACE" in - "cli") - stop_recording_handler_cli - ;; - "zenity") - stop_recording_handler_zenity - ;; - esac -} - function stop_recording_handler_cli() { log_info "stop recording with \033[1;36mctrl+c\033[0m or send INT SIGNAL to this process \033[1;36mkillall -int -g giph\033[0m" trap '' INT } -function stop_recording_handler_zenity() { - zenity --question --cancel-label "Cancel" --ok-label "Stop" --text "\nrecording..." --icon-name media-record &> /dev/null - zenity_return=$? - - kill -INT $FFMPEG_PID - - if [ $zenity_return = 1 ]; then - wait $FFMPEG_PID - log_error "video recording canceled by user" - fi -} - function encode_gif_ffmpeg() { log "encoding gif using ffmpeg encoder" 1 true ffmpeg_generate_palette=(ffmpeg -i "$TEMP_DIRECTORY/recording.mkv" -vf palettegen "$TEMP_DIRECTORY/palette.png")