diff --git a/bin/av1_enc b/bin/av1_enc new file mode 100755 index 0000000..b03b97e --- /dev/null +++ b/bin/av1_enc @@ -0,0 +1,43 @@ +#!/bin/bash + +if [[ -z "$1" ]]; then + printf 'Need an input file.\n' >&2 + exit 1 +fi + +if [[ ! -f "$1" ]]; then + printf '%s doesnt exist.\n' >&2 "$1" + exit 1 +fi + +full_filename="$1" +filename=$(basename -- "$1") +output_file="${filename%.*}.webm" +log1="/dev/shm/${filename%.*}.log1" +log2="/dev/shm/${filename%.*}.log2" + +read width height < <(mediainfo --Output=JSON "$full_filename" | jq -r '.media.track[] | select(."@type"=="Video") | .Width + " " + .Height') + +aomenc -o "$output_file" --codec=av1 --passes=3 --pass=1 --fpf="$log1" \ + -v --webm -u 0 -t 24 --enable-dnl-denoising=0 --denoise-noise-level=5 \ + --target-bitrate=50000 "$full_filename" -w "$width" -h "$height" +if [[ $? != 0 ]]; then + printf 'oops\n' >&2 + exit 1 +fi + +aomenc -o "$output_file" --codec=av1 --passes=3 --pass=2 --fpf="$log1" \ + -spf "$log2" -v --webm -u 0 -t 24 --enable-dnl-denoising=0 \ + --denoise-noise-level=5 --target-bitrate=50000 "$full_filename" +if [[ $? != 0 ]]; then + printf 'oops\n' >&2 + exit 1 +fi + +aomenc -o "$output_file" --codec=av1 --passes=3 --pass=3 --fpf="$log1" \ + -spf "$log2" -v --webm -u 0 -t 24 --enable-dnl-denoising=0 \ + --denoise-noise-level=5 --target-bitrate=50000 "$full_filename" +if [[ $? != 0 ]]; then + printf 'oops\n' >&2 + exit 1 +fi diff --git a/bin/extract_audio b/bin/extract_audio new file mode 100755 index 0000000..b2c7a49 --- /dev/null +++ b/bin/extract_audio @@ -0,0 +1,44 @@ +#!/bin/bash +#!/bin/bash + +err_file="/tmp/getaudio_$$" + +if [[ -z "$1" ]]; then + printf 'Need a filename of a video\n' >&2 + exit 1 +fi + +input_file="$1" +if [[ ! -f "$input_file" ]]; then + printf "Can't read %s\n" >&2 + exit 1 +fi + +base_path="$(dirname "$input_file" 2>"$err_file")" +err="$(<"$err_file")" + +if [[ -n "$err" ]]; then + printf '%s\n' "$err" >&2 + exit 1 +fi + +# audio_ext="$(ffprobe "$input_file" 2>&1 | sed -nr 's/.*Audio: (...).*/\1/p')" + +mediainfo_json="$(mediainfo --Output=JSON "$input_file")" +audio_codec="$(jq -r '.media.track[] | select(."@type"=="Audio") | .Format' <<< "$mediainfo_json")" +audio_ext="$(tr [:upper:] [:lower:] <<< "$audio_codec")" + +if [[ -n "$2" ]]; then + if [[ "$2" == *.* ]]; then + audio_out="$2" + else + audio_out="${2}.${audio_ext}" + fi +else + out_file="$(basename ${input_file%%.*})" + audio_out="${base_path}/${out_file}.${audio_ext}" +fi + +echo ffmpeg -i "$input_file" -vn -acodec copy "$audio_out" +ffmpeg -i "$input_file" -vn -acodec copy "$audio_out" + diff --git a/bin/gclone b/bin/gclone new file mode 100755 index 0000000..177140e --- /dev/null +++ b/bin/gclone @@ -0,0 +1,29 @@ +#!/bin/bash + +if [[ -z "$1" ]]; then + printf 'Need a project:\n\n' >&2 + pass show gitea/token >&2 + exit 1 +fi + +project="$1" +shift +unset token +token="$(pass show gitea/token/${project})" +if [[ -z "$token" ]]; then + printf 'Failed to get token.\n' + exit 1 +fi +if [[ "$project" == 'pass' ]]; then + if [[ -n "$@" ]]; then + pass git pull "$@" "https://luke:${token}@git.drheck.dev/luke/${project}.git" + else + pass git pull "https://luke:${token}@git.drheck.dev/luke/${project}.git" + fi +else + if [[ -n "$@" ]]; then + git clone "$@" "https://luke:${token}@git.drheck.dev/luke/${project}.git" + else + git clone "https://luke:${token}@git.drheck.dev/luke/${project}.git" + fi +fi diff --git a/bin/get_audio b/bin/get_audio new file mode 100755 index 0000000..f953f12 --- /dev/null +++ b/bin/get_audio @@ -0,0 +1,38 @@ +#!/bin/bash + +err_file="/tmp/getaudio_$$" + +if [[ -z "$1" ]]; then + printf 'Need a filename of a video\n' >&2 + exit 1 +fi + +input_file="$1" +if [[ ! -f "$input_file" ]]; then + printf "Can't read %s\n" >&2 + exit 1 +fi + +base_path="$(dirname "$input_file" 2>"$err_file")" +err="$(<"$err_file")" + +if [[ -n "$err" ]]; then + printf '%s\n' "$err" >&2 + exit 1 +fi + +audio_ext="$(ffprobe "$input_file" 2>&1 | sed -nr 's/.*Audio: (...).*/\1/p')" + +if [[ -n "$2" ]]; then + if [[ "$2" == *.* ]]; then + audio_out="$2" + else + audio_out="${2}.${audio_ext}" + fi +else + out_file="$(basename ${input_file%%.*})" + audio_out="${base_path}/${out_file}.${audio_ext}" +fi + +echo ffmpeg -i "$input_file" -vn -acodec copy "$audio_out" +ffmpeg -i "$input_file" -vn -acodec copy "$audio_out" diff --git a/bin/gitea_hints b/bin/gitea_hints new file mode 100755 index 0000000..d63b002 --- /dev/null +++ b/bin/gitea_hints @@ -0,0 +1,5 @@ +#!/bin/bash + +printf 'https://username:PERSONAL_ACCESS_TOKEN@github.com/username/project.git\n' +printf 'git push https://username:PERSONAL_ACCESS_TOKEN@github.com/username/project.git\n' +printf 'token: avatar, settings, applications\n' diff --git a/bin/gmic_test.sh b/bin/gmic_test.sh new file mode 100755 index 0000000..df71e46 --- /dev/null +++ b/bin/gmic_test.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +input_dir="${HOME}/vids/Home/out" +output_dir="${HOME}/vids/Home/out2" +a=0 +effect="fx_sketchbw 3,45,180,30,1.75,0.02,0.5,0.75,0.1,0.7,3,6,0,1,4,0,0,50,50" +effect="fx_sketchbw 5,45,180,16,1.75,0.0291,0.5,0.75,0.1,0.7,3,6,1,1,4,0,0,50,50" +effect="samj_Angoisse 1,5,0,5,100,2,4,1,250" +effect="boxfitting 2,0" +for i in *.png; do + # a=$((a+1)) + echo "$i" + # print_a=$(printf "%04d" "$a") + echo gmic "${input_dir}/${i}" $effect output "${output_dir}/${i}" >> /tmp/cmds + +done + + +# ffmpeg -i "${output_dir}/%09d.png" -c:v libx264 -vf fps=25 -pix_fmt yuv420p "${HOME}/vids/home_effect.mp4" diff --git a/bin/gpull b/bin/gpull new file mode 100755 index 0000000..3bfc297 --- /dev/null +++ b/bin/gpull @@ -0,0 +1,29 @@ +#!/bin/bash + +if [[ -z "$1" ]]; then + printf 'Need a project:\n\n' >&2 + pass show gitea/token >&2 + exit 1 +fi + +project="$1" +shift +unset token +token="$(pass show gitea/token/${project})" +if [[ -z "$token" ]]; then + printf 'Failed to get token.\n' + exit 1 +fi +if [[ "$project" == 'pass' ]]; then + if [[ -n "$@" ]]; then + pass git pull "$@" "https://luke:${token}@git.drheck.dev/luke/${project}.git" + else + pass git pull "https://luke:${token}@git.drheck.dev/luke/${project}.git" + fi +else + if [[ -n "$@" ]]; then + git pull "$@" "https://luke:${token}@git.drheck.dev/luke/${project}.git" + else + git pull "https://luke:${token}@git.drheck.dev/luke/${project}.git" + fi +fi diff --git a/bin/gpush b/bin/gpush new file mode 100755 index 0000000..074a075 --- /dev/null +++ b/bin/gpush @@ -0,0 +1,29 @@ +#!/bin/bash + +if [[ -z "$1" ]]; then + printf 'Need a project:\n\n' >&2 + pass show gitea/token >&2 + exit 1 +fi + +project="$1" +shift +unset token +token="$(pass show gitea/token/${project})" +if [[ -z "$token" ]]; then + printf 'Failed to get token.\n' + exit 1 +fi +if [[ "$project" == 'pass' ]]; then + if [[ -n "$@" ]]; then + pass git push "$@" "https://luke:${token}@git.drheck.dev/luke/${project}.git" + else + pass git push "https://luke:${token}@git.drheck.dev/luke/${project}.git" + fi +else + if [[ -n "$@" ]]; then + git push "$@" "https://luke:${token}@git.drheck.dev/luke/${project}.git" + else + git push "https://luke:${token}@git.drheck.dev/luke/${project}.git" + fi +fi diff --git a/bin/grims b/bin/grims new file mode 100755 index 0000000..938aba6 --- /dev/null +++ b/bin/grims @@ -0,0 +1,3 @@ +#!/bin/bash + +grim -g "$(slurp)" diff --git a/bin/record_nosound b/bin/record_nosound index 961aa0a..ec14f4d 100755 --- a/bin/record_nosound +++ b/bin/record_nosound @@ -1,2 +1,7 @@ #!/bin/bash -wf-recorder -g "$(slurp)" --file=$(date "+%s").mp4 +if [[ -z "$1" ]]; then + file="$(date +%Y-%M-%d_%H:%m)" +else + file="$1" +fi +wf-recorder -g "$(slurp)" --file="${file}.mp4" diff --git a/bin/record_sound b/bin/record_sound index 432cbb7..98f9d75 100755 --- a/bin/record_sound +++ b/bin/record_sound @@ -1,2 +1,7 @@ #!/bin/bash -wf-recorder -g "$(slurp)" --audio --file=$(date "+%s").mp4 +if [[ -z "$1" ]]; then + file="$(date +%Y-%M-%d_%H:%m)" +else + file="$1" +fi +wf-recorder -g "$(slurp)" --audio --file="${file}.mp4" diff --git a/shell/bashrc b/shell/bashrc index a817ea3..44a457f 100644 --- a/shell/bashrc +++ b/shell/bashrc @@ -60,6 +60,7 @@ sources=( "${HOME}/.bash_functions" "${HOME}/.bash_functions2" "${HOME}/.cargo/env" + "${HOME}/.config/gom/init" "${KITTY_INSTALLATION_DIR}/shell-integration/bash/kitty.bash" ) @@ -117,6 +118,16 @@ if [[ "$?" == "1" ]]; then fi [[ -L "${ssh_auth_link}" ]] && [[ -e "${ssh_auth_link}" ]] && export SSH_AUTH_SOCK="$ssh_auth_link" +# autotmux +# export AT=true on connecting host to enable +default_session=shell +tls 2>/dev/null | grep -E "$default_session"'.*attached' &>/dev/null +not_in_tmux="$?" +no_auto="${HOME}/.config/autotmux/disable" +if [[ ! -f "$no_auto" ]] && [[ "$AT" == 'true' ]] && [[ "$not_in_tmux" ]]; then + stx "${default_session}" +fi + # Eternal bash history. # --------------------- # Undocumented feature which sets the size to "unlimited".