Skip to content

Commit

Permalink
Merge pull request #8 from elkowar/master
Browse files Browse the repository at this point in the history
Add --stop flag
  • Loading branch information
phisch authored Aug 24, 2020
2 parents e34d55f + 8603a88 commit a6f34d9
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 14 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Command used in this demo: `giph -s -l -c 0.3,0,0.6,0.3 ~/Videos/$(date +%s).gif
```bash
$ giph -s -l -c 1,1,1,0.3 -b 5 -p -5 out.gif
```
Select a window or area with slop. The selection rectangle is highlighted in a transparent blue color abd has a 5px border on the inside. After stopping the recording with either `ctrl+c` or by sending a `SIGINT` to the processgroup, the resulting gif is written to `out.gif`.
Select a window or area with slop. The selection rectangle is highlighted in a transparent blue color abd has a 5px border on the inside.
After stopping the recording with either `ctrl+c`, by running `giph --stop` or by sending a `SIGINT` to the processgroup, the resulting gif is written to `out.gif`.


```bash
Expand Down Expand Up @@ -39,6 +40,7 @@ Optionally, install the following dependencies:

- slop (`--select`)
- libnotify (`--notify`)
- pgrep (`--stop`)

Clone the giph repository:

Expand All @@ -51,4 +53,4 @@ And finally install giph:
```bash
$ cd giph
$ sudo make install
```
```
16 changes: 7 additions & 9 deletions man/giph.1
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,18 @@ is a screen recorder that records the desktop, a window or selection and encodes
.BI "giph -g " "300x200+600+200 ~/Videos/$(date +%s).png"
Records a 300x200 pixel (width x height) rectangle, that is shifted 600 pixel to the right and 200 pixel down from the top-left corner. The recording stops when either
.B ctrl+c
is pressed, or the
.BR "process group is interrupted" .
The encoded gif will be saved in your users Videos directory and has the current timestamp as a name. To send an interrupt signal to the process group, you can use:
.in +2
\(bu
.BI "kill -INT -" PID
is pressed, or after calling
.B giph --stop.
.br
\(bu
.BI "killall -INT -g " giph
The encoded gif will be saved in your users videos directory and has the current timestamp as a name.
.SH OPTIONS
.TP
.BR \-h ", " \-\-help
Print help and exit.
.TP
.BR \-\-stop
Finish any running giph recordings
.TP
.BR \-\-version
Print version and exit.
.TP
Expand Down Expand Up @@ -112,4 +110,4 @@ Disable being able to cancel the selection using the keyboard.
.BR \-o ", " \-\-noopengl
Disable graphics acceleration.
.SH SEE ALSO
.B slop(1)
.B slop(1)
22 changes: 19 additions & 3 deletions src/giph
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ OPTIONS
-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.
-y, --notify Send notification on error or success.
--stop Finish any running giph recordings.
SLOP OPTIONS
-b, --bordersize=FLOAT Set the selection border thickness.
Expand Down Expand Up @@ -115,6 +116,9 @@ while [[ "$1" == -* ]]; do
--quiet)
VERBOSITY=-1
;;
--stop)
SHOULD_STOP=true
;;
-s|--select)
SLOP=1
;;
Expand Down Expand Up @@ -341,11 +345,13 @@ function countdown_cli() {
done
}


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"
log_info "stop recording with \033[1;36mctrl+c\033[0m or call \033[1;36mgiph --stop\033[0m"
trap '' INT
}


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")
Expand Down Expand Up @@ -389,5 +395,15 @@ function giph() {
exit 0
}

giph
wait
function stop_all_recordings() {
for pid in $(pgrep giph); do
kill -INT -"$pid"
done
}

if [ -n "$SHOULD_STOP" ]; then
stop_all_recordings
else
giph
fi
wait

0 comments on commit a6f34d9

Please sign in to comment.