summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbin/extra/clock62
-rwxr-xr-xbin/extra/ddsurf4
-rwxr-xr-xbin/extra/igdl21
-rwxr-xr-xbin/extra/mtr23
-rwxr-xr-xbin/extra/muz-sync10
-rwxr-xr-xbin/extra/myalscore.sh7
-rwxr-xr-xbin/extra/spschedule2
-rwxr-xr-xbin/extra/trmv13
8 files changed, 142 insertions, 0 deletions
diff --git a/bin/extra/clock b/bin/extra/clock
new file mode 100755
index 0000000..fdffae0
--- /dev/null
+++ b/bin/extra/clock
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+clocks="${XDG_DATA_HOME:-$HOME}"/clocks.csv
+
+if [ ! -f "$clocks" ]
+then
+ printf 'start,end,message\n' > "$clocks"
+fi
+
+if [ "$1" = "-c" ]
+then
+ # empty
+ [ "$(wc -l < "$clocks")" -eq 1 ] && exit
+
+ timefmt="%y%m%d-%T"
+ IFS=","
+ # skip csv header
+ tail -n +2 "$clocks" |
+ while read -r start end message
+ do
+ printf "%s - %s | %s\n" "$(date -d "@$start" +"$timefmt" )" "$(date -d "@$end" +"$timefmt")" "$message"
+ done
+ exit
+fi
+
+if [ "$1" = "-e" ]
+then
+ $EDITOR "$clocks"
+ exit
+fi
+
+trap 'exit 0' INT # The proper way to exit
+
+while true
+do
+ >&2 printf ' > '
+ message="$(head -n 1)"
+
+ [ "$message" ] || exit 1
+ printf '\033[1A' # move cursor up once: https://en.wikipedia.org/wiki/ANSI_escape_code
+
+ start_time="$(date +%s)"
+ start_time_pretty="$(date -d "@$start_time" +%R)"
+ >&2 printf -- '\r%s- > %s' "$start_time_pretty" "$message"
+
+ # Wait for EOF
+ cat > /dev/null 2>&1
+
+ end_time="$(date +%s)"
+ end_time_pretty="$(date -d "@$end_time" +%R)"
+ >&2 printf -- '\r%s-%s > %s\n' "$start_time_pretty" "$end_time_pretty" "$message"
+
+ if printf '%s' "$message" | grep ',' > /dev/null
+ then
+ # escape potential double quotes
+ message="$(printf '%s' "$message" | sed -e 's/"/""/g')"
+ message="\"$message\""
+ fi
+
+ # save clocked time and message
+ printf '%s,%s,%s\n' "$start_time" "$end_time" "$message" >> "$clocks"
+done
diff --git a/bin/extra/ddsurf b/bin/extra/ddsurf
new file mode 100755
index 0000000..a3ae0d1
--- /dev/null
+++ b/bin/extra/ddsurf
@@ -0,0 +1,4 @@
+#!/bin/sh
+f="$(mktemp)"
+awk '!x[$2]++' ~/.config/surf/history.txt > "$f"
+mv "$f" ~/.config/surf/history.txt
diff --git a/bin/extra/igdl b/bin/extra/igdl
new file mode 100755
index 0000000..1973187
--- /dev/null
+++ b/bin/extra/igdl
@@ -0,0 +1,21 @@
+#!/bin/sh
+lock="/tmp/igdl.lock"
+
+if [ -f "$lock" ]
+then
+ herbe "already downloading."
+ exit 1
+fi
+
+
+url="$(clipo)"
+out="/tmp/igdl.mp4"
+
+touch "$lock"
+herbe "igdl" "downloading: $url" &
+yt-dlp "$url" -o "$out" || rm "$lock"
+
+printf '%s' "$out" | clipp
+herbe "igdl" "copied path."
+
+rm "$lock"
diff --git a/bin/extra/mtr b/bin/extra/mtr
new file mode 100755
index 0000000..486a9b8
--- /dev/null
+++ b/bin/extra/mtr
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+list_categories()
+{
+ cat <<EOF
+music
+anime
+movies
+shows
+other
+software
+games
+isos
+books
+EOF
+}
+
+category="$(list_categories | commander -cl)"
+[ "$category" ] || exit 1
+
+transmission-remote debuc.com -a "$(clipo)" -w "/downloads/$category"
+
+notify-send "mtr" "added to <b>$category</b>"
diff --git a/bin/extra/muz-sync b/bin/extra/muz-sync
new file mode 100755
index 0000000..a81ef74
--- /dev/null
+++ b/bin/extra/muz-sync
@@ -0,0 +1,10 @@
+#!/bin/sh
+trap "exit 1" INT
+
+music="$(xdg-user-dir MUSIC)"
+>&2 printf "music: %s\n" "$music"
+
+# recursive, links, fuzzy, partial, progress
+while ! rsync -rlyP --size-only db:/media/basilisk/music/sorted/ "$music"
+do :
+done
diff --git a/bin/extra/myalscore.sh b/bin/extra/myalscore.sh
new file mode 100755
index 0000000..ef68bcc
--- /dev/null
+++ b/bin/extra/myalscore.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+[ "$1" ] || exit 1
+query="$(printf '%s' "$*" | sed 's/\s/%20/g')"
+curl -s "https://myanimelist.net/search/prefix.json?type=all&keyword=$query&v=1" \
+ -H 'Accept: application/json, text/javascript, */*; q=0.01' |
+ jq -r '.categories[].items[] | [.payload.score, .name] | join(" ")'
diff --git a/bin/extra/spschedule b/bin/extra/spschedule
new file mode 100755
index 0000000..b0dd70a
--- /dev/null
+++ b/bin/extra/spschedule
@@ -0,0 +1,2 @@
+#!/bin/sh
+curl -s 'https://subsplease.org/api/?f=schedule&tz=UTC' | jq -r ".schedule.$(date +%A).[] | [.time, .title] | join(\" \")"
diff --git a/bin/extra/trmv b/bin/extra/trmv
new file mode 100755
index 0000000..22d9e48
--- /dev/null
+++ b/bin/extra/trmv
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+trr() { transmission-remote 192.168.178.79 "$@"; }
+
+id="$(trr -t all -l | tail -n +2 | head -n -1 | fzf | awk '{print $1}')"
+[ "$id" ] || exit 1
+name="$(trr -t "$id" -i | grep '^\s*Name:' | cut -f 4- -d ' ')"
+location="$(trr -t "$id" -i | grep '^\s*Location:' | cut -f 4- -d ' ')"
+
+>&2 printf '#%s\n' "$id"
+>&2 printf "old name: %s\n" "$name"
+>&2 printf 'new name: '
+trr -t "$id" --path "$name" --rename "$(head -n 1)"