From 06696ca201682f63ea50da3ab41d992ed6b61816 Mon Sep 17 00:00:00 2001 From: ene Date: Sat, 25 Feb 2023 07:54:37 +0100 Subject: Feat(packages): Add my scripts --- home-manager/packages/scripts/wrappers/backsnap | 3 + .../packages/scripts/wrappers/deprecated/clippy | 56 +++++ .../scripts/wrappers/deprecated/pacman/pacComp | 28 +++ .../scripts/wrappers/deprecated/pacman/pacF | 19 ++ .../scripts/wrappers/deprecated/pacman/pacS | 14 ++ .../wrappers/deprecated/pacman/packages_scan | 20 ++ .../packages/scripts/wrappers/deprecated/tidal-dl | 11 + .../packages/scripts/wrappers/deprecated/xi | 12 ++ .../packages/scripts/wrappers/deprecated/xs | 233 +++++++++++++++++++++ home-manager/packages/scripts/wrappers/ll | 13 ++ home-manager/packages/scripts/wrappers/llp | 19 ++ home-manager/packages/scripts/wrappers/spodi | 39 ++++ home-manager/packages/scripts/wrappers/virsh-del | 14 ++ home-manager/packages/scripts/wrappers/yti | 36 ++++ 14 files changed, 517 insertions(+) create mode 100755 home-manager/packages/scripts/wrappers/backsnap create mode 100755 home-manager/packages/scripts/wrappers/deprecated/clippy create mode 100755 home-manager/packages/scripts/wrappers/deprecated/pacman/pacComp create mode 100755 home-manager/packages/scripts/wrappers/deprecated/pacman/pacF create mode 100755 home-manager/packages/scripts/wrappers/deprecated/pacman/pacS create mode 100755 home-manager/packages/scripts/wrappers/deprecated/pacman/packages_scan create mode 100755 home-manager/packages/scripts/wrappers/deprecated/tidal-dl create mode 100755 home-manager/packages/scripts/wrappers/deprecated/xi create mode 100755 home-manager/packages/scripts/wrappers/deprecated/xs create mode 100755 home-manager/packages/scripts/wrappers/ll create mode 100755 home-manager/packages/scripts/wrappers/llp create mode 100755 home-manager/packages/scripts/wrappers/spodi create mode 100755 home-manager/packages/scripts/wrappers/virsh-del create mode 100755 home-manager/packages/scripts/wrappers/yti (limited to 'home-manager/packages/scripts/wrappers') diff --git a/home-manager/packages/scripts/wrappers/backsnap b/home-manager/packages/scripts/wrappers/backsnap new file mode 100755 index 00000000..3487ba57 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/backsnap @@ -0,0 +1,3 @@ +#! /bin/sh +snap-sync --noconfirm -u d1c6e0f6-1837-40fd-bb29-251d5ea0ddb0 +umount /run/dt/d1c6e0f6-1837-40fd-bb29-251d5ea0ddb0 diff --git a/home-manager/packages/scripts/wrappers/deprecated/clippy b/home-manager/packages/scripts/wrappers/deprecated/clippy new file mode 100755 index 00000000..89f8554a --- /dev/null +++ b/home-manager/packages/scripts/wrappers/deprecated/clippy @@ -0,0 +1,56 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +tmp=$(mktemp); +cat << EOF > $tmp; +-W clippy::allow_attributes_without_reason +-W clippy::clone_on_ref_ptr +-W clippy::create_dir +-W clippy::decimal_literal_representation +-W clippy::filetype_is_file +-W clippy::get_unwrap +-W clippy::if_then_some_else_none +-W clippy::large_include_file +-W clippy::let_underscore_must_use +-W clippy::missing_enforced_import_renames +-W clippy::mixed_read_write_in_expression +-W clippy::mod_module_files +-W clippy::multiple_inherent_impl +-W clippy::rc_mutex +-W clippy::rc_buffer +-W clippy::rest_pat_in_fully_bound_structs +-W clippy::same_name_method +-W clippy::single_char_lifetime_names +-W clippy::str_to_string +-W clippy::string_to_string +-W clippy::unneeded_field_pattern +-W clippy::unseparated_literal_suffix +-W clippy::verbose_file_reads +-W clippy::wildcard_enum_match_arm + +# debugging remnants +-W clippy::unwrap_used +#-W clippy::use_debug +#-W clippy::unreachable +#-W clippy::unimplemented +#-W clippy::todo +#-W clippy::panic +#-W clippy::panic_in_result_fn +#-W clippy::expect_used +#-W clippy::dbg_macro + +# Docs +-W clippy::missing_docs_in_private_items +-W clippy::undocumented_unsafe_blocks + + +EOF + + +cargo clippy -- -W clippy::pedantic -W clippy::nursery -W clippy::unwrap_used -W clippy::expect_used -W clippy::cargo $(clean "$tmp") + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/wrappers/deprecated/pacman/pacComp b/home-manager/packages/scripts/wrappers/deprecated/pacman/pacComp new file mode 100755 index 00000000..9fdfd8e7 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/deprecated/pacman/pacComp @@ -0,0 +1,28 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + + +for i in $(cat ~/pacsaves);do + + a=$(echo $i | sed 's|.pacsave||') + + printf "%s AND %s\n" "$a" "$i" + sudo diff -y "$a" "$i" + a= + readp "Delete .pacsave? [N/y]" ans + if [ "$ans" = y ];then + sudo rm $i + sed -i "s|$i||" ~/pacsaves + fi + + +done + + + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/wrappers/deprecated/pacman/pacF b/home-manager/packages/scripts/wrappers/deprecated/pacman/pacF new file mode 100755 index 00000000..09d0329c --- /dev/null +++ b/home-manager/packages/scripts/wrappers/deprecated/pacman/pacF @@ -0,0 +1,19 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +while true +do + tmp=$(mktmp) + readp "Input: " pac + pacman -F --color=always $pac > $tmp + cat "$tmp" + cat $tmp | awk -F "/" 'NR==1 {print $2}' + rm $tmp +done + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/wrappers/deprecated/pacman/pacS b/home-manager/packages/scripts/wrappers/deprecated/pacman/pacS new file mode 100755 index 00000000..20947864 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/deprecated/pacman/pacS @@ -0,0 +1,14 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +while true +do + readp "Package Name: " pac + pacman -Si --color=always "$pac" +done + + + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/wrappers/deprecated/pacman/packages_scan b/home-manager/packages/scripts/wrappers/deprecated/pacman/packages_scan new file mode 100755 index 00000000..2229ef23 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/deprecated/pacman/packages_scan @@ -0,0 +1,20 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +tmp=$(tmp 'pacman -Qq'); +output=$(mktmp); + + +while read -r line; do + msg2 reading $line; + pacman_out=$(tmp "pacman -Qi $line"); + description=$(awk -F ":" '/Description/ {print $2}' $pacman_out); + printf "%s # " $line >> $output; + echo $description >> $output; +done < $tmp + +cat $output; + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/wrappers/deprecated/tidal-dl b/home-manager/packages/scripts/wrappers/deprecated/tidal-dl new file mode 100755 index 00000000..c709a63d --- /dev/null +++ b/home-manager/packages/scripts/wrappers/deprecated/tidal-dl @@ -0,0 +1,11 @@ +#! /bin/bash +tmp=$(mktemp) + +scrap > $tmp + +for ((i=0; i < $( cat $tmp | wc -l); i++)) +do + out=$(awk -v n=$i 'NR == n {print $0}' $tmp) + spotdl --output /home/dt/media/playlist/down --output-format mp3 --lyrics-provider genius --dt 16 --st 16 "${out}" +done + diff --git a/home-manager/packages/scripts/wrappers/deprecated/xi b/home-manager/packages/scripts/wrappers/deprecated/xi new file mode 100755 index 00000000..c2f58528 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/deprecated/xi @@ -0,0 +1,12 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +export XKB_DEFAULT_LAYOUT="mykeys" +exec river + + + + +# if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi diff --git a/home-manager/packages/scripts/wrappers/deprecated/xs b/home-manager/packages/scripts/wrappers/deprecated/xs new file mode 100755 index 00000000..50908071 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/deprecated/xs @@ -0,0 +1,233 @@ +#!/bin/sh + +# +# This is just a sample implementation of a slightly less primitive +# interface than xinit. It looks for user .xinitrc and .xserverrc +# files, then system xinitrc and xserverrc files, else lets xinit choose +# its default. The system xinitrc should probably do things like check +# for .Xresources files and merge them in, start up a window manager, +# and pop a clock and several xterms. +# +# Site administrators are STRONGLY urged to write nicer versions. +# + +unset SESSION_MANAGER +userclientrc=$XDG_CONFIG_HOME/X11/xinitrc +sysclientrc=/etc/X11/xinit/xinitrc + +userserverrc=$HOME/.xserverrc +sysserverrc=/etc/X11/xinit/xserverrc +defaultclient=xterm +defaultserver=/usr/bin/X +defaultclientargs="" +defaultserverargs="" +defaultdisplay="" +clientargs="" +serverargs="" +vtarg="" +enable_xauth=1 + + +# Automatically determine an unused $DISPLAY +d=0 +while true ; do + [ -e "/tmp/.X$d-lock" -o -S "/tmp/.X11-unix/X$d" ] || break + d=$(($d + 1)) +done +defaultdisplay=":$d" +unset d + +whoseargs="client" +while [ x"$1" != x ]; do + case "$1" in + # '' required to prevent cpp from treating "/*" as a C comment. + /''*|\./''*) + if [ "$whoseargs" = "client" ]; then + if [ x"$client" = x ] && [ x"$clientargs" = x ]; then + client="$1" + else + clientargs="$clientargs $1" + fi + else + if [ x"$server" = x ] && [ x"$serverargs" = x ]; then + server="$1" + else + serverargs="$serverargs $1" + fi + fi + ;; + --) + whoseargs="server" + ;; + *) + if [ "$whoseargs" = "client" ]; then + clientargs="$clientargs $1" + else + # display must be the FIRST server argument + if [ x"$serverargs" = x ] && \ + expr "$1" : ':[0-9][0-9]*$' > /dev/null 2>&1; then + display="$1" + else + serverargs="$serverargs $1" + fi + fi + ;; + esac + shift +done + +# process client arguments +if [ x"$client" = x ]; then + client=$defaultclient + + # For compatibility reasons, only use startxrc if there were no client command line arguments + if [ x"$clientargs" = x ]; then + if [ -f "$userclientrc" ]; then + client=$userclientrc + elif [ -f "$sysclientrc" ]; then + client=$sysclientrc + fi + fi +fi + +# if no client arguments, use defaults +if [ x"$clientargs" = x ]; then + clientargs=$defaultclientargs +fi + +# process server arguments +if [ x"$server" = x ]; then + server=$defaultserver + + + # When starting the defaultserver start X on the current tty to avoid + # the startx session being seen as inactive: + # "https://bugzilla.redhat.com/show_bug.cgi?id=806491" + tty=$(tty) + if expr "$tty" : '/dev/tty[0-9][0-9]*$' > /dev/null; then + tty_num=$(echo "$tty" | grep -oE '[0-9]+$') + vtarg="vt$tty_num -keeptty" + fi + + + # For compatibility reasons, only use xserverrc if there were no server command line arguments + if [ x"$serverargs" = x -a x"$display" = x ]; then + if [ -f "$userserverrc" ]; then + server=$userserverrc + elif [ -f "$sysserverrc" ]; then + server=$sysserverrc + fi + fi +fi + +# if no server arguments, use defaults +if [ x"$serverargs" = x ]; then + serverargs=$defaultserverargs +fi + +# if no vt is specified add vtarg (which may be empty) +have_vtarg="no" +for i in $serverargs; do + if expr "$i" : 'vt[0-9][0-9]*$' > /dev/null; then + have_vtarg="yes" + fi +done +if [ "$have_vtarg" = "no" ]; then + serverargs="$serverargs $vtarg" +fi + +# if no display, use default +if [ x"$display" = x ]; then + display=$defaultdisplay +fi + +if [ x"$enable_xauth" = x1 ] ; then + if [ x"$XAUTHORITY" = x ]; then + XAUTHORITY=$HOME/.Xauthority + export XAUTHORITY + fi + + removelist= + + # set up default Xauth info for this machine + hostname=`uname -n` + + authdisplay=${display:-:0} + + mcookie=`/usr/bin/mcookie` + + + + + + + + if test x"$mcookie" = x; then + echo "Couldn't create cookie" + exit 1 + fi + dummy=0 + + # create a file with auth information for the server. ':0' is a dummy. + xserverauthfile=`mktemp -p /tmp serverauth.XXXXXXXXXX` + trap "rm -f '$xserverauthfile'" HUP INT QUIT ILL TRAP KILL BUS TERM + xauth -q -f "$xserverauthfile" << EOF +add :$dummy . $mcookie +EOF + + + + + serverargs=${serverargs}" -auth "${xserverauthfile} + + + # now add the same credentials to the client authority file + # if '$displayname' already exists do not overwrite it as another + # server may need it. Add them to the '$xserverauthfile' instead. + for displayname in $authdisplay $hostname/unix$authdisplay; do + authcookie=`xauth list "$displayname" \ + | sed -n "s/.*$hostname\/unix$authdisplay[[:space:]*].*[[:space:]*]//p"` 2>/dev/null; + if [ "z${authcookie}" = "z" ] ; then + xauth -q << EOF +add $displayname . $mcookie +EOF + removelist="$displayname $removelist" + else + dummy=$(($dummy+1)); + xauth -q -f "$xserverauthfile" << EOF +add :$dummy . $authcookie +EOF + fi + done +fi + + + + +xinit "$client" $clientargs -- "$server" $display $serverargs + +retval=$? + +if [ x"$enable_xauth" = x1 ] ; then + if [ x"$removelist" != x ]; then + xauth remove $removelist + fi + if [ x"$xserverauthfile" != x ]; then + rm -f "$xserverauthfile" + fi +fi + + + + + +if command -v deallocvt > /dev/null 2>&1; then + deallocvt +fi + + + + + + +exit $retval diff --git a/home-manager/packages/scripts/wrappers/ll b/home-manager/packages/scripts/wrappers/ll new file mode 100755 index 00000000..d177b341 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/ll @@ -0,0 +1,13 @@ +#! /bin/bash +export LLP=0 +tmp="$(mktemp)" +lf -last-dir-path="$tmp" "$@" +if [ -f "$tmp" ]; then + dir="$(cat "$tmp")" + rm -f "$tmp" + if [ -d "$dir" ]; then + if [ "$dir" != "$(pwd)" ]; then + cd "$dir" + fi + fi +fi diff --git a/home-manager/packages/scripts/wrappers/llp b/home-manager/packages/scripts/wrappers/llp new file mode 100755 index 00000000..2a21450c --- /dev/null +++ b/home-manager/packages/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/home-manager/packages/scripts/wrappers/spodi b/home-manager/packages/scripts/wrappers/spodi new file mode 100755 index 00000000..9c440340 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/spodi @@ -0,0 +1,39 @@ +#!/bin/sh + +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +DOWN_DIR=/home/dt/media/playlist/down/ + + +tmp=$(mktemp) +config=$(mktemp) + +for e in "$DOWN_DIR"/*.mp3;do echo "$e" >> "$tmp";done +cat << EO > "$config" +--log-level INFO +--cache-path /home/dt/.config/spotdl/.spotipy +--audio youtube-music youtube +--lyrics genius musixmatch azlyrics +--ffmpeg ffmpeg +--format mp3 +--output {artists}-{title}.{output-ext} +--overwrite skip +--client-id 5f573c9620494bae87890c0f08a60293 +--client-secret 212476d9b0f3472eaa762d90b19b0ba8 +--threads 16 +--print-errors +--preload +EO + +[ "$(wc -l "$tmp" | awk '{print $1}')" -gt 2 ] && die "something is already downloaded" + +rm ${DOWN_DIR}spotdl.log +cd $DOWN_DIR || die "BUG: no $DOWN_DIR" + +unbuffer spotdl $(cat "$config") download "$1" | tee $DOWN_DIR/spotdl.log + +[ -d ~/.spotdl ] && rm -r ~/.spotdl +rm "$tmp" +rm "$config" diff --git a/home-manager/packages/scripts/wrappers/virsh-del b/home-manager/packages/scripts/wrappers/virsh-del new file mode 100755 index 00000000..f2bd8e3d --- /dev/null +++ b/home-manager/packages/scripts/wrappers/virsh-del @@ -0,0 +1,14 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + +LIB_TEMP_DIR_FOR_SCRIPT=$(mktemp -d); + +virsh destroy "$1" +virsh undefine "$1" --nvram +virsh vol-delete --pool default "$1".qcow2 + + + +if [ -d "$LIB_TEMP_DIR_FOR_SCRIPT" ];then rm -r "$LIB_TEMP_DIR_FOR_SCRIPT"; fi diff --git a/home-manager/packages/scripts/wrappers/yti b/home-manager/packages/scripts/wrappers/yti new file mode 100755 index 00000000..97350b37 --- /dev/null +++ b/home-manager/packages/scripts/wrappers/yti @@ -0,0 +1,36 @@ +#!/bin/sh +# shellcheck disable=SC2086 +# shellcheck source=/dev/null +. ~/.local/lib/shell/lib + + +DOWN_DIR=/home/dt/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 + +if [ -d /tmp/LIB_FILE_TEMP_DIR/ ];then rm -r /tmp/LIB_FILE_TEMP_DIR/; fi -- cgit 1.4.1