bin: odd bits and additions
This commit is contained in:
parent
c6206d3fc1
commit
67eb994037
|
@ -10,7 +10,7 @@
|
||||||
# - visual files are displayed with timg
|
# - visual files are displayed with timg
|
||||||
# video thumbnails via mtn, pdf pages from pdftoppm
|
# video thumbnails via mtn, pdf pages from pdftoppm
|
||||||
# - text files are displayed through bat
|
# - text files are displayed through bat
|
||||||
# Automatically requests elevation through sudo when needed
|
# Usually automatically requests elevation through sudo when needed
|
||||||
# TODO .raw,.iso,.qcow2
|
# TODO .raw,.iso,.qcow2
|
||||||
|
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
@ -43,10 +43,10 @@ fileinfo() {
|
||||||
$elevate file --exclude elf -E "$arg"
|
$elevate file --exclude elf -E "$arg"
|
||||||
tput rmso
|
tput rmso
|
||||||
$elevate ssh-keygen -l -f "$arg" 2>/dev/null || true
|
$elevate ssh-keygen -l -f "$arg" 2>/dev/null || true
|
||||||
# TODO do not grep bitrate but extract properly
|
# I think this check is here to avoid scrolling text interpreted as video
|
||||||
#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' &&
|
||||||
{ ! $inspect && $elevate ffprobe -hide_banner "$arg" 2>&1 | grep "bitrate: ....\? " | sed 's/, start:[^,]\+,/,/'; } ||
|
{ ! $inspect && $elevate ffprobe -hide_banner "$arg" 2>&1 | grep -E "bitrate: .{3,5} " | sed 's/, start:[^,]\+,/,/'; } ||
|
||||||
$elevate 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))"
|
||||||
|
@ -95,6 +95,8 @@ for arg; do
|
||||||
timg+=("$tmpfile");;
|
timg+=("$tmpfile");;
|
||||||
(*\ video/*)
|
(*\ video/*)
|
||||||
suffix=_thumbs.jpg
|
suffix=_thumbs.jpg
|
||||||
|
# TODO sometimes duration mismatch for short videos
|
||||||
|
test $(printf "%.0f" $(ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 "$arg")) -gt 3 &&
|
||||||
mtn -q -i -t -W -r$(expr 5 - $# \& $# \< 4 \| 1) -D6 -b 0.6 -c $grid -w $(expr $(tput cols) '*' 20) \
|
mtn -q -i -t -W -r$(expr 5 - $# \& $# \< 4 \| 1) -D6 -b 0.6 -c $grid -w $(expr $(tput cols) '*' 20) \
|
||||||
-O "$prefix" -o "$suffix" "$arg" &&
|
-O "$prefix" -o "$suffix" "$arg" &&
|
||||||
timg -W "$prefix/$(basename -- "${arg%.*}")$suffix"
|
timg -W "$prefix/$(basename -- "${arg%.*}")$suffix"
|
||||||
|
@ -139,7 +141,7 @@ for arg; do
|
||||||
fi
|
fi
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
(*:\ SQLite\ *\ database*) highlight "Tables" && sqlite3 "$arg" ".tables";;
|
(*:\ SQLite\ *\ database*) highlight "Tables" && sqlite3 "$arg" ".tables";; # TODO for few tables: SELECT * FROM db LIMIT 3; | cut -c-$col
|
||||||
(*:\ data) ;;
|
(*:\ data) ;;
|
||||||
(*\ key) bat+=("$arg");;
|
(*\ key) bat+=("$arg");;
|
||||||
(*) bat+=("$arg")
|
(*) bat+=("$arg")
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/bash -e
|
||||||
|
# Verify the given password hash against a password
|
||||||
|
if test "$1"
|
||||||
|
then hash="$1"; shift
|
||||||
|
else printf "Hash? " && read -r hash
|
||||||
|
fi
|
||||||
|
while echo "Type password (no echo) " && read -r -s password && test "$password"; do
|
||||||
|
param=$(echo "$hash" | cut -d\$ -f3)
|
||||||
|
# Check if hash contains parameters
|
||||||
|
if test $(echo "$hash" | tr -cd \$ | wc -c) -gt 3
|
||||||
|
then salt=$(echo "$hash" | cut -d\$ -f4)
|
||||||
|
salted_hash=$(mkpasswd -m sha-512 --"$param" --salt="$salt" "$password")
|
||||||
|
else salted_hash=$(mkpasswd -m sha-512 --salt="$param" "$password")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Compare the generated hash with the original hash
|
||||||
|
if [[ "$salted_hash" == "$hash" ]]
|
||||||
|
then echo ":) Password correct"; break
|
||||||
|
else echo "X Password incorrect"
|
||||||
|
fi
|
||||||
|
done
|
|
@ -29,12 +29,6 @@ find -L -maxdepth 2 -type l -printf "Removing broken symlink %p\n" -delete 2>/de
|
||||||
test -d /mnt/data/backups/mobile/ &&
|
test -d /mnt/data/backups/mobile/ &&
|
||||||
mv -v $DATA/4*/backups/mobile/signal-* /mnt/data/backups/mobile/ 2>/dev/null
|
mv -v $DATA/4*/backups/mobile/signal-* /mnt/data/backups/mobile/ 2>/dev/null
|
||||||
|
|
||||||
highlight "y :: recursively remove empty folders and files"
|
|
||||||
if [[ $1 =~ "y" ]]; then
|
|
||||||
find -name '.thumbnails' -printf "Pre-cleaning %p\n" -exec rm -r {} +
|
|
||||||
find \( -name ".stfolder" -o -name ".*keep" -o -name ".git" -o -name "tmp" -o -name ".nomedia" -o -name "__init__.py" -o -name "instalee" \) -prune -o -empty -printf "Removing empty %p\n" -exec rm -d {} +
|
|
||||||
fi
|
|
||||||
|
|
||||||
highlight "e :: remove downloaded emacs packages (rebuild takes minutes!)"
|
highlight "e :: remove downloaded emacs packages (rebuild takes minutes!)"
|
||||||
[[ $1 =~ "e" ]] &&
|
[[ $1 =~ "e" ]] &&
|
||||||
find $DOOMLOCALDIR -maxdepth 1 \( -name straight -o -type f \) -printf "Removing %p\n" -exec rm -rf {} +
|
find $DOOMLOCALDIR -maxdepth 1 \( -name straight -o -type f \) -printf "Removing %p\n" -exec rm -rf {} +
|
||||||
|
|
|
@ -21,7 +21,7 @@ conf_tmp="${conf_cache}.tmp"
|
||||||
mkdir -p "$conf_cache_dir"
|
mkdir -p "$conf_cache_dir"
|
||||||
touch "$conf_cache"
|
touch "$conf_cache"
|
||||||
|
|
||||||
sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview '$(test -r {} || echo "sudo") bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches")
|
sel=$(listconf | fzf -1 -0 --tiebreak=end,length --preview '$(test -r {} || echo "sudo -n") bat --color=always --style=numbers --line-range :200 {}' --query="$1" --history "$conf_cache_dir/searches")
|
||||||
case "$sel" in
|
case "$sel" in
|
||||||
("") exit 2;;
|
("") exit 2;;
|
||||||
(/etc/sudoers) sudo visudo;;
|
(/etc/sudoers) sudo visudo;;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
# TODO fails on "Alchemy"
|
# TODO fails on "Alchemy"
|
||||||
# TODO implement finding by tags
|
# TODO implement finding by tags
|
||||||
PLAYLISTS="${PLAYLISTS:-$MUSIC/Playlists}"
|
PLAYLISTS="${PLAYLISTS:-$MUSIC/Playlists}"
|
||||||
mpc -q clear || mpdr && mpc -q clear
|
mpc -q clear || mpdr
|
||||||
if test -z "$1"
|
if test -z "$1"
|
||||||
then mp -q "$PLAYLISTS/focus.m3u"
|
then mp -q "$PLAYLISTS/focus.m3u"
|
||||||
else
|
else
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
kdeconnect-cli --refresh
|
kdeconnect-cli --refresh
|
||||||
if ! test -f "$1"; then echo "Please specify a file to share" && exit 1; fi
|
if ! test -f "$1"; then echo "Please specify a file to share" && exit 1; fi
|
||||||
file="$1"
|
file="$1"
|
||||||
device="$(kdeconnect-cli --list-available 2>/dev/null | fzf -0 -1 | cut -d' ' -f3)"
|
device="$(kdeconnect-cli --list-available 2>/dev/null | fzf -0 -1 | sed -E 's|.*: ([^ ]*) .*|\1|')"
|
||||||
test -z "$device" && kdeconnect-cli --list-devices && echo "No device available!" && exit 1
|
test -z "$device" && kdeconnect-cli --list-devices && echo "No device available!" && exit 1
|
||||||
shift
|
shift
|
||||||
kdeconnect-cli "--share=$file" -d "$device" "$@"
|
kdeconnect-cli "--share=$file" -d "$device" "$@"
|
||||||
|
|
|
@ -28,6 +28,15 @@ case $1 in
|
||||||
shift;;
|
shift;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# FILE as loopback device
|
||||||
|
if test -f "$arg"
|
||||||
|
then set -e
|
||||||
|
loopdevice="$(sudo losetup -f)"
|
||||||
|
sudo losetup -P -v "$loopdevice" "$arg"
|
||||||
|
$0 "$loopdevice"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
|
||||||
# FSTAB: BY LABEL
|
# FSTAB: BY LABEL
|
||||||
if grep --word-regexp "LABEL=$arg" /etc/fstab
|
if grep --word-regexp "LABEL=$arg" /etc/fstab
|
||||||
then # have to mount twice as the first one might be creating the directory
|
then # have to mount twice as the first one might be creating the directory
|
||||||
|
|
|
@ -14,8 +14,10 @@ do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Clean empty files
|
||||||
|
$elevate find -name '.thumbnails' -printf 'Pre-cleaning %p\n' -exec rm -r {} +
|
||||||
|
$elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) \( -name '.stfolder' -o -name '.*keep' -o -name '*.py' -o -name 'nodelay.txt' -o -name '.git' -o -name 'tmp' -o -name '.nomedia' -o -name '__init__.py' -o -name '*ignore' -o -name 'instalee' \) \( -type d -o -type f \) -prune -o -empty -printf 'Removing empty %p\n' #-exec rm -d {} +
|
||||||
# $elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 4) -type d -empty -name .stfolder -exec rm -div {} \;
|
# $elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 4) -type d -empty -name .stfolder -exec rm -div {} \;
|
||||||
$elevate find -H "$f" -maxdepth $(expr 1 \& "$f" = "/" \| 5 \& $# \> 0 \| 3) -not \( -name '.stfolder' -o -name '.*keep' -o -name "*.py" -o -name "nodelay.txt" \) \( -type d -o -type f \) -a -empty -printf 'Removing empty %p\n' -delete
|
|
||||||
test $# -eq 0 && exit $?
|
test $# -eq 0 && exit $?
|
||||||
if test -e "$f"; then
|
if test -e "$f"; then
|
||||||
echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 &&
|
echo -n "$f ($(ls -A "$f" | head -3 | paste -s -d' ')) " >&2 &&
|
||||||
|
|
Loading…
Reference in New Issue