summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2024-11-29 17:21:07 +0100
committerRaymaekers Luca <raymaekers.luca@gmail.com>2024-11-29 17:21:07 +0100
commit1c632029d7a02742b0cc740b6984ce139429b88b (patch)
treec3ff42411f67d57ef86249723f38a726414ecd8a /bin
parent5464c097a44165473b352c463805a39799888c52 (diff)
checkpoint
Diffstat (limited to 'bin')
-rwxr-xr-xbin/extra/asciiext34
-rwxr-xr-xbin/extra/gdbs14
-rwxr-xr-xbin/extra/gml73
-rwxr-xr-xbin/extra/myts65
-rwxr-xr-xbin/menuscripts/mdbsrv17
-rwxr-xr-xbin/menuscripts/mgame20
6 files changed, 150 insertions, 73 deletions
diff --git a/bin/extra/asciiext b/bin/extra/asciiext
new file mode 100755
index 0000000..00e3408
--- /dev/null
+++ b/bin/extra/asciiext
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# heading index with div line
+printf "\n "; # indent
+
+for x in {0..15}; do printf "%-3x" $x; done;
+printf "\n%46s\n" | sed 's/ /-/g;s/^/ /';
+
+# two lines with dots to represent control chars
+c=$(echo "fa" | xxd -p -r | iconv -f 'CP437//' -t 'UTF-8')
+printf "%32s" | sed 's/../'"$c"' /g;s/^/ 0 /;s/$/\n\n/'
+printf "%32s" | sed 's/../'"$c"' /g;s/^/ 1 /'
+
+# convert dec to codepage 437 in a table
+for x in {32..255};
+do
+
+ # newline every 16 translated code values
+ (( x % 16 == 0 )) && printf "\n\n"
+
+ # left index numbers
+ let "n = x % 15"
+ (( (x % 16) == 0 )) && printf "%-4x" $n | sed 's/0/f/;s/^/ /'
+
+ # conversion of x integer value to symbol
+ printf "%02x" $x | xxd -p -r | iconv -f 'CP437//' -t 'UTF-8' | sed 's/.*/& /'
+
+ # div line
+ (( x == 127 )) && printf "%46s" | sed 's/ /-/g;s/^/ /;i\ '
+
+done
+printf "%46s" | sed 's/ /-/g;s/^/\n /;s/$/\n /'; # div line
+for x in {0..15}; do printf "%-3x" $x; done;
+echo
diff --git a/bin/extra/gdbs b/bin/extra/gdbs
new file mode 100755
index 0000000..e0fa371
--- /dev/null
+++ b/bin/extra/gdbs
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+gdbs="$HOME/.cache/gdbs"
+
+command="$@"
+if [ -z "$command" ]; then
+ [ -f ] && command="$(cat "$gdbs" 2>/dev/null)"
+ [ "$command" ] || exit 1
+fi
+
+gdbserver :4200 $command
+
+echo "$command" > "$gdbs"
+
diff --git a/bin/extra/gml b/bin/extra/gml
deleted file mode 100755
index f8d6b7e..0000000
--- a/bin/extra/gml
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/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 |
- 274190 broforce
- 291550 brawlhalla
- 1712840 tiny tina
- 105600 terraria
- kill
- EOF
- column -t -l 2 | commander -d -x -c | awk '{printf $1}')"
-
- case "$choice" in
- kill) pkill steam ;;
- "") ;;
- *) setsid steam steam://rungameid/"$choice" ;;
- esac
- exit
-}
-
-eval "$(
- cat <<-EOF | commander -c -w 9 -y 3
- minecraft
- steam
- lutris
- EOF
-)"
diff --git a/bin/extra/myts b/bin/extra/myts
new file mode 100755
index 0000000..aea4842
--- /dev/null
+++ b/bin/extra/myts
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# Play a youtube song via yt-dlp, jq, fzf and play it with mpv or mpd.
+
+tsv="/tmp/ytsearch.tsv"
+json="/tmp/ytsearch.json"
+
+# This is the preview code for fzf
+if [ "$1" = "-p" ]; then
+ grep "^$2\s" "$tsv" |
+ cut -f 4,5,6 | tr '\t' '\n' |
+ while read -r channel; do
+ read -r timestamp
+ read -r views
+ printf '\033[2m%s\033[0m\n' "$channel"
+ printf '%s views\n' "$(numfmt --to=iec "$views")"
+ printf '\033[3m%s\033[0m\n' "$(date -d @"$timestamp" +'released on %d/%m/%y at %T')"
+ done
+ exit
+fi
+
+# Whether to pass th --no-video flag to mpv
+if [ "$1" = "-n" ]; then
+ noVideoFlag=1
+ shift
+fi
+
+# Whether to add the url to mpd
+if [ "$1" = "-m" ]; then
+ toMPDFlag=1
+ shift
+fi
+
+q="$@"
+if [ -z "$q" ]; then
+ >&2 printf 'Usage: %s query\n' "$0"
+ exit 1
+fi
+
+>&2 printf 'Searching..\n'
+yt-dlp -j "ytsearch5:$q" | jq > "$json"
+
+jq -r '[.id,.title,.original_url,.channel,.timestamp,.view_count] | @tsv' "$json" > "$tsv"
+
+choice="$(cut -f 1,2,6 "$tsv" |
+ sort -t ' ' -k 3 |
+ cut -f 1,2 |
+ column -t -s ' ' |
+ fzf --with-nth "2.." --preview "$0"' -p {1}')"
+[ "$choice" ] || exit 1
+choice="${choice%% *}"
+url="$(grep "^$choice " "$tsv" | cut -f 3)"
+[ "$url" ] || exit 2
+
+rm -f "$tsv" "$json"
+
+if [ "$toMPDFlag" ]; then
+ >&2 printf 'Adding to mpd..\n'
+ mpc add "$(yt-dlp --prefer-insecure -g -f140 "$url")"
+elif [ "$noVideoFlag" ]; then
+ mpv --no-video "$url"
+else
+ mpv "$url"
+fi
+>&2 printf 'Done.\n'
diff --git a/bin/menuscripts/mdbsrv b/bin/menuscripts/mdbsrv
new file mode 100755
index 0000000..81b5109
--- /dev/null
+++ b/bin/menuscripts/mdbsrv
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+services() {
+ cat <<-EOF
+ 5030 slsksd
+ 9091 transmission
+ 8096 jellyfin
+ 80 ntfy
+ 24961 miniflux
+ 24880 pihole
+ 8384 syncthing
+EOF
+}
+
+service="$(services | column -t -l 2 | dmenu -c -x)"
+[ "$service" ] || exit 1
+$BROWSER "http://192.168.178.79:${service%% *}"
diff --git a/bin/menuscripts/mgame b/bin/menuscripts/mgame
new file mode 100755
index 0000000..7c90a2b
--- /dev/null
+++ b/bin/menuscripts/mgame
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+steam_games()
+{
+ # List every manifest file and get the id of the games from the file names and the name of the
+ # game from the file.
+ find $HOME/.local/share/Steam/steamapps \
+ -maxdepth 1 -type f -iname 'appmanifest_*.acf' |
+ while read -r File; do
+ Name="$(grep '"name"' "$File" | cut -f 4 -d '"')"
+ FileBaseName="${File%.acf}"
+ SteamID="${FileBaseName##*appmanifest_}"
+ printf '%s %s\n' "$SteamID" "$Name"
+ done
+}
+
+Choice="$(steam_games | cut -f 2- -d' ' | dmenu -c -i -x)"
+ID="$(steam_games | grep "[0-9]\+ $Choice" | cut -f 1 -d ' ')"
+
+setsid steam steam://rungameid/"$ID"