summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/common/ask38
-rwxr-xr-xbin/common/targit5
-rwxr-xr-xbin/common/ytclipo12
-rwxr-xr-xbin/extra/aivpn6
-rwxr-xr-xbin/extra/append2mpv30
-rwxr-xr-xbin/extra/cht.sh2
-rwxr-xr-xbin/extra/sgimg6
-rwxr-xr-xbin/extra/supd22
-rwxr-xr-xbin/guiscripts/clipo6
-rwxr-xr-xbin/guiscripts/clipp6
-rwxr-xr-xbin/guiscripts/clipswap4
-rwxr-xr-xbin/guiscripts/cliptype2
-rwxr-xr-xbin/guiscripts/dmfm3
-rwxr-xr-xbin/menuscripts/memoji17
14 files changed, 87 insertions, 72 deletions
diff --git a/bin/common/ask b/bin/common/ask
index 9fb04ce..95530f5 100755
--- a/bin/common/ask
+++ b/bin/common/ask
@@ -1,36 +1,4 @@
#!/bin/sh
-
-# requirements
-which pass jq > /dev/null ||
- exit 1
-
-# input
-test -z "${inp:=$@}" &&
- inp="$(cat /dev/stdin)"
-
-# \n\t -> ' ' && "->'
-prompt="$(echo "$inp" | tr "\n\t\"" " '")"
-test -z "$prompt" && exit 1
-
-API_KEY="$(pass tokens/openai-api)"
-model="text-davinci-003"
-tokens="1024"
-temperature=0
-
-data=$(echo \
-'{
- "prompt": "'"$prompt"'",
- "model": "'"$model"'",
- "max_tokens": '$tokens',
- "temperature": '$temperature'
-}')
-
-output=$(curl -s -X POST \
- -H 'Content-Type: application/json' \
- -H "Authorization: Bearer $API_KEY" \
- -d "$data" \
- https://api.openai.com/v1/completions \
- | jq -r '.choices[0].text')
-
-# remove newline
-echo "${output:1}"
+which tgpt >/dev/null || exit 1
+[ "${inp:=$@}" ] || inp="$(cat /dev/stdin)"
+tgpt "$inp"
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..959ee21 100755
--- a/bin/common/ytclipo
+++ b/bin/common/ytclipo
@@ -11,9 +11,13 @@ 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/')"
+# remove util scheme
+inp="${inp#*//}"
+# convert to youtube.com/path url
+# works for:
+# - 'youtu.be/watch?v=xxxxxx'
+# - 'https://piped.video/watch?v=xxxxx'
+inp="https://youtube.com/${inp#*/}"
>&2 printf "inp: %s\n" "$inp"
notify-send "ytclipo" "downloading <i>$inp</i>" || :
@@ -23,5 +27,5 @@ yt-dlp "$inp" \
-f "b" \
-S "res:1080" \
-P "$HOME/vids/youtube/" \
- -o "%(channel)s - %(title)s.%(ext)s"
+ -o "%(channel)s/%(title)s.%(ext)s"
notify-send "ytclipo" "finished downloading." || :
diff --git a/bin/extra/aivpn b/bin/extra/aivpn
index fd72ffb..3c87ce8 100755
--- a/bin/extra/aivpn
+++ b/bin/extra/aivpn
@@ -33,9 +33,3 @@ ssh vm "rasdial \"vpn.student.ehb.be\""
ssh -f -N \
-L 2222:10.2.160.41:22 \
vm
-
-ssh -t \
- -L 8188:localhost:8188 \
- vm \
- ssh -N -L 8188:localhost:8188 luca@10.2.160.41
-logn "[8188], [2222]"
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/cht.sh b/bin/extra/cht.sh
index 681fc69..f373e55 100755
--- a/bin/extra/cht.sh
+++ b/bin/extra/cht.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
# shellcheck disable=SC1117,SC2001
#
# [X] open section
diff --git a/bin/extra/sgimg b/bin/extra/sgimg
new file mode 100755
index 0000000..7c1823c
--- /dev/null
+++ b/bin/extra/sgimg
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+imv "$(find ~/.local/share/gurk/ -type f -printf "%A@\t%p\n" |
+ sort -n |
+ tail -n 1 |
+ cut -f 2-)"
diff --git a/bin/extra/supd b/bin/extra/supd
index 48638bd..9a5ce0c 100755
--- a/bin/extra/supd
+++ b/bin/extra/supd
@@ -7,7 +7,7 @@ then
>&2 cat <<-EOF
usage:
supd Update dirs in current dir
- ls ~/projects | supd Update dirs read from stdin
+ ... | supd Update dirs read from stdin
supd -h Show help
EOF
exit
@@ -17,16 +17,22 @@ fi
for dir in $dirs
do
- printf '%s:' "$dir" | >&2 sed "s#$HOME#~#"
(
cd "$dir" || return
+ # is git dir
+ if ! git rev-parse > /dev/null 2>&1
+ then
+ printf 'x\n'
+ exit
+ fi
+ printf '%s: ' "$dir" | >&2 sed "s#$HOME#~#"
git "${1:-fetch}" > /dev/null 2>&1 &&
- printf ' o' ||
- printf ' x'
+ printf 'o' ||
+ printf 'x'
# Show remote state
- printf '%s %s\n' "$(git status --short 2> /dev/null |
- awk 'NR==1 {print $1}')" "$(git branch -v 2>/dev/null |
- awk -F '[][]' '/^\*/ {print $2}')" |
- sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*/ /g'
+ printf ' %s%s\n' "$(git status --short 2> /dev/null |
+ awk 'NR==1 {print "(" $1 ")"}')" "$(git branch -v 2>/dev/null |
+ awk -F '[][]' '/^\*/ {print $2}' |
+ sed 's/ahead/↑ /;s/behind/↓ /;s/[^↓↑]*//g')"
)
done
diff --git a/bin/guiscripts/clipo b/bin/guiscripts/clipo
new file mode 100755
index 0000000..39994f9
--- /dev/null
+++ b/bin/guiscripts/clipo
@@ -0,0 +1,6 @@
+#!/bin/sh
+[ "$1" = "-p" ] && arg='primary'
+if [ "$WAYLAND_DISPLAY" ]
+then wl-paste -n ${1}
+else xclip -o -selection "${arg:-clipboard}" -r
+fi
diff --git a/bin/guiscripts/clipp b/bin/guiscripts/clipp
new file mode 100755
index 0000000..c9e4f51
--- /dev/null
+++ b/bin/guiscripts/clipp
@@ -0,0 +1,6 @@
+#!/bin/sh
+[ "$1" = "-p" ] && arg='primary'
+if [ "$WAYLAND_DISPLAY" ]
+then wl-copy -n $1
+else xclip -selection "${arg:-clipboard}" -r
+fi
diff --git a/bin/guiscripts/clipswap b/bin/guiscripts/clipswap
new file mode 100755
index 0000000..1cae135
--- /dev/null
+++ b/bin/guiscripts/clipswap
@@ -0,0 +1,4 @@
+#!/bin/sh
+paste="$(clipo)"
+clipo -p | clipp
+printf '%s' "$paste" | clipp -p
diff --git a/bin/guiscripts/cliptype b/bin/guiscripts/cliptype
new file mode 100755
index 0000000..e6ac093
--- /dev/null
+++ b/bin/guiscripts/cliptype
@@ -0,0 +1,2 @@
+#!/bin/sh
+clipo | ydotool type -f -
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/menuscripts/memoji b/bin/menuscripts/memoji
index 9c45950..45a74f1 100755
--- a/bin/menuscripts/memoji
+++ b/bin/menuscripts/memoji
@@ -5,30 +5,19 @@
# If this file includes emojis below "__DATA__" it is generated.
# This file was generated: 2022-04-21 12:38:03+00:00
-if [ "$WAYLAND_DISPLAY" ]
-then
- alias copycmd="wl-copy"
-else
- alias copycmd="xclip -sel c"
-fi
set -e
case "$1" in
- "list")
- data=$(sed '0,/^__DATA__$/d' "$0")
- printf "%s" "$data"
- ;;
+ "list") printf "%s" "$(sed '0,/^__DATA__$/d' "$0")" ;;
"copy")
input=$(tee | cut -f 1 -d ' ')
if [ "$input" ]
then
notify-send "dmemoji" "$input <b>copied!</b>"
- printf "%s" "$input" | copycmd
+ printf "%s" "$input" | clipp
fi
;;
- "")
- sh "$0" list | commander -p "Emoji:" -l -x | sh "$0" copy
- ;;
+ "") sh "$0" list | commander -p "Emoji:" -x -w 44 -y 10 -c | sh "$0" copy ;;
esac
exit