From f5b4d22afa3fa2e3f2d18c23d266c5f17a30e29b Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 1 Oct 2023 21:12:32 +0200 Subject: refactor --- bin/extra/supd | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/supd b/bin/extra/supd index 931d808..a383d65 100755 --- a/bin/extra/supd +++ b/bin/extra/supd @@ -1,24 +1,30 @@ #!/bin/sh -print_dir () { printf '%s: ' "$1" | sed "s#$HOME#~#" >&2; } +usage() { >&2 printf "usage: supd\nusage: supd "; 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 ' ' + git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' printf '\n' done } -dirs="installdrier dotfiles password-store" -prefix="$HOME/src" +if [ "$#" -eq 0 ] +then + dirs="installdrier dotfiles password-store" + prefix="$HOME/src" +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" -- cgit v1.2.3 From 4f8e2c1a36f85c55ca2bc190af9804c590ec7186 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 1 Oct 2023 23:26:28 +0200 Subject: added dbnewg --- bin/extra/dbnewg | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100755 bin/extra/dbnewg (limited to 'bin/extra') 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 " +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 -- cgit v1.2.3 From 010c7903562963e5585190896f47d62218fa08fd Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 2 Oct 2023 17:43:23 +0200 Subject: added scripts --- bin/extra/curszip | 17 +++++++++++++++ bin/extra/gml | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ bin/extra/pomo | 8 +++++++ 3 files changed, 90 insertions(+) create mode 100755 bin/extra/curszip create mode 100755 bin/extra/gml create mode 100755 bin/extra/pomo (limited to 'bin/extra') 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/gml b/bin/extra/gml new file mode 100755 index 0000000..0d3a277 --- /dev/null +++ b/bin/extra/gml @@ -0,0 +1,65 @@ +#!/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 broforc3 + 291550 brawlhalla + 1712840 tiny tina + EOF + )" + [ "$choice" ] && setsid steam steam://rungameid/"$choice" + exit +} + +eval "$( + cat <<-EOF | commander -c + minecraft + steam + EOF +)" diff --git a/bin/extra/pomo b/bin/extra/pomo new file mode 100755 index 0000000..4227738 --- /dev/null +++ b/bin/extra/pomo @@ -0,0 +1,8 @@ +#!/bin/sh +while true +do + date +%R + sleep 20m + notify-send -u critical -t 5000 "pomodoro" "BREAK TIME" + sleep 5m +done -- cgit v1.2.3 From 98ab77c554907e92637dc33a5a671fd03d6a987f Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 3 Oct 2023 18:18:34 +0200 Subject: added terraria --- bin/extra/gml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/gml b/bin/extra/gml index 0d3a277..f00abcf 100755 --- a/bin/extra/gml +++ b/bin/extra/gml @@ -48,17 +48,18 @@ steam() { choice="$( cat <<-EOF | column -t -l 2 | commander -d -x -c | awk '{printf $1}' - 274190 broforc3 + 274190 broforce 291550 brawlhalla 1712840 tiny tina - EOF + 105600 terraria +EOF )" [ "$choice" ] && setsid steam steam://rungameid/"$choice" exit } eval "$( - cat <<-EOF | commander -c + cat <<-EOF | commander -c -w 9 -y 2 minecraft steam EOF -- cgit v1.2.3 From 5a8c1637d56e430f6d80e2b27e28f31cf21687dd Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 4 Oct 2023 02:40:50 +0200 Subject: added reading from stdin --- bin/extra/supd | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/supd b/bin/extra/supd index a383d65..83a606b 100755 --- a/bin/extra/supd +++ b/bin/extra/supd @@ -1,6 +1,13 @@ #!/bin/sh -usage() { >&2 printf "usage: supd\nusage: supd "; exit 1; } +usage() { + >&2 cat <<-EOF + usage: supd + supd + stdout | supd + EOF + exit 1 +} check () { @@ -12,8 +19,8 @@ check () printf 'Up to date.' || printf 'Couldn'\''t update.' printf ' ' - git status --short 2> /dev/null | head -n1 | awk '{print $1 " "}' - printf '\n' + printf '%s\n' "$(git status --short 2> /dev/null | + awk 'NR==1 {print $1}')" done } @@ -21,6 +28,10 @@ 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 -- cgit v1.2.3 From 14c41cc89367b13d0d9d9f360428582954e8be3d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Wed, 4 Oct 2023 02:53:27 +0200 Subject: added kill option --- bin/extra/gml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'bin/extra') diff --git a/bin/extra/gml b/bin/extra/gml index f00abcf..0f2f143 100755 --- a/bin/extra/gml +++ b/bin/extra/gml @@ -52,9 +52,13 @@ steam() 291550 brawlhalla 1712840 tiny tina 105600 terraria + kill EOF )" - [ "$choice" ] && setsid steam steam://rungameid/"$choice" + case "$choice" in + kill) pkill steam ;; + *) setsid steam steam://rungameid/"$choice" ;; + esac exit } -- cgit v1.2.3 From d9b55a1b4ce254afce95ec836d819d19da5b0d6e Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Thu, 5 Oct 2023 16:23:54 +0200 Subject: changed parse_branch and added it to supd --- bin/extra/supd | 7 +++++-- config/essentials/zsh/.zshrc | 11 +++-------- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/supd b/bin/extra/supd index 83a606b..4975b94 100755 --- a/bin/extra/supd +++ b/bin/extra/supd @@ -19,8 +19,11 @@ check () printf 'Up to date.' || printf 'Couldn'\''t update.' printf ' ' - printf '%s\n' "$(git status --short 2> /dev/null | - awk 'NR==1 {print $1}')" + 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 } diff --git a/config/essentials/zsh/.zshrc b/config/essentials/zsh/.zshrc index 9b6fa48..2499c45 100644 --- a/config/essentials/zsh/.zshrc +++ b/config/essentials/zsh/.zshrc @@ -106,14 +106,9 @@ RPROMPT='%F{blue}$(parse_git_remote)%f%F{red}$(parse_git_status)%f%F{green}$(par setopt prompt_subst parse_git_remote() { - b="$(git branch -v 2>/dev/null | grep "^*" | cut -f2 -d'[' | cut -f1 -d' ')" - if [ "$b" = "behind" ] - then - printf "↓ " - elif [ "$b" = "ahead" ] - then - printf "↑ " - fi + git branch -v 2>/dev/null | + grep '^\*' | cut -f2 -d'[' | cut -f1 -d' ' | + sed 's/ahead/↑/;s/behind/↓/;s/\*//' } parse_git_branch() { git symbolic-ref --short HEAD 2> /dev/null || git rev-parse --short HEAD 2> /dev/null -- cgit v1.2.3 From 62f92d6ed11b8892d32b59178b07e1d52c154bc6 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 8 Oct 2023 13:12:11 +0200 Subject: refactor --- bin/extra/ehbtodl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'bin/extra') 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 -- cgit v1.2.3 From 472da12759cdb2e63520826add567da34376d15a Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 8 Oct 2023 17:06:33 +0200 Subject: added countdown timer --- bin/extra/pomo | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'bin/extra') diff --git a/bin/extra/pomo b/bin/extra/pomo index 4227738..fa14cca 100755 --- a/bin/extra/pomo +++ b/bin/extra/pomo @@ -1,6 +1,14 @@ #!/bin/sh +notif() { notify-send -t 1000 "pomo" "$1"; sleep 1; } + +for msg in "three" "two" "one" +do notif "$msg" +done + while true -do + +do + notif "START" date +%R sleep 20m notify-send -u critical -t 5000 "pomodoro" "BREAK TIME" -- cgit v1.2.3 From f69263dc091c6a61011af9e5f3684d2895b49795 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Sun, 8 Oct 2023 17:07:02 +0200 Subject: added bigger break after four cycles --- bin/extra/pomo | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/pomo b/bin/extra/pomo index fa14cca..2627628 100755 --- a/bin/extra/pomo +++ b/bin/extra/pomo @@ -5,12 +5,21 @@ for msg in "three" "two" "one" do notif "$msg" done +i="${1-0}" while true do notif "START" date +%R sleep 20m - notify-send -u critical -t 5000 "pomodoro" "BREAK TIME" - sleep 5m + if [ "$i" -eq 3 ] + then + i=-1 + notify-send -u critical -t 20000 "pomodoro" "GIGA BREAK TIME" + sleep 20m + else + notify-send -u critical -t 5000 "pomodoro" "BREAK TIME" + sleep 5m + fi + i=$((i+1)) done -- cgit v1.2.3 From 9001cd2124c665abcedf359ef77507e301ea9e8e Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 9 Oct 2023 14:58:43 +0200 Subject: fixed: notification not staying long enough changed the delay from seconds to minutes through multiplying by 60. --- bin/extra/pomo | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/pomo b/bin/extra/pomo index 2627628..0971343 100755 --- a/bin/extra/pomo +++ b/bin/extra/pomo @@ -14,12 +14,12 @@ do sleep 20m if [ "$i" -eq 3 ] then - i=-1 - notify-send -u critical -t 20000 "pomodoro" "GIGA BREAK TIME" + notify-send -u critical -t 1200000 "pomodoro" "GIGA BREAK TIME" sleep 20m + i=0 else - notify-send -u critical -t 5000 "pomodoro" "BREAK TIME" + notify-send -u critical -t 300000 "pomodoro" "BREAK TIME" sleep 5m + i=$((i+1)) fi - i=$((i+1)) done -- cgit v1.2.3 From d89bf2c50e177f6570c2d845b14a014b5c7898c0 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 9 Oct 2023 21:23:24 +0200 Subject: added more verbose output --- bin/extra/pomo | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'bin/extra') diff --git a/bin/extra/pomo b/bin/extra/pomo index 0971343..27722a4 100755 --- a/bin/extra/pomo +++ b/bin/extra/pomo @@ -10,8 +10,9 @@ while true do notif "START" - date +%R + date '+%R S' sleep 20m + date '+%R B' if [ "$i" -eq 3 ] then notify-send -u critical -t 1200000 "pomodoro" "GIGA BREAK TIME" -- cgit v1.2.3 From b4f7c506a75d4d540b902d533bad3a733b976e27 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Mon, 9 Oct 2023 23:53:04 +0200 Subject: updated for new vm --- bin/extra/aivpn | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/aivpn b/bin/extra/aivpn index 55e013a..14d176c 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,16 @@ keyadd ehb/ai export SSH_ASKPASS="$0" export SSH_ASKPASS_REQUIRE="prefer" -export PASSWORD=aluc +export PASSWORD=zot/qemu 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]" -- cgit v1.2.3 From c5461e289dcd7dab36d028aec5d3e1d0b8677f64 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 10 Oct 2023 00:15:44 +0200 Subject: added connectivity check --- bin/extra/aivpn | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bin/extra') diff --git a/bin/extra/aivpn b/bin/extra/aivpn index 14d176c..fd72ffb 100755 --- a/bin/extra/aivpn +++ b/bin/extra/aivpn @@ -23,6 +23,11 @@ export SSH_ASKPASS="$0" export SSH_ASKPASS_REQUIRE="prefer" 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 vm "rasdial \"vpn.student.ehb.be\"" ssh -f -N \ -- cgit v1.2.3 From ee6e9c223b1b73c08801b415c17e12f93e504f2a Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 10 Oct 2023 19:08:13 +0200 Subject: use a function for breaks --- bin/extra/pomo | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/pomo b/bin/extra/pomo index 27722a4..859dd12 100755 --- a/bin/extra/pomo +++ b/bin/extra/pomo @@ -1,10 +1,20 @@ #!/bin/sh -notif() { notify-send -t 1000 "pomo" "$1"; sleep 1; } +notif() { notify-send -t "${2:-1000}" "pomo" "$1"; sleep 1; } for msg in "three" "two" "one" do notif "$msg" done +# $1: time in seconds +# $2: msg for notification +ring_ring() +{ + time="$(($1*1000*60))" + date '+%R B' + notif "$time" "$2" + sleep "$time"s +} + i="${1-0}" while true @@ -12,15 +22,12 @@ do notif "START" date '+%R S' sleep 20m - date '+%R B' if [ "$i" -eq 3 ] then - notify-send -u critical -t 1200000 "pomodoro" "GIGA BREAK TIME" - sleep 20m i=0 + ring_ring 20 "GIGA BREAK TIME" else - notify-send -u critical -t 300000 "pomodoro" "BREAK TIME" - sleep 5m + ring_ring 5 "BREAK TIME" i=$((i+1)) fi done -- cgit v1.2.3 From a01644894f9e490a7055f49d3fa8fc2c3164cc4d Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 10 Oct 2023 20:58:37 +0200 Subject: introudcing the -w option of notify-send --- bin/extra/pomo | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'bin/extra') diff --git a/bin/extra/pomo b/bin/extra/pomo index 859dd12..68f3d59 100755 --- a/bin/extra/pomo +++ b/bin/extra/pomo @@ -1,5 +1,5 @@ #!/bin/sh -notif() { notify-send -t "${2:-1000}" "pomo" "$1"; sleep 1; } +notif() { notify-send -t 1000 -w "pomo" "$1"; } for msg in "three" "two" "one" do notif "$msg" @@ -9,10 +9,8 @@ done # $2: msg for notification ring_ring() { - time="$(($1*1000*60))" date '+%R B' - notif "$time" "$2" - sleep "$time"s + notify-send -w "$(($1*1000*60))" -u critical "pomo" "$2" } i="${1-0}" -- cgit v1.2.3 From a93a711e4f6f112f0b5a1b29f576e5f9b8742a65 Mon Sep 17 00:00:00 2001 From: Raymaekers Luca Date: Tue, 10 Oct 2023 20:59:09 +0200 Subject: typo --- bin/extra/pomo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bin/extra') diff --git a/bin/extra/pomo b/bin/extra/pomo index 68f3d59..a2c371d 100755 --- a/bin/extra/pomo +++ b/bin/extra/pomo @@ -5,7 +5,7 @@ for msg in "three" "two" "one" do notif "$msg" done -# $1: time in seconds +# $1: time in minutes # $2: msg for notification ring_ring() { -- cgit v1.2.3