diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-10-15 00:33:26 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-10-15 00:33:26 +0200 |
commit | 826ce094fecc4c6e07faf6e8b91387c2ae49842c (patch) | |
tree | 1820c843e4e260f6b51e8d269a972295a17e558c /bin/extra | |
parent | c032a9d071ee4b7eb2bfe79ec03d2a7dc4020f15 (diff) | |
parent | a915b5ade1a47b9678e2f9963b13b49dbd406031 (diff) |
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/extra')
-rwxr-xr-x | bin/extra/aivpn | 15 | ||||
-rwxr-xr-x | bin/extra/curszip | 17 | ||||
-rwxr-xr-x | bin/extra/dbnewg | 11 | ||||
-rwxr-xr-x | bin/extra/ehbtodl | 14 | ||||
-rwxr-xr-x | bin/extra/gml | 70 | ||||
-rwxr-xr-x | bin/extra/pomo | 31 | ||||
-rwxr-xr-x | bin/extra/supd | 38 |
7 files changed, 177 insertions, 19 deletions
diff --git a/bin/extra/aivpn b/bin/extra/aivpn index 55e013a..fd72ffb 100755 --- a/bin/extra/aivpn +++ b/bin/extra/aivpn @@ -4,7 +4,7 @@ logn() { printf "%s\n" "$@"; } if [ "$1" = "-k" ] then - pgrep -f -- "ssh.*-L.*mc-wd" | + pgrep -f -- "ssh.*-L.*vm" | xargs kill exit fi @@ -21,16 +21,21 @@ keyadd ehb/ai export SSH_ASKPASS="$0" export SSH_ASKPASS_REQUIRE="prefer" -export PASSWORD=aluc +export PASSWORD=zot/qemu + +logn "I: Waiting for connectivity..." +while ! ssh -o ConnectTimeout=1 -o BatchMode=yes vm 2>&1 | grep -q "Permission denied" +do sleep 1 +done logn "I: Activating vpn" -# ssh mc-wd "rasdial \"vpn.student.ehb.be\" \"luca.raymaekers@student.ehb.be\" \"$(pass school/login.ehb.be)\"" +ssh vm "rasdial \"vpn.student.ehb.be\"" ssh -f -N \ -L 2222:10.2.160.41:22 \ - mc-wd + vm ssh -t \ -L 8188:localhost:8188 \ - mc-wd \ + vm \ ssh -N -L 8188:localhost:8188 luca@10.2.160.41 logn "[8188], [2222]" diff --git a/bin/extra/curszip b/bin/extra/curszip new file mode 100755 index 0000000..6ab99e8 --- /dev/null +++ b/bin/extra/curszip @@ -0,0 +1,17 @@ +#!/bin/sh + +list1() { find "$1" -mindepth 1 -maxdepth 1 -type "${2:-d}" -printf '%f\n'; } + +curs="$(list1 ~/docs/school/Vakken | fzf)" +[ "$curs" ] || exit 1 +zip="$(list1 ~/dl f | fzf -f "$curs" | grep '\.zip$')" +[ "$zip" ] || exit 1 + +>&2 printf "zip: %s\n" "$zip" + +cd -- ~/docs/school/Vakken/"$curs" || exit 1 +rm -rf Cursus +mv -- ~/dl/"$zip" . +unzip -- "./$zip" +mv -- "${zip%%.zip}" Cursus +rm -- "$zip" diff --git a/bin/extra/dbnewg b/bin/extra/dbnewg new file mode 100755 index 0000000..a8c4bcf --- /dev/null +++ b/bin/extra/dbnewg @@ -0,0 +1,11 @@ +#!/bin/sh + +die () { >&2 printf '%s\n' "$@"; exit 1; } + +[ "$1" ] || die "usage: dbnewg <dir>" +proj="$(basename "$(readlink -f "$1")")" + +ssh git@db '$HOME/initdir.sh' "$proj" +cd "$1" || exit 1 +git remote add origin git@db:"$proj" +git push --set-upstream origin main diff --git a/bin/extra/ehbtodl b/bin/extra/ehbtodl index df11797..fc873f6 100755 --- a/bin/extra/ehbtodl +++ b/bin/extra/ehbtodl @@ -1,9 +1,13 @@ #!/usr/bin/env sh -echo "$1" | sed 's/-H/\\\n\t&/g' | sed '/gzip/d' > /tmp/curlcommand.sh -sh /tmp/curlcommand.sh > /tmp/ehbso.html -vids="$(grep -oE "youtube\.com/embed/.{11}" /tmp/ehbso.html | cut -d'/' -f 3 | tr '\n' ' ')" +printf "%s\n" "$1" | + sed 's/-H/\\\n&/g' | + sed '/gzip/d' | + tee /tmp/curlcommand.sh | + sh > /tmp/ehbso.html +vids="$(grep -oE "youtube\.com/embed/.{11}" /tmp/ehbso.html | + cut -d'/' -f 3 | + tr '\n' ' ')" for i in $vids -do - echo "https://www.youtube.com/watch?v=$i" +do printf "%s\n" "https://www.youtube.com/watch?v=$i" done > /tmp/todownload # yt-dlp -P "$HOME/Downloads/vids" -o "%(title)s" -a /tmp/todownload diff --git a/bin/extra/gml b/bin/extra/gml new file mode 100755 index 0000000..0f2f143 --- /dev/null +++ b/bin/extra/gml @@ -0,0 +1,70 @@ +#!/bin/sh + +minecraft() +{ + instance="$( + ( + printf "default\n" + find ~/.local/share/multimc/instances \ + -maxdepth 1 -mindepth 1 \ + -type d \ + -printf "%f\n" | + grep -v '_LAUNCHER_TEMP' + ) | + commander -d -c -x)" + + [ "$instance" ] || exit 1 + [ "$instance" = "default" ] && instance="1.20.1" + + ips="none 192.168.178.79 192.168.178.52 10.7.0.1 mc.hypixel.net" + ip="$(for ip in $ips + do printf "%s\n" "$ip" + done | commander -d -c)" + + if [ "$ip" != 'none' ] + then setsid multimc -l "$instance" -s "$ip" > /dev/null 2>&1 + else + + world="$( + ( + printf "none\n" + find "$HOME"/.local/share/multimc/instances/"$instance"/.minecraft/saves/ \ + -mindepth 1 -maxdepth 1 \ + -type d \ + -printf "%f\n" + ) | commander -d -c -s)" + + [ -z "$world" ] && exit 1 + + if [ "$world" = 'none' ] + then setsid multimc -l "$instance" > /dev/null 2>&1 + else setsid multimc -l "$instance" -w "$world" > /dev/null 2>&1 + fi + + fi +} + +steam() +{ + choice="$( + cat <<-EOF | column -t -l 2 | commander -d -x -c | awk '{printf $1}' + 274190 broforce + 291550 brawlhalla + 1712840 tiny tina + 105600 terraria + kill +EOF + )" + case "$choice" in + kill) pkill steam ;; + *) setsid steam steam://rungameid/"$choice" ;; + esac + exit +} + +eval "$( + cat <<-EOF | commander -c -w 9 -y 2 + minecraft + steam + EOF +)" diff --git a/bin/extra/pomo b/bin/extra/pomo new file mode 100755 index 0000000..a2c371d --- /dev/null +++ b/bin/extra/pomo @@ -0,0 +1,31 @@ +#!/bin/sh +notif() { notify-send -t 1000 -w "pomo" "$1"; } + +for msg in "three" "two" "one" +do notif "$msg" +done + +# $1: time in minutes +# $2: msg for notification +ring_ring() +{ + date '+%R B' + notify-send -w "$(($1*1000*60))" -u critical "pomo" "$2" +} + +i="${1-0}" +while true + +do + notif "<b>START</b>" + date '+%R S' + sleep 20m + if [ "$i" -eq 3 ] + then + i=0 + ring_ring 20 "GIGA BREAK TIME" + else + ring_ring 5 "BREAK TIME" + i=$((i+1)) + fi +done diff --git a/bin/extra/supd b/bin/extra/supd index 931d808..4975b94 100755 --- a/bin/extra/supd +++ b/bin/extra/supd @@ -1,24 +1,44 @@ #!/bin/sh -print_dir () { printf '%s: ' "$1" | sed "s#$HOME#~#" >&2; } +usage() { + >&2 cat <<-EOF + usage: supd + supd <prefix> <dir> + stdout | supd <prefix> + EOF + exit 1 +} check () { for dir in $1 do - print_dir "$2/$dir" + printf '%s: ' "$2/$dir" | sed "s#$HOME#~#" >&2 cd "$2/$dir" || continue git pull > /dev/null 2>&1 && printf 'Up to date.' || printf 'Couldn'\''t update.' - printf '\n' + printf ' ' + printf '%s %s\n' "$(git status --short 2> /dev/null | + awk 'NR==1 {print $1}')" "$(git branch -v 2>/dev/null | + grep '^\*' | cut -f2 -d'[' | cut -f1 -d' ' | + sed 's/ahead/↑/;s/behind/↓/;s/\*//')" + done } -dirs="installdrier dotfiles password-store" -prefix="$HOME/src" +if [ "$#" -eq 0 ] +then + dirs="installdrier dotfiles password-store" + prefix="$HOME/src" +elif [ ! -t 0 ] +then + prefix="$1" + dirs="$(cat)" +else + prefix="$1" + shift || usage + dirs="$*" + [ "$dirs" ] || usage +fi check "$dirs" "$prefix" - -# dirs="$(ls -1 "$HOME/proj/personal")" -# prefix="$HOME/proj/personal" -# check "$dirs" "$prefix" |