about summary refs log tree commit diff stats
path: root/hm/soispha/pkgs/scripts/wrappers
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2023-08-26 23:42:21 +0200
committerSoispha <soispha@vhack.eu>2023-08-26 23:42:21 +0200
commit3f600ab07dbad3b6dd7655587ddea158b19aea71 (patch)
tree7164ccd965e1d14ade970aeb8eb188b1442a6c91 /hm/soispha/pkgs/scripts/wrappers
parentStyle(treewide): Format all lua-files makes lua ➛ nix easier (diff)
downloadnixos-config-3f600ab07dbad3b6dd7655587ddea158b19aea71.zip
Refactor(treewide): Abbreviate path names
Diffstat (limited to 'hm/soispha/pkgs/scripts/wrappers')
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/backsnap3
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/ll14
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/llp19
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/spodi45
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/virsh-del10
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/yti36
6 files changed, 127 insertions, 0 deletions
diff --git a/hm/soispha/pkgs/scripts/wrappers/backsnap b/hm/soispha/pkgs/scripts/wrappers/backsnap
new file mode 100755
index 00000000..cd08045d
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/backsnap
@@ -0,0 +1,3 @@
+#! /usr/bin/env dash
+snap-sync --noconfirm -u d1c6e0f6-1837-40fd-bb29-251d5ea0ddb0
+umount /run/dt/d1c6e0f6-1837-40fd-bb29-251d5ea0ddb0
diff --git a/hm/soispha/pkgs/scripts/wrappers/ll b/hm/soispha/pkgs/scripts/wrappers/ll
new file mode 100755
index 00000000..cb1fc0ea
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/ll
@@ -0,0 +1,14 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+last_directory="$(mktemp)"
+
+command lf -last-dir-path="$last_directory" "$@"
+
+dir="$(cat "$last_directory")"
+cd "$dir" || die "$dir does not exist!"
+rm "$last_directory"
+
+# vim: ft=sh
diff --git a/hm/soispha/pkgs/scripts/wrappers/llp b/hm/soispha/pkgs/scripts/wrappers/llp
new file mode 100755
index 00000000..2a21450c
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/llp
@@ -0,0 +1,19 @@
+#! /bin/bash
+
+export LLP=1
+cleanup() {
+    exec 3>&-
+	rm "$FIFO_UEBERZUG"
+}
+
+if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
+	lf "$@"
+else
+	[ ! -d "$HOME/.cache/lf" ] && mkdir --parents "$HOME/.cache/lf"
+	export FIFO_UEBERZUG="$HOME/.cache/lf/ueberzug-$$"
+	mkfifo "$FIFO_UEBERZUG"
+	ueberzug layer -s <"$FIFO_UEBERZUG" -p json &
+	exec 3>"$FIFO_UEBERZUG"
+	trap cleanup EXIT
+	lf "$@" 3>&-
+fi
diff --git a/hm/soispha/pkgs/scripts/wrappers/spodi b/hm/soispha/pkgs/scripts/wrappers/spodi
new file mode 100755
index 00000000..4ff53bff
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/spodi
@@ -0,0 +1,45 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+DOWN_DIR="/home/soispha/media/music/down";
+
+download_url="$1";
+
+
+
+already_downloaded_files="$(mktmp)"
+fd . "$DOWN_DIR" --exclude spotdl.log > "$already_downloaded_files";
+
+config="$(mktmp)"
+cat << EO > "$config"
+--log-level INFO
+--cache-path /home/soispha/.local/share/spotdl/.spotipy
+--audio youtube-music youtube
+--lyrics genius musixmatch azlyrics
+--ffmpeg ffmpeg
+--format mp3
+--output {artists}_-_{title}
+--overwrite skip
+--client-id 5f573c9620494bae87890c0f08a60293
+--client-secret 212476d9b0f3472eaa762d90b19b0ba8
+--threads 16
+--print-errors
+--preload
+EO
+
+if [ -z "$NO_CHECK" ] && [ "$(wc -l < "$already_downloaded_files" )" -ne 0 ];then
+    die "something is already downloaded"
+fi
+
+rm "$DOWN_DIR/spotdl.log"
+cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR"
+
+
+# The sub shell needs to be unquoted, as the arguments may not be treated as one.
+# shellcheck disable=2046
+unbuffer spotdl $(cat "$config") download "$download_url" | tee "$DOWN_DIR/spotdl.log"
+
+[ -d ~/.spotdl ] && rm -r ~/.spotdl
+# vim: ft=sh
diff --git a/hm/soispha/pkgs/scripts/wrappers/virsh-del b/hm/soispha/pkgs/scripts/wrappers/virsh-del
new file mode 100755
index 00000000..afcd87c1
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/virsh-del
@@ -0,0 +1,10 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+virsh destroy "$1"
+virsh undefine "$1" --nvram
+virsh vol-delete --pool default "$1".qcow2
+
+# vim: ft=sh
diff --git a/hm/soispha/pkgs/scripts/wrappers/yti b/hm/soispha/pkgs/scripts/wrappers/yti
new file mode 100755
index 00000000..0b737b30
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/yti
@@ -0,0 +1,36 @@
+#! /usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="1.1.4" . %SHELL_LIBRARY_PATH
+
+die "Use spodi instead!" # TODO: fix this script
+DOWN_DIR=/home/soispha/media/playlist/down/
+
+
+tmp=$(mktmp)
+config=$(mktmp)
+
+for e in "$DOWN_DIR"/*.mp3;do echo "$e" >> "$tmp";done
+[ "$(wc -l "$tmp" | awk '{print $1}')" -gt 2 ] && die "something is already downloaded"
+
+cat << EO > "$config"
+--paths home:"$DOWN_DIR"
+#--output %(fulltitle)
+--restrict-filenames
+--no-overwrites
+--no-write-info-json
+--clean-info-json
+--prefer-free-formats
+#--format mp3
+--extract-audio
+--audio-quality 0
+--audio-format best
+EO
+
+
+rm ${DOWN_DIR}yt-dlp.log
+cd $DOWN_DIR || die "BUG: no $DOWN_DIR"
+
+unbuffer yt-dlp --config-location "$config" "$1" | tee $DOWN_DIR/yt-dlp.log
+
+# vim: ft=sh