From 2dab2233ef9cb54a3878e0120016d542045c7ee8 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 16 Jun 2024 16:16:11 +0200 Subject: checkpoint --- bin/guiscripts/record | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 bin/guiscripts/record (limited to 'bin/guiscripts/record') diff --git a/bin/guiscripts/record b/bin/guiscripts/record new file mode 100755 index 0000000..778e02e --- /dev/null +++ b/bin/guiscripts/record @@ -0,0 +1,86 @@ +#!/bin/sh + +# record - record an area of the screen + +lock="/tmp/record.lock" + +# dependencies: ffmpeg, hacksaw (part), xwininfo & lsw (window), xdotool (active) +# optional: +# - hacksaw: part +# - xwininfo, lsw, commander: window +# - xdotool: active +# - xdg-user-dir + +# $1: width +# $2: height +# $3: x +# $4: y +# $5: output dir +# $6: output name +record_cmd() +{ + if [ -f "$lock" ] + then + >&2 printf 'already recording, please stop recording first\n' + exit 1 + else + touch "$lock" + fi + + herbe "started recording." & + w=$(($3 + $3 % 2)) + h=$(($4 + $4 % 2)) + ffmpeg \ + -v 16 \ + -r 30 \ + -f pulse -ac 2 -i default \ + -f x11grab \ + -s "${w}x${h}" \ + -i ":0.0+$1,$2" \ + -preset slow \ + -c:v h264 \ + -pix_fmt yuv420p \ + -crf 20 \ + "$5/$6.mp4" + printf '%s\n' "$5/$6.mp4" + rm -f "$lock" + herbe "stopped recording." & +} + +if [ -d "$1" ] +then + dir="$1" + shift +else + dir="$(which xdg-user-dir > /dev/null 2>&1 && xdg-user-dir VIDEOS)" + [ "$dir" ] && dir="$dir/records" || dir="$HOME/vids/records" +fi +mkdir -p "$dir" + +current=$(date +%F_%H-%M-%S) + +[ "$1" ] && option="$1" || option="$(printf 'active\nwindow\npart\nstop\nfull\n' | commander -c)" +case "$option" in + active) + record_cmd $(xwininfo -id "$(xdotool getactivewindow)" | + sed -e '/Absolute\|Width:\|Height:/!d;s/.*:\s*//' | tr '\n' ' ') $dir $current + ;; + + window) + winid="$(lsw | commander -cxl | cut -d' ' -f1)" + [ "$winid" ] || exit 1 + values="$(xwininfo -id "$winid" | sed -e '/Absolute\|Width:\|Height:/!d;s/.*:\s*//' | tr '\n' ' ')" + [ "$values" ] || exit 1 + record_cmd $values $dir $current + ;; + + part) + hacksaw | { + IFS=+x read -r w h x y + record_cmd $w $h $x $y $dir $current + } + ;; + stop) kill "$(pgrep ffmpeg | xargs ps | grep 'x11grab' | awk '{print $1}')"; rm -f "$lock" ;; + full) record_cmd 0 0 1920 1080 $dir $current ;; + help|*) >&2 printf 'record [dir] (active|window|part|stop|full)\n' ;; +esac -- cgit v1.2.3 From b0cf79d522a609eda250629386eb45c2978ef2d8 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 18 Jun 2024 15:34:10 +0200 Subject: checkpoint --- bin/guiscripts/record | 20 +++++++++++++++++--- bin/menuscripts/keyadd | 2 +- config/common/tmux/tmux.conf | 2 +- config/essentials/zsh/.zshrc | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) (limited to 'bin/guiscripts/record') diff --git a/bin/guiscripts/record b/bin/guiscripts/record index 778e02e..df4b6e6 100755 --- a/bin/guiscripts/record +++ b/bin/guiscripts/record @@ -11,6 +11,8 @@ lock="/tmp/record.lock" # - xdotool: active # - xdg-user-dir +audio= + # $1: width # $2: height # $3: x @@ -30,10 +32,9 @@ record_cmd() herbe "started recording." & w=$(($3 + $3 % 2)) h=$(($4 + $4 % 2)) - ffmpeg \ + ffmpeg $audio \ -v 16 \ -r 30 \ - -f pulse -ac 2 -i default \ -f x11grab \ -s "${w}x${h}" \ -i ":0.0+$1,$2" \ @@ -57,9 +58,21 @@ else fi mkdir -p "$dir" +if [ "$1" = "-a" ] +then + audio="-f pulse -ac 2 -i default" + shift +fi + +if [ "$1" = "-l" ] +then + find vids/records/ -type f | sort | tail -n 1 + exit +fi + current=$(date +%F_%H-%M-%S) -[ "$1" ] && option="$1" || option="$(printf 'active\nwindow\npart\nstop\nfull\n' | commander -c)" +[ "$1" ] && option="$1" || option="$(printf 'active\nwindow\npart\nstop\nfull\naudio' | commander -c)" case "$option" in active) record_cmd $(xwininfo -id "$(xdotool getactivewindow)" | @@ -82,5 +95,6 @@ case "$option" in ;; stop) kill "$(pgrep ffmpeg | xargs ps | grep 'x11grab' | awk '{print $1}')"; rm -f "$lock" ;; full) record_cmd 0 0 1920 1080 $dir $current ;; + audio) $0 -a; exit ;; help|*) >&2 printf 'record [dir] (active|window|part|stop|full)\n' ;; esac diff --git a/bin/menuscripts/keyadd b/bin/menuscripts/keyadd index 12519ec..4e7949f 100755 --- a/bin/menuscripts/keyadd +++ b/bin/menuscripts/keyadd @@ -2,7 +2,7 @@ log() { - notify-send -t 1000 "keyadd" "$1" + notify-send -t 1000 "keyadd" "$1" & >&2 printf '%s\n' "$1" } diff --git a/config/common/tmux/tmux.conf b/config/common/tmux/tmux.conf index 9300c97..8cf10e5 100755 --- a/config/common/tmux/tmux.conf +++ b/config/common/tmux/tmux.conf @@ -120,7 +120,7 @@ set -g status on #+--- Layout ---+ set -g set-titles-string "[#S: #W] #T" set -g set-titles on -set -g status-position top +set -g status-position bottom set -g window-status-current-style "underscore" set -g status-justify left set -g status-left-length 16 diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 6bd948a..8aa9f5e 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -41,7 +41,7 @@ plug "zsh-users/zsh-completions" plug "MichaelAquilina/zsh-auto-notify" export AUTO_NOTIFY_TITLE="zsh" export AUTO_NOTIFY_BODY="%command [%exit_code]" -AUTO_NOTIFY_IGNORE+=("gurk" "ttyper" "pulsemixer" "tmux" "btop" "vis") +AUTO_NOTIFY_IGNORE+=("gurk" "ttyper" "pulsemixer" "tmux" "btop" "vis" "clock") # Substring search settings export HISTORY_SUBSTRING_SEARCH_HIGHLIGHT_FOUND="bg=blue,fg=black,bold" -- cgit v1.2.3