diff options
Diffstat (limited to 'bin/extra')
-rwxr-xr-x | bin/extra/append2mpv | 30 | ||||
-rwxr-xr-x | bin/extra/mariadb-adduser | 25 | ||||
-rwxr-xr-x | bin/extra/oclipp | 2 | ||||
-rwxr-xr-x | bin/extra/sgimg | 6 |
4 files changed, 63 insertions, 0 deletions
diff --git a/bin/extra/append2mpv b/bin/extra/append2mpv new file mode 100755 index 0000000..28c3916 --- /dev/null +++ b/bin/extra/append2mpv @@ -0,0 +1,30 @@ +#!/bin/sh +IPC="/tmp/mpvsocket" + +die () { >&2 printf '%s\n' "$@"; exit 1; } +append_to_mpv() +{ + file="$(readlink -f "$1")" + if [ ! -r "$file" ] + then + >&2 printf '%s\n' "'$file' not found" + return + fi + + echo '{ "command": ["loadfile", "'"$file"'", "append"] }' | + socat - "$IPC" +} + +[ -S "$IPC" ] || die "$IPC is not a socket or doesn't exist" +which socat > /dev/null || exit 1 + + +if [ -t 0 ] +then + append_to_mpv "$1" +else + while read -r file + do + append_to_mpv "$file" + done +fi diff --git a/bin/extra/mariadb-adduser b/bin/extra/mariadb-adduser new file mode 100755 index 0000000..d4e1b45 --- /dev/null +++ b/bin/extra/mariadb-adduser @@ -0,0 +1,25 @@ +#!/bin/sh +if [ "$(id -u)" -ne 0 ] +then + >&2 printf "Not root.\n" + exit 1 +fi + +printf 'name? ' +name="$(head -n 1)" +printf 'password? ' +password="$(head -n 1)" +printf 'database? ' +database="$(head -n 1)" + +( + cat <<EOF + CREATE USER '$name'@'%' IDENTIFIED BY '$password'; +EOF + [ "$database" ] && cat <<EOF + GRANT ALL PRIVILEGES ON `$database`.* TO '$name'@'%' WITH GRANT OPTION; + CREATE DATABASE `$database`; + FLUSH PRIVILEGES; +EOF + +) | mariadb diff --git a/bin/extra/oclipp b/bin/extra/oclipp new file mode 100755 index 0000000..b711385 --- /dev/null +++ b/bin/extra/oclipp @@ -0,0 +1,2 @@ +#!/bin/sh +printf "\033]52;c;%s\a" "$(cat | base64)" diff --git a/bin/extra/sgimg b/bin/extra/sgimg new file mode 100755 index 0000000..acb8126 --- /dev/null +++ b/bin/extra/sgimg @@ -0,0 +1,6 @@ +#!/bin/sh + +imv "$(find ~/.local/share/gurk/ -type f \( -iname '*.png' -o -iname '*.jpg' \) -printf "%A@\t%p\n" | + sort -n | + tail -n 1 | + cut -f 2-)" |