bin: many script tweaks
This commit is contained in:
parent
b711a5f921
commit
64a8adc1d8
|
@ -34,7 +34,7 @@ fileinfo() {
|
||||||
#probe="$($elevate ffprobe "$arg" 2>&1)"
|
#probe="$($elevate ffprobe "$arg" 2>&1)"
|
||||||
#echo $probe | grep -v -e '00:00:00.04' -e 'ansi' &&
|
#echo $probe | grep -v -e '00:00:00.04' -e 'ansi' &&
|
||||||
$elevate ffprobe -hide_banner "$arg" 2>&1 | grep "bitrate: ....\? " | sed 's/, start:[^,]\+,/,/' ||
|
$elevate ffprobe -hide_banner "$arg" 2>&1 | grep "bitrate: ....\? " | sed 's/, start:[^,]\+,/,/' ||
|
||||||
stat --format "%U:%G %A %s $(
|
$elevate stat --format "%U:%G %A %s $(
|
||||||
size="$($elevate unzip -l "$arg" 2>/dev/null | tail -1)" &&
|
size="$($elevate unzip -l "$arg" 2>/dev/null | tail -1)" &&
|
||||||
echo "(uncompressed $(echo $size | cut -d' ' -f1 | numfmt --to=iec-i --suffix=B))"
|
echo "(uncompressed $(echo $size | cut -d' ' -f1 | numfmt --to=iec-i --suffix=B))"
|
||||||
) - birth %.10w mod %.10y" "$arg" | numfmt --field=3 --to=iec-i --padding=6 --suffix=B
|
) - birth %.10w mod %.10y" "$arg" | numfmt --field=3 --to=iec-i --padding=6 --suffix=B
|
||||||
|
@ -52,7 +52,8 @@ for arg; do
|
||||||
then echo "File not found: '$arg'" 1>&2
|
then echo "File not found: '$arg'" 1>&2
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
grid=$(expr $(tput cols) / 20)
|
grid=$(expr $(tput cols) / \( 25 - \( $# / 2 \) \& $# \< 30 \| 5 \))
|
||||||
|
# TODO reduce grid when many PDFs
|
||||||
tmpfile="$prefix/$(basename "$arg")"
|
tmpfile="$prefix/$(basename "$arg")"
|
||||||
case "$mime" in
|
case "$mime" in
|
||||||
(*\ application/pdf\;*)
|
(*\ application/pdf\;*)
|
||||||
|
@ -109,7 +110,7 @@ for arg; do
|
||||||
batplain+=("$list");;
|
batplain+=("$list");;
|
||||||
esac; fi
|
esac; fi
|
||||||
;;
|
;;
|
||||||
(*:\ *database*) sqlite3 "$arg" ".tables";;
|
(*:\ *database*) highlight "Tables" && sqlite3 "$arg" ".tables";;
|
||||||
(*) bat+=("$arg")
|
(*) bat+=("$arg")
|
||||||
timga+=("$arg")
|
timga+=("$arg")
|
||||||
continue;;
|
continue;;
|
||||||
|
@ -124,8 +125,8 @@ done
|
||||||
if test "$timg"; then
|
if test "$timg"; then
|
||||||
# Don't show info on all images for gifs
|
# Don't show info on all images for gifs
|
||||||
$inspect || $elevate timg $(test "$timga" && echo "-V") --rotate=exif -g $(tput cols)x$(expr $(tput lines) / 2) \
|
$inspect || $elevate timg $(test "$timga" && echo "-V") --rotate=exif -g $(tput cols)x$(expr $(tput lines) / 2) \
|
||||||
$(test $# -gt 1 && grid=$(expr $(tput cols) / \( 30 - $# \& $# \< 25 \| 5 \)) &&
|
$(test $# -gt 1 &&
|
||||||
echo "-t0.2 --center $(test $# -lt 30 && echo "--title") --grid=$((grid < $# ? grid : $#))x2") \
|
echo "-t0.2 --center $(test $# -lt 20 && echo "--title") --grid=$((grid < $# ? grid : $#))x2") \
|
||||||
"${timg[@]}" "${timga[@]}" 2>/dev/null || true
|
"${timg[@]}" "${timga[@]}" 2>/dev/null || true
|
||||||
if $inspect || test $# -lt 10; then
|
if $inspect || test $# -lt 10; then
|
||||||
tput setaf 6
|
tput setaf 6
|
||||||
|
@ -148,7 +149,7 @@ if test "$bat" -o "$batplain"; then
|
||||||
fi
|
fi
|
||||||
batcommand="$elevate bat $cut $args --pager"
|
batcommand="$elevate bat $cut $args --pager"
|
||||||
batstyle="--style plain$rule"
|
batstyle="--style plain$rule"
|
||||||
test "$batplain" && $batcommand $batstyle "${batplain[@]}"
|
test "$batplain" && $batcommand "$pager" $batstyle "${batplain[@]}"
|
||||||
test "$bat" && if test "$cut" && ! $inspect
|
test "$bat" && if test "$cut" && ! $inspect
|
||||||
then case $TERM in (*kitty)
|
then case $TERM in (*kitty)
|
||||||
declare -a timgtxt
|
declare -a timgtxt
|
||||||
|
|
|
@ -25,5 +25,9 @@ case $command in
|
||||||
git add -f .SRCINFO *.install 2>/dev/null || true
|
git add -f .SRCINFO *.install 2>/dev/null || true
|
||||||
git commit -v -a "$@"
|
git commit -v -a "$@"
|
||||||
git push;;
|
git push;;
|
||||||
|
(clean)
|
||||||
|
find "$aurdir" -mindepth 2 -maxdepth 2 \( -name "*.tar.gz" -o -type d -not -name ".*" \) \
|
||||||
|
-print -exec sudo rm -rI {} +;;
|
||||||
|
(*) echo "Unknown command!"; exit 3;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,11 @@ checkaccess -w "$@" || elevate=sudo
|
||||||
! $elevate test -e "$1" && echo "$1 does not exist" && exit 1
|
! $elevate test -e "$1" && echo "$1 does not exist" && exit 1
|
||||||
|
|
||||||
dir="$(dirname "$1")"
|
dir="$(dirname "$1")"
|
||||||
test $(lsattr -d "$dir" | cut -c6) = a && setappend=true
|
test "$(lsattr -d "$dir" | cut -c6 2>/dev/null)" = a && setappend=true
|
||||||
test -z "$setappend" || sudo chattr -V -a "$dir"
|
test -z "$setappend" || sudo chattr -V -a "$dir"
|
||||||
|
|
||||||
$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)
|
$elevate mkdir -p $(case "$last" in (*/) echo "$last";; (*) dirname "$last";; esac)
|
||||||
$elevate mv --verbose --interactive "$@"
|
$elevate mv --verbose --interactive "$@"
|
||||||
|
# Diff when interactive
|
||||||
|
|
||||||
test -z "$setappend" || sudo chattr -V +a "$dir"
|
test -z "$setappend" || sudo chattr -V +a "$dir"
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# Play given files on mpd, enabling playing of external files through symlinking and recursively resolving playlists
|
# [M]edia [P]lay
|
||||||
|
# Play given files on mpd, playing external files through symlinking and recursively resolving playlists
|
||||||
# depends: xargs realpath mpc
|
# depends: xargs realpath mpc
|
||||||
# env: MUSIC
|
# env: MUSIC
|
||||||
MUSIC="${MUSIC:-$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/mpd/mpd.conf | grep music_directory | cut -d'"' -f2 | sed "s|~|$HOME|")}"
|
MUSIC="${MUSIC:-$(cat ${XDG_CONFIG_HOME:-$HOME/.config}/mpd/mpd.conf | grep music_directory | cut -d'"' -f2 | sed "s|~|$HOME|")}"
|
||||||
|
@ -24,7 +25,7 @@ then shift
|
||||||
else
|
else
|
||||||
test -n "$verbose" &&
|
test -n "$verbose" &&
|
||||||
echo "Running find in path '$filepath' $(test "$arg" != "$filepath" && echo "from '$arg' ")" >&2
|
echo "Running find in path '$filepath' $(test "$arg" != "$filepath" && echo "from '$arg' ")" >&2
|
||||||
find "$filepath" -iname "*.flac" -o -iname "*.mp3" -o -iname "*.ogg" -o -iname "*.opus" |
|
find "$filepath" -iname "*.aac" -o -iname "*.flac" -o -iname "*.mp3" -o -iname "*.ogg" -o -iname "*.opus" |
|
||||||
sort | while read file
|
sort | while read file
|
||||||
do case "$file" in
|
do case "$file" in
|
||||||
($MUSIC/*) echo "${file#$MUSIC/}";;
|
($MUSIC/*) echo "${file#$MUSIC/}";;
|
||||||
|
|
|
@ -1,2 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
strace --follow-forks -e trace=file "$@" 2>&1 >/dev/null | grep openat | cut -d'"' -f2 | grep -v ".so" | grep -v "/dev/" | less
|
while true; do
|
||||||
|
case $1 in
|
||||||
|
(-e) filter="\|ENOENT"; shift;;
|
||||||
|
(*) break;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
strace --follow-forks -e trace=file "$@" 2>&1 | grep -v "\(newfstatat$filter\)" | cut -d'"' -f2 | grep -v "\(.so\|/dev/\)" | less
|
||||||
|
|
|
@ -11,9 +11,9 @@ iptables --new-chain chain-times 2>/dev/null || iptables --flush chain-times
|
||||||
iptables -A chain-times -m owner --uid-owner janek -d 192.168.1.0/24 -j ACCEPT
|
iptables -A chain-times -m owner --uid-owner janek -d 192.168.1.0/24 -j ACCEPT
|
||||||
iptables -A chain-times -m owner --uid-owner janek -d 127.0.0.0/8 -j ACCEPT
|
iptables -A chain-times -m owner --uid-owner janek -d 127.0.0.0/8 -j ACCEPT
|
||||||
|
|
||||||
time9=$(date -u -d "$(date -d 09:00)" +%k)
|
time9=$(date -u -d "$(date -d 9:00)" +%k)
|
||||||
iptables -A chain-times -m owner --uid-owner janek -j DROP -m time \
|
iptables -A chain-times -m owner --uid-owner janek -j DROP -m time \
|
||||||
--timestart $(date -u -d "$(date -d "${1:-15 min}")" +%k:%M) --timestop $(expr $time9 - 2):00
|
--timestart $(date -u -d "$(date -d "${1:-15 min}")" +%k:%M) --timestop $(expr $time9):00
|
||||||
|
|
||||||
# TODO Only 10 minutes every hour, anything else needs justification
|
# TODO Only 10 minutes every hour, anything else needs justification
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue