From 59297cbd2a6a5c78f131e3b1a8c60710198f5213 Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Thu, 21 Nov 2024 10:04:34 +0100 Subject: Fixing shellcheck errors --- README.md | 6 +++++- local/bin/junk | 8 +++++--- local/bin/latest-recording | 2 +- local/bin/screenshot-prompt | 2 ++ local/bin/video-to-h264 | 21 +++++++++++++++++++++ local/bin/video-to-x264 | 15 --------------- test | 4 ++-- 7 files changed, 36 insertions(+), 22 deletions(-) create mode 100755 local/bin/video-to-h264 delete mode 100755 local/bin/video-to-x264 diff --git a/README.md b/README.md index 3037653..60f4305 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# dotfiles [![Build Status](https://api.travis-ci.com/cacharle/dotfiles.svg?branch=master)](https://app.travis-ci.com/github/cacharle/dotfiles) +# dotfiles ## Installation @@ -29,3 +29,7 @@ $ ./install ## Credit * mpv script youtube quality - + +## TODO + +- [ ] atuin - diff --git a/local/bin/junk b/local/bin/junk index faf9b32..9758f68 100755 --- a/local/bin/junk +++ b/local/bin/junk @@ -11,9 +11,11 @@ do if [ -e "$dest" ] then echo "$dest already exists, generating a prefix" - identifier="$(seq 100 | xargs -I N sh -c "echo N; test -e '$dest__N' || exit 255" 2> /dev/null | tail -n1)" + identifier="$(seq 100 | xargs -I N sh -c "echo N; test -e '""$dest""__N' || exit 255" 2> /dev/null | tail -n1)" dest="$dest"__"$identifier" fi - mv "$arg" "$dest" && - echo "$arg moved to $dest" || true + if mv "$arg" "$dest" + then + echo "$arg moved to $dest" + fi done diff --git a/local/bin/latest-recording b/local/bin/latest-recording index bf3b3b2..518ffd6 100755 --- a/local/bin/latest-recording +++ b/local/bin/latest-recording @@ -3,5 +3,5 @@ set -e recordings_dir="$HOME/recordings" -latest_recording="$(ls "$recordings_dir" | sort --numeric-sort | tail -n1)" +latest_recording="$(find "$recordings_dir"/* -prune -print | sort --numeric-sort | tail -n1)" echo "$recordings_dir/$latest_recording" diff --git a/local/bin/screenshot-prompt b/local/bin/screenshot-prompt index 6852eba..b320178 100755 --- a/local/bin/screenshot-prompt +++ b/local/bin/screenshot-prompt @@ -23,6 +23,7 @@ screenshot_dir="$HOME/screenshots" [ ! -d "$screenshot_dir" ] && mkdir "$screenshot_dir" scrot_wrapper() { + # shellcheck disable=SC2016 file_format="$screenshot_dir/"'%Y-%m-%d_$wx$h.png' if [ "$1" = '-' ] then @@ -30,6 +31,7 @@ scrot_wrapper() { shift else # optipng optimizes png size without loss (doesn't work if we output directly to stdout) + # shellcheck disable=SC2016 command -v optipng && optipng_arg='optipng -o4 $f' fi scrot --silent --quality 95 --compression 9 --file "$file_format" -e "$optipng_arg" "$@" diff --git a/local/bin/video-to-h264 b/local/bin/video-to-h264 new file mode 100755 index 0000000..8b4d21b --- /dev/null +++ b/local/bin/video-to-h264 @@ -0,0 +1,21 @@ +#!/usr/bin/bash + +file_path="$1" + +# from: https://stackoverflow.com/questions/2869281/how-to-determine-video-codec-of-a-file-with-ffmpeg +current_codec="$( + ffprobe -v error -select_streams v:0 \ + -show_entries stream=codec_name -of default=noprint_wrappers=1:nokey=1 \ + "$file_path" +)" +[ "$current_codec" = 'h264' ] && { echo 'Video is already in h264'; exit 1; } + +# CUDA options: -hwaccel cuda -hwaccel_output_format cuda -c:v h264_nvenc +# seems slower on gpu tho +# There is also -c:v hvec_nvenc +# +# Options to reduce size: -b:v 5M -crf 28 + +ffmpeg -i "$file_path" \ + -map 0 -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy \ + "${file_path%%.*}-h264.${file_path##*.}" diff --git a/local/bin/video-to-x264 b/local/bin/video-to-x264 deleted file mode 100755 index dd93ca5..0000000 --- a/local/bin/video-to-x264 +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/bash - -file_path="$1" -extension= - - -# CUDA options: -hwaccel cuda -hwaccel_output_format cuda -c:v h264_nvenc -# seems slower on gpu tho -# There is also -c:v hvec_nvenc -# -# Options to reduce size: -b:v 5M -crf 28 - -ffmpeg -i "$file_path" \ - -map 0 -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy \ - "${file_path%%.*}-x264.${file_path##*.}" diff --git a/test b/test index b2970e5..49b3856 100755 --- a/test +++ b/test @@ -16,8 +16,8 @@ shellcheck -s sh config/x11/xinitrc # vint -s config/vim/pluggins.vim # FLAKE8 -flake8 --ignore F821,E501,W504,N816,E241 config/qutebrowser/config.py -flake8 --ignore W504,CCR001 config/python/startup.py +# flake8 --ignore F821,E501,W504,N816,E241 config/qutebrowser/config.py +# flake8 --ignore W504,CCR001 config/python/startup.py # CRONTAB if crontab -h 2>&1 | grep -q '.*-T.*' -- cgit