radio: files: .local/bin

impermanence
Luis Guilherme Coelho 2024-03-23 03:11:36 -03:00
parent 8a45491a28
commit 600eb74830
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
6 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,116 @@
#!/bin/sh
set -exu
WIDTH=$2
HEIGHT=$3
image() {
chafa -f sixel \
-s "$((${WIDTH}-2))x$((${HEIGHT}-2))" \
--polite on \
--animate on "$1"
}
batorcat() {
shift
if command -v bat > /dev/null 2>&1; then
bat --color=always --style=plain --pager=never "$1"
else
cat "$1"
fi
}
FILE=$(readlink -f "$1")
CACHE="$HOME/.cache/lf/thumbnail.$(stat --printf '%n\0%i\0%F\0%s\0%W\0%Y' -- "$FILE" | sha256sum | awk '{print $1}')"
case "${FILE}" in
*.bmp|*.jpg|*.jpeg|*.png|*.xpm|*.webp|*.gif|*.jfif)
image "${FILE}"
exit 1
;;
*.pdf)
[ ! -f "${CACHE}.jpg" ] && pdftoppm -jpeg -f 1 -singlefile "${FILE}" "${CACHE}"
image "${CACHE}.jpg"
exit 1
;;
*.svg)
[ ! -f "${CACHE}.jpg" ] && convert "${FILE}" "${CACHE}.jpg"
image "${CACHE}.jpg"
exit 1
;;
*.avi|*.mp4|*.wmv|*.dat|*.3gp|*.ogv|*.mkv|*.mpg|*.mpeg|*.vob|*.fl[icv]|*.m2v|*.mov|*.webm|*.ts|*.mts|*.m4v|*.r[am]|*.qt|*.divx)
[ ! -f "${CACHE}.jpg" ] && ffmpegthumbnailer -i "${FILE}" -o "${CACHE}.jpg" -s 0 -q 5
image "${CACHE}.jpg"
exit 1
;;
*.wav|*.mp3|*.flac|*.m4a|*.wma|*.ape|*.ac3|*.og[agx]|*.spx|*.opus|*.as[fx]|*.mka)
exiftool "${FILE}"
;;
*.epub)
[ ! -f "${CACHE}" ] && epub-thumbnailer "${FILE}" "${CACHE}" 1024
image "${CACHE}"
;;
*.cbz|*.cbr|*.cbt)
[ ! -f "${CACHE}" ] && comicthumb "${FILE}" "${CACHE}" 1024
image "${CACHE}"
;;
*.tgz|*.tar.gz)
tar tzf "${FILE}"
;;
*.tar.bz2|*.tbz2)
tar tjf "${FILE}"
;;
*.tar.txz|*.txz)
xz --list "${FILE}"
;;
*.tar)
tar tf "${FILE}"
;;
*.zip|*.jar|*.war|*.ear|*.oxt)
unzip -l "${FILE}"
;;
*.rar)
unrar l "${FILE}"
;;
*.md)
glow -s dark "${FILE}"
;;
*.7z)
7z l "${FILE}"
;;
*.[1-8])
man "${FILE}" | col -b
;;
*.o)
nm "${FILE}"
;;
*.torrent)
transmission-show "${FILE}"
;;
*.iso)
iso-info --no-header -l "${FILE}"
;;
*.odt|*.ods|*.odp|*.sxw)
odt2txt "${FILE}"
;;
*.doc)
catdoc "${FILE}"
;;
*.docx)
docx2txt "${FILE}" -
;;
*.xml|*.html)
w3m -dump "${FILE}"
;;
*.xls|*.xlsx)
ssconvert --export-type=Gnumeric_stf:stf_csv "${FILE}" "fd://1" | batorcat --language=csv
;;
*.ino)
batorcat --language=cpp "${FILE}"
;;
*)
cat "${FILE}"
;;
esac
exit 0

View File

@ -0,0 +1,13 @@
#!/bin/sh
if [ $# -gt 0 ] && [ $1 = "-r" ]; then
URL=https://c.xkcd.com/random/comic
else
URL=https://xkcd.com/
fi
URL=$(curl -s -L $URL \
| grep 'href= "https://imgs.xkcd.com/comics.*' \
| cut -d'>' -f2 \
| cut -d'<' -f1)
curl $URL --output /tmp/xkcd 2>/dev/null
chafa /tmp/xkcd

View File

@ -0,0 +1,3 @@
#!/bin/sh
setsid -f mpv av://v4l2:/dev/video0 --profile=low-latency --vf=hflip --untimed

View File

@ -0,0 +1,24 @@
#!/usr/bin/env -S guix shell bash -- bash
# Author: GekkoP
# Source: http://linuxbbq.org/bbs/viewtopic.php?f=4&t=1656#p33189
f=3 b=4
for j in f b; do
for i in {0..7}; do
printf -v $j$i %b "\e[${!j}${i}m"
done
done
d=$'\e[1m'
t=$'\e[0m'
v=$'\e[7m'
cat << EOF
$f0████$d▄$t $f1████$d▄$t $f2████$d▄$t $f3████$d▄$t $f4████$d▄$t $f5████$d▄$t $f6████$d▄$t $f7████$d▄$t
$f0████$d█$t $f1████$d█$t $f2████$d█$t $f3████$d█$t $f4████$d█$t $f5████$d█$t $f6████$d█$t $f7████$d█$t
$f0████$d█$t $f1████$d█$t $f2████$d█$t $f3████$d█$t $f4████$d█$t $f5████$d█$t $f6████$d█$t $f7████$d█$t
$d$f0 ▀▀▀▀ $d$f1 ▀▀▀▀ $f2▀▀▀▀ $f3▀▀▀▀ $f4▀▀▀▀ $f5▀▀▀▀ $f6▀▀▀▀ $f7▀▀▀▀$t
EOF

View File

@ -0,0 +1,21 @@
#!/bin/sh
case "$1" in
"activewindow")
# Get active window geometry
eval $(xdotool getactivewindow getwindowgeometry --shell)
REGION="$((${WIDTH} + 10))x$((${HEIGHT}+10))+$((${X}-5))+$((${Y}-5))"
maim -Bg "${REGION}" | xclip -selection clipboard -t image/png;;
"selectwindow")
# Let the user select a window and get its geometry
eval $(xdotool selectwindow getwindowgeometry --shell)
REGION="$((${WIDTH} + 10))x$((${HEIGHT}+10))+$((${X}-5))+$((${Y}-5))"
maim -Bg "${REGION}" | xclip -selection clipboard -t image/png;;
"selectregion")
maim -s | xclip -selection clipboard -t image/png;;
*)
# Get current screen
SCREEN=$(xdotool get_desktop)
REGION="$(hostname):${SCREEN}.1"
maim -u | xclip -selection clipboard -t image/png;;
esac

View File

@ -0,0 +1,19 @@
#!/bin/sh
set -exu
tty=$(tty)
tty=${tty#/dev/tty}
dir=$(which Xorg)
dir=${dir%/bin/Xorg}
display=0
while [ -e "/tmp/.X$display-lock" ] || [ -S "/tmp/.X11-unix/X$display" ]; do
: "$((display += 1))"
done
display=:$display
"$dir/bin/xinit" -- "$dir/bin/Xorg" "$display" "vt$tty" \
-keeptty \
-configdir "$dir/share/X11/xorg.conf.d" \
-modulepath "$dir/lib/xorg/modules"