diff options
Diffstat (limited to 'bin/extra')
| -rwxr-xr-x | bin/extra/clock | 62 | ||||
| -rwxr-xr-x | bin/extra/curszip | 12 | ||||
| -rwxr-xr-x | bin/extra/ddsurf | 4 | ||||
| -rwxr-xr-x | bin/extra/igdl | 21 | ||||
| -rw-r--r-- | bin/extra/keyboards.txt | 2 | ||||
| -rwxr-xr-x | bin/extra/mtr | 23 | ||||
| -rwxr-xr-x | bin/extra/muz-sync | 10 | ||||
| -rwxr-xr-x | bin/extra/myalscore.sh | 7 | ||||
| -rwxr-xr-x | bin/extra/qrclip | 12 | ||||
| -rwxr-xr-x | bin/extra/spschedule | 2 | ||||
| -rwxr-xr-x | bin/extra/trl | 101 | ||||
| -rwxr-xr-x | bin/extra/trmv | 13 | ||||
| -rwxr-xr-x | bin/extra/udict | 12 | 
13 files changed, 197 insertions, 84 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/curszip b/bin/extra/curszip index 64abdb6..0de772f 100755 --- a/bin/extra/curszip +++ b/bin/extra/curszip @@ -1,13 +1,17 @@  #!/bin/sh -list1() { find "$1" -mindepth 1 -maxdepth 1 -type "${2:-d}" -printf '%f\n'; } +# $1: dir  +# $2: type +list1() { find "$1" -mindepth 1 -maxdepth 1 -type "$2" -printf '%f\n'; } -curs="$(list1 ~/docs/school/Vakken | commander -c)" +curs="$(list1 ~/docs/school/Vakken d | dmenu -c)"  [ "$curs" ] || exit 1 -zip="$(list1 ~/dl f | fzf -f "$curs" | grep '\.zip$')"  >&2 printf "curs: %s\n" "$curs" -[ "$zip" ] || exit 1 +dldir="$(which xdg-user-dir > /dev/null 2>&1 && xdg-user-dir 'DOWNLOAD' || echo '~/dl')" + +zip="$(list1 "$dldir" f | fzf -f "$curs" | grep '\.zip$')" +[ "$zip" ] || exit 1  >&2 printf "zip: %s\n" "$zip"  cd -- ~/docs/school/Vakken/"$curs" || exit 1 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/keyboards.txt b/bin/extra/keyboards.txt index db004ce..d6e9b8a 100644 --- a/bin/extra/keyboards.txt +++ b/bin/extra/keyboards.txt @@ -1,2 +1,2 @@  us -us -option ctrl:swapcaps,altwin:menu_win -variant colemak +colemak -option ctrl:swapcaps,altwin:menu_win 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/qrclip b/bin/extra/qrclip new file mode 100755 index 0000000..f9dc92e --- /dev/null +++ b/bin/extra/qrclip @@ -0,0 +1,12 @@ +#!/bin/sh +case $1 in +	'-o') +		qrencode -s 16 "$(clipo)" -o - | +			imv -w "imv - $(clipo)" - ;; +	'-s') +		qrencode -s 16 "https://duckduckgo.com/$(clipo)" -o - | +			imv -w "imv - search $(clipo)" - ;; +    *) +        >&2 printf 'qrclip [-s | -o]\n' +        exit 1 +esac 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/trl b/bin/extra/trl index ee42040..55d65ee 100755 --- a/bin/extra/trl +++ b/bin/extra/trl @@ -1,20 +1,8 @@  #!/bin/sh -# prints on stderr -log () { >&2 echo "$@"; } +# Translate words using http://context.reverso.net and scraping the answers +# with 'pup' and 'curl'. -help ()  -{ -	 >&2 cat <<-EOF -	  h         help -	  l         clear output -	  q         quit - -	  i         invert languages -	  p         select primary -	  s         select secondary -	EOF -}  # returns available languages  languages () {  	cat <<-EOF @@ -46,70 +34,25 @@ languages () {  	EOF  } -# translates a word -# $1: primary language -# $2: secondary language -# $3: word to translate -translate () -{ -	curl -s "https://context.reverso.net/translation/$1-$2/$3" \ -	--compressed \ -	-H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0' \ -	-H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \ -	-H 'Accept-Language: en-US,en;q=0.5' \ -	-H 'Accept-Encoding: gzip, deflate, br' | -	pup 'a.link_highlighted em text{}' | -	sed 's/.*/\L&/' | -	sort | uniq | sed 's/.*/  &/' -} - -# prints the current language -current_language () -{ -	log "  current: $primary-$secondary" -} - -select_language () -{ -	tmp="$(languages | fzf)" -	[ "$tmp" ] && [ "$tmp" != "$primary" ] && [ "$tmp" != "$secondary" ] && -		eval "$1=\"$tmp\"" -	current_language -} - -# set default languages -primary=french -secondary=dutch - - -main () -{ -	current_language -	while true -	do -		log -n '>' -		read -r prompt  -		test $? -eq 1 && exit 0 # quit on ctrl-d -		case "$prompt" in -			q) break ;; -			l) clear ;; -			i) tmp="$secondary"; secondary="$primary"; primary="$tmp" -				current_language ;; -			h) help ;; # TODO -			p) select_language primary ;; -			s) select_language secondary ;; -			'') ;; -			*) translate "$primary" "$secondary" "$prompt" ;; -		esac -	done -} - - -if  [ "$1" = "--help"  ] || [ "$1" = "-h" ] +if [ -z "${word:=$1}" ]  then -	log "usage: trl" -	help -	exit +    >&2 printf '>' +    word="$(head -n1)"  fi - -main +[ "$word" ] || exit 1 + +primary="$(languages | fzf --prompt="from:")" +[ "$primary" ] || exit 1 + +secondary="$(languages | fzf --prompt="to:")" +[ "$secondary" ] || exit 1 + +curl -s "https://context.reverso.net/translation/$primary-$secondary/$word" \ +    --compressed \ +    -H 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/116.0' \ +    -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' \ +    -H 'Accept-Language: en-US,en;q=0.5' \ +    -H 'Accept-Encoding: gzip, deflate, br' | +    pup 'a.link_highlighted em text{}' | +    sed 's/.*/\L&/' | +    sort | uniq | sed 's/.*/  &/' 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)" diff --git a/bin/extra/udict b/bin/extra/udict new file mode 100755 index 0000000..77f9747 --- /dev/null +++ b/bin/extra/udict @@ -0,0 +1,12 @@ +#!/bin/sh + +[ $# -eq 0 ] && printf '%s\n' "Usage: +    udict some term" && exit 1 + +term="$@" + +term="$(printf '%s\n' "${term}" | sed 's/ /\\/g' )" + +curl -s "https://api.urbandictionary.com/v0/define?term=${term}" | +	jq -r '.list[0] | .word, .definition' | +	sed -e 's/\[/\o033[1m/g' -e 's/\]/\o033[0m/g' -e '1s/^.*$/\o033[1;4;34m&\o033[0m/'  | 
