summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/common/targit5
-rwxr-xr-xbin/common/ytclipo21
-rwxr-xr-xbin/common/ytlink14
-rwxr-xr-xbin/extra/append2mpv30
-rwxr-xr-xbin/extra/mariadb-adduser25
-rwxr-xr-xbin/extra/oclipp2
-rwxr-xr-xbin/extra/sgimg6
-rwxr-xr-xbin/guiscripts/dmfm3
-rwxr-xr-xbin/guiscripts/getdisplays3
-rwxr-xr-xbin/guiscripts/linkhandler8
-rwxr-xr-xbin/guiscripts/startdwl5
-rwxr-xr-xbin/guiscripts/sturl6
-rwxr-xr-xbin/guiscripts/torque4
-rwxr-xr-xbin/menuscripts/mmpv8
-rwxr-xr-xbin/menuscripts/mpass-otp7
15 files changed, 118 insertions, 29 deletions
diff --git a/bin/common/targit b/bin/common/targit
index ae046ac..ca560b3 100755
--- a/bin/common/targit
+++ b/bin/common/targit
@@ -1,6 +1,5 @@
#!/bin/sh
-pwd=$(pwd)
root="$(git rev-parse --show-toplevel)"
cd "$root" || exit 1
-file="$(basename "$root" | sed 's/^\.//').tar.gz"
-tar czf "$pwd/$file" $(git ls-files)
+file="${root##*/}".tar.gz
+tar czf "$file" $(git ls-files)
diff --git a/bin/common/ytclipo b/bin/common/ytclipo
index 5d86c3f..6416a15 100755
--- a/bin/common/ytclipo
+++ b/bin/common/ytclipo
@@ -1,21 +1,8 @@
#!/bin/sh
-# argument ($1) -> clipboard -> stdin
-if [ "$WAYLAND_DISPLAY" ]
-then paste() { wl-paste; }
-elif [ "$TERMUX_VERSION" ]
-then paste() { termux-clipboard-get; }
-else paste() { xclip -o -sel c; }
-fi
-
-inp="$1"
-[ "${inp:=$(paste)}" ] || inp="$(cat /dev/stdin)"
-
-# take last link from clipboard
-# works when link is from yt-local
-inp="https://youtu.be/$(echo "$inp" | sed 's/.*\(.\{11\}\)$/\1/')"
+inp="$(ytlink)"
>&2 printf "inp: %s\n" "$inp"
-notify-send "ytclipo" "downloading <i>$inp</i>" || :
+# notify-send "ytclipo" "downloading <i>$inp</i>" || :
yt-dlp "$inp" \
--restrict-filenames \
@@ -23,5 +10,5 @@ yt-dlp "$inp" \
-f "b" \
-S "res:1080" \
-P "$HOME/vids/youtube/" \
- -o "%(channel)s - %(title)s.%(ext)s"
-notify-send "ytclipo" "finished downloading." || :
+ -o "%(channel)s/%(title)s.%(ext)s"
+# notify-send "ytclipo" "finished downloading." || :
diff --git a/bin/common/ytlink b/bin/common/ytlink
new file mode 100755
index 0000000..a5e9bf0
--- /dev/null
+++ b/bin/common/ytlink
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# convert to youtube.com/path url
+# works for:
+# - 'youtu.be/watch?v=xxxxxx'
+# - 'https://piped.video/watch?v=xxxxx'
+
+inp="$1"
+[ "${inp:=$(clipo)}" ] || inp="$(cat /dev/stdin)"
+
+# remove util scheme
+inp="${inp#*//}"
+inp="https://youtube.com/${inp#*/}"
+printf "%s" "$inp"
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-)"
diff --git a/bin/guiscripts/dmfm b/bin/guiscripts/dmfm
index d1dd8b8..9485469 100755
--- a/bin/guiscripts/dmfm
+++ b/bin/guiscripts/dmfm
@@ -2,9 +2,10 @@
while true
do
+ dir="$(printf '%s' "$PWD" | sed "s#^$HOME#\~#;s#\([^/]\)[^/]*/#\1/#g")"
file=$(find . -maxdepth 1 -mindepth 1 -not -name '.*' -printf '%y\t%f\n' |
sort -k 1 -k 2 | cut -f 2- |
- commander -xcd -p "$PWD>")
+ commander -xc -p "$dir")
[ "$file" ] || break
[ ! -e "$file" ] && continue
diff --git a/bin/guiscripts/getdisplays b/bin/guiscripts/getdisplays
new file mode 100755
index 0000000..8712b30
--- /dev/null
+++ b/bin/guiscripts/getdisplays
@@ -0,0 +1,3 @@
+#!/bin/sh
+grep -l '^connected$' /sys/class/drm/*/status |
+ sed 's@^/sys/class/drm/[^-]*-\(.*\)/status$@\1@'
diff --git a/bin/guiscripts/linkhandler b/bin/guiscripts/linkhandler
index aeec202..329e267 100755
--- a/bin/guiscripts/linkhandler
+++ b/bin/guiscripts/linkhandler
@@ -11,6 +11,12 @@ test -z "${url:=$1}" &&
dunstify "linkhandler" "<b>handling</b> $url"
case "$url" in
+ file://*) file="${url##file:/}"
+ case "$(file -bi "$file" | cut -f1 -d'/')" in
+ audio|video) mpv "$file" ;;
+ image) imv "$file" ;;
+ *) xdg-open "$file" ;;
+ esac ;;
*mkv|*webm|*mp4|*youtube.com/watch*|*youtube.com/playlist*|*youtube.com/shorts*|*youtu.be*|*hooktube.com*|*bitchute.com*|*videos.lukesmith.xyz*|*odysee.com*)
setsid -f mpv --quiet --ytdl --ytdl-raw-options="format-sort=res:720" "$url" > /dev/null 2>&1 ;;
*png|*jpg|*jpe|*jpeg|*gif)
@@ -18,7 +24,7 @@ case "$url" in
*pdf|*cbz|*cbr)
curl -sL "$url" > "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" && $VIEWER "/tmp/$(echo "$url" | sed "s/.*\///;s/%20/ /g")" >/dev/null 2>&1 & ;;
*mp3|*flac|*opus|*mp3?source*)
- qndl "$url" 'curl -LO' >/dev/null 2>&1 ;;
+ mpv "$url" 'curl -LO' >/dev/null 2>&1 ;;
*)
if [ -f "$url" ]
then setsid -f "$TERMINAL" -e "$EDITOR" "$url" >/dev/null 2>&1
diff --git a/bin/guiscripts/startdwl b/bin/guiscripts/startdwl
index bb5fec0..039f506 100755
--- a/bin/guiscripts/startdwl
+++ b/bin/guiscripts/startdwl
@@ -39,6 +39,7 @@ export IMAGE="imv"
# env = __GLX_VENDOR_LIBRARY_NAME,nvidia
# env = WLR_NO_HARDWARE_CURSORS,1
-while true;
-do dwl -s "$HOME"/.config/dwl/startup.sh
+while true
+do
+ dwl -s "$HOME"/.config/dwl/startup.sh
done
diff --git a/bin/guiscripts/sturl b/bin/guiscripts/sturl
index c738c8e..5b8b1e7 100755
--- a/bin/guiscripts/sturl
+++ b/bin/guiscripts/sturl
@@ -1,11 +1,11 @@
#!/bin/sh
-regex='(((https?|gopher|gemini|ftps?|git)://|www\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|(magnet:\?xt=urn:btih:[a-zA-Z0-9]*)'
-url="$(tr -d '\n' | grep -Eo "$regex" | dmenu -x -c -g 1 -l 10)"
+regex='(((file|https?|gopher|gemini|ftps?|git)://|www\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|(magnet:\?xt=urn:btih:[a-zA-Z0-9]*)'
+url="$(tr -d '\n' | grep -Eo "$regex" | tac | commander -cl)"
[ -z "$url" ] && exit 1
case $1 in
- 'c') echo -n "$url" | xclip -sel c -r ;;
+ 'c') printf '%s' "$url" | xclip -sel c -r ;;
'o') linkhandler "$url" ;;
*) echo "no option" ;;
esac
diff --git a/bin/guiscripts/torque b/bin/guiscripts/torque
index 51e2806..8f939e1 100755
--- a/bin/guiscripts/torque
+++ b/bin/guiscripts/torque
@@ -47,8 +47,8 @@ prompt() {
r) read -rp "remove torrent: #"; send -t "$REPLY" -r; k=0 ;;
o) read -rp "load magnet: "; send -a "$REPLY"; k=0 ;;
m)
- read -rp "move torrent: " torrent
- read -rp "destination folder: "
+ read -rp "move torrent: #" torrent
+ read -rp "destination folder: /downloads/"
send -t "$torrent" --move "/downloads/$REPLY"
;;
j) ((j==${#t[@]}))||((k=k>=j?k:++k,j=j<${#t[@]}?++j:j)) ;;
diff --git a/bin/menuscripts/mmpv b/bin/menuscripts/mmpv
new file mode 100755
index 0000000..76c0d6a
--- /dev/null
+++ b/bin/menuscripts/mmpv
@@ -0,0 +1,8 @@
+#!/bin/sh
+# Have an mpv instance that works with a socket somewhat globally
+socket="/tmp/mpvsocket"
+# Start mpv in idle if socket is not getting listened to
+nc -zvU "$socket" || setsid mpv --input-ipc-server=/tmp/mpvsocket --idle &
+file="$(PLAYER='echo' mmedia video)"
+[ "$file" ] || exit 1
+echo '{ "command": ["loadfile", "'"$file"'", "append-play"] }' | nc -U /tmp/mpvsocket
diff --git a/bin/menuscripts/mpass-otp b/bin/menuscripts/mpass-otp
new file mode 100755
index 0000000..e771f9f
--- /dev/null
+++ b/bin/menuscripts/mpass-otp
@@ -0,0 +1,7 @@
+#!/bin/sh
+pass="$(find "$PASSWORD_STORE_DIR"/keys/otp -name "*.gpg" -printf '%f\n' |
+ sed 's/\.gpg$//' |
+ commander -c)"
+[ "$pass" ] || exit 1
+pass otp -c keys/otp/"$pass"
+notify-send -t 1000 "mpass" "copied <b>$pass</b>"