diff options
Diffstat (limited to 'hm/soispha/pkgs')
22 files changed, 413 insertions, 451 deletions
diff --git a/hm/soispha/pkgs/scripts/apps/aumo.sh b/hm/soispha/pkgs/scripts/apps/aumo.sh index b5840fc3..7426115a 100755 --- a/hm/soispha/pkgs/scripts/apps/aumo.sh +++ b/hm/soispha/pkgs/scripts/apps/aumo.sh @@ -3,52 +3,23 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -# TODO: rewrite this - -if [ "$1" = "-u" ];then udisksctl unmount -b "$(cat "$HOME/.cache/aumo/mnt_disk")"; exit 0; fi -all_available_disks=$(mktemp) -awk '{print $4}' /proc/partitions | sed '1 s|.*||' > "$all_available_disks" - -mounted_disk=$(mktemp) -awk '{print $1}' /proc/mounts > "$mounted_disk" - -unmounted_disks=$(mktemp) - -for i in $(cat $all_available_disks);do - if ! grep -qw "/dev/$i" $mounted_disk && ! ls /sys/block/$i/*/partition > /dev/null 2> /dev/null;then echo $i >> $unmounted_disks;fi -done - - -u=1 -disk=-1 -while [ $disk -lt 0 ] || [ $disk -gt $(wc -l $unmounted_disks | awk '{print $1}') ];do - - [ "$1" = "-v" ] && for i in $(cat $unmounted_disks);do - sudo fdisk -l "/dev/$i" - done - - for i in $(cat $unmounted_disks);do - printf "%4s) %s\n" "$u" "$i" - u=$(( u + 1 )) - done - - printf "%4s) Exit\n" "0" - printf "Input number: " - read -r disk - - [ $disk -lt 0 ] || [ $disk -gt $(wc -l $unmounted_disks | awk '{print $1}') ] && printf "Wrong number. Please retry\n" - [ $disk -eq 0 ] && exit 0 -done - -mnt_disk="/dev/$(awk -v n=$disk 'NR==n' $unmounted_disks)" - -if ! [ "$1" = "-v" ] && [ -n "$1" ];then sudo mount "$mnt_disk" "$1" && exit 0;fi -[ -n "$2" ] && sudo mount "$mnt_disk" "$1" && exit 0 -if mount | grep -q ~/mnt ;then dien "Something is mounted at ~/mnt";else udisksctl mount -b "$mnt_disk";fi - -[ -e $HOME/.cache/aumo/mnt_disk ] || mkdir -p $HOME/.cache/aumo -echo $mnt_disk >> $HOME/.cache/aumo/mnt_disk -rm $all_available_disks -rm $mounted_disk -rm $unmounted_disks -[ -d /tmp/LIB_FILE_TEMP_DIR/ ] && rm -r /tmp/LIB_FILE_TEMP_DIR/ +unmounting() { + disk_name="$(find /dev/disk/by-label -type l -printf "%P|" | rofi -sep "|" -dmenu -p "Select disk to mount")" + + udisksctl unmount --block-device "/dev/disk/by-label/$disk_name" +} + +mounting() { + disk_name="$(find /dev/disk/by-label -type l -printf "%P|" | rofi -sep "|" -dmenu -p "Select disk to mount")" + + udisksctl mount --block-device "/dev/disk/by-label/$disk_name" +} + +case "$1" in +"mount") + mounting + ;; +"unmount" | "umount") + unmounting + ;; +esac diff --git a/hm/soispha/pkgs/scripts/apps/con2pdf.sh b/hm/soispha/pkgs/scripts/apps/con2pdf.sh index be8810bb..620a299a 100755 --- a/hm/soispha/pkgs/scripts/apps/con2pdf.sh +++ b/hm/soispha/pkgs/scripts/apps/con2pdf.sh @@ -3,17 +3,19 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - # needed for help() and version # shellcheck disable=2034 -AUTHORS="Soispha"; +AUTHORS="Soispha" # shellcheck disable=2034 -YEARS="2023"; +YEARS="2023" # shellcheck disable=2034 -VERSION="1.0.0"; +VERSION="1.0.0" +# NAME is from the wrapper +# shellcheck disable=SC2269 +NAME="$NAME" help() { -cat << EOF + cat <<EOF Scan images and turn them into a pdf. Usage: @@ -60,98 +62,97 @@ EOF } scan_adf() { - device="$1"; - sides_per_page="$2"; - method="ADF"; - for i in $(seq "$sides_per_page");do + device="$1" + sides_per_page="$2" + method="ADF" + for i in $(seq "$sides_per_page"); do do_until_success \ "scanimage --format=tiff --progress --source='$method' --device='$device' --batch=%d.tif --batch-increment='$sides_per_page' --batch-start='$i'" \ "warn 'Retrying scan, as we assume a network error!'" - - if [ "$sides_per_page" -ne 1 ];then - msg "Finished turn, please change side!"; + if [ "$sides_per_page" -ne 1 ]; then + msg "Finished turn, please change side!" readp "Press enter to continue" noop fi done } process_images_adf() { - tiff_temp_path="$1"; - output_directory="$2"; - name="$3"; + tiff_temp_path="$1" + output_directory="$2" + name="$3" - counter=0; - pdf_counter=0; + counter=0 + pdf_counter=0 image_cache="$(mktmp)" while read -r scanned_image; do - dbg "$scanned_image (scanned_image) at $counter (counter)"; - echo "$scanned_image" >> "$image_cache" + dbg "$scanned_image (scanned_image) at $counter (counter)" + echo "$scanned_image" >>"$image_cache" : $((counter += 1)) if [ "$counter" = "$number_of_pages" ]; then dbg "$counter == $number_of_pages" - counter=0; + counter=0 convert_images "$image_cache" "${name}_$pdf_counter" "$output_directory" : $((pdf_counter += 1)) - printf "" > "$image_cache" + printf "" >"$image_cache" fi - done < "$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" + done <"$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" } scan_flatbed() { - device="$1"; - number_of_pages"$2"; - method="Flatbed"; + device="$1" + number_of_pages"$2" + method="Flatbed" for i in $(seq "$number_of_pages"); do do_until_success \ "scanimage --format=tiff --progress --source='$method' --device='$device' --output-file=$i.tiff" \ "warn 'Retrying scan, as we assume a network error!'" - if [ "$number_of_pages" -ne 1 ];then - msg "Finished turn, please change side!"; + if [ "$number_of_pages" -ne 1 ]; then + msg "Finished turn, please change side!" readp "Press enter to continue" noop fi done } process_images_flatbed() { - tiff_temp_path="$1"; - output_directory="$2"; - name="$3"; + tiff_temp_path="$1" + output_directory="$2" + name="$3" - counter=0; + counter=0 image_cache="$(mktmp)" while read -r scanned_image; do - echo "$scanned_image" >> "$image_cache" + echo "$scanned_image" >>"$image_cache" : $((counter += 1)) if [ "$counter" = "$number_of_pages" ]; then - counter=0; + counter=0 convert_images "$image_cache" "$name" "$output_directory" - printf "" > "$image_cache" + printf "" >"$image_cache" fi - done < "$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" + done <"$(tmp_pipe fd . "$tiff_temp_path" "|" sort -V)" } convert_images() { - image_cache="$1"; - pdf_name="$2"; - output_dir="$3"; + image_cache="$1" + pdf_name="$2" + output_dir="$3" set -- while read -r image; do - dbg "setting image: $image"; + dbg "setting image: $image" set -- "$@" "$image" - done < "$image_cache" + done <"$image_cache" while [ -e "$output_dir/${pdf_name}.pdf" ]; do pdf_name="${pdf_name}_$(tr -dc 'A-Za-z0-9' </dev/urandom | head -c 25)" done - dbg "using pdf_name: $pdf_name"; + dbg "using pdf_name: $pdf_name" convert "$@" -compress jpeg -quality 100 "$output_dir/${pdf_name}.pdf" } scan() { - number_of_pages="$1"; - device="$2"; - output_directory="$(readlink -f "$3")"; - name="$4"; - method="$5"; + number_of_pages="$1" + device="$2" + output_directory="$(readlink -f "$3")" + name="$4" + method="$5" [ -z "$number_of_pages" ] && die "Parameter 'number_of_pages' is not set!" [ -z "$device" ] && die "Parameter 'device' is not set!" @@ -159,21 +160,21 @@ scan() { [ -z "$name" ] && die "Parameter 'name' is not set!" [ -z "$method" ] && die "Parameter 'method' is not set!" - tiff_temp_path="$(mktmp -d)"; + tiff_temp_path="$(mktmp -d)" cd "$tiff_temp_path" || die "Bug" - msg "Started scanning..."; + msg "Started scanning..." if [ "$method" = "Flatbed" ]; then scan_flatbed "$device" "$number_of_pages" else scan_adf "$device" "$number_of_pages" fi - msg "Creating output directory..."; - mkdir "$output_directory"; + msg "Creating output directory..." + mkdir "$output_directory" cd "$output_directory" || die "Bug" - msg "Converting images to pdfs..."; + msg "Converting images to pdfs..." if [ "$method" = "Flatbed" ]; then process_images_flatbed "$tiff_temp_path" "$output_directory" "$name" else @@ -181,57 +182,53 @@ scan() { fi } - for input in "$@"; do case "$input" in - "--help" | "-h") - help; - exit 0; - ;; - "--version" | "-v") - version; - exit 0; - ;; + "--help" | "-h") + help + exit 0 + ;; + "--version" | "-v") + version + exit 0 + ;; esac done -number_of_pages="1"; -unset device; -output_directory="$(pwd)/pdf"; -unset name; -method="ADF"; +number_of_pages="1" +unset device +output_directory="$(pwd)/pdf" +unset name +method="ADF" while [ "$#" -ne 0 ]; do case "$1" in - "--help" | "-h") - ;; - "--version" | "-v") - ;; - "--out-dir" | "-o") - shift 1; - output_directory="$1"; - ;; - "--name" | "-n") - shift 1; - name="$1"; - ;; - "--num-pages" | "-p") - shift 1; - number_of_pages="$1"; - ;; - "--device" | "-d") - shift 1; - device="$1"; - ;; - "--method" | "-m") - shift 1; - method="$1"; - ;; - *) - die "Command line arg $1 does not exist. See --help for a list."; - ;; + "--help" | "-h") ;; + "--version" | "-v") ;; + "--out-dir" | "-o") + shift 1 + output_directory="$1" + ;; + "--name" | "-n") + shift 1 + name="$1" + ;; + "--num-pages" | "-p") + shift 1 + number_of_pages="$1" + ;; + "--device" | "-d") + shift 1 + device="$1" + ;; + "--method" | "-m") + shift 1 + method="$1" + ;; + *) + die "Command line arg $1 does not exist. See --help for a list." + ;; esac - shift 1; + shift 1 done -scan "$number_of_pages" "$device" "$output_directory" "$name" "$method"; - +scan "$number_of_pages" "$device" "$output_directory" "$name" "$method" diff --git a/hm/soispha/pkgs/scripts/apps/fupdate.1.md b/hm/soispha/pkgs/scripts/apps/fupdate.1.md index b2b7bf4f..710e8fb7 100644 --- a/hm/soispha/pkgs/scripts/apps/fupdate.1.md +++ b/hm/soispha/pkgs/scripts/apps/fupdate.1.md @@ -3,29 +3,34 @@ % May 2023 # NAME + fupdate - updates your flake, while checking for common mistakes # SYNOPSIS -**fupdate** list of [*flake*|*<some word>*|*--help*|*-h*] + +**fupdate** list of \[*flake*|*\<some word>*|*--help*|*-h*\] # DESCRIPTION + Argument can be stacked, this makes it possible to specify multiple targets to be updated in succession. See the Examples section for further details. No argument or *flake* : **fupdate**, when executed without arguments or with *flake*, will update your *flake.lock*, check for duplicate flake inputs, i.e., an input has an input declared, which you have also declared as input, and will run a script called *update.sh*, if you allow it. The allowance for the script is asked, when you run **fupdate** and the found script is not yet allowed. Furthermore, the allowance is based on the concrete sha256 hash of the script, so any changes will require another allowance. -**<some word>** as argument -: If the executable **update-<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. +**\<some word>** as argument +: If the executable **update-\<some word>** is reachable thought the PATH variable, than this is run. Otherwise, the program will exit. # OPTIONS -**\-\-help**, **-h** + +**--help**, **-h** : Displays a help message and exit. -**\-\-version**, **-v** +**--version**, **-v** : Displays the software version and exit. # EXAMPLES + **fupdate** or **fupdate flake** : Updates your *flake.lock*. See the Description section for further details. @@ -36,6 +41,7 @@ The allowance for the script is asked, when you run **fupdate** and the found sc : First updates your flake, then, if the command succeeded, runs **update-sys**, afterweich **update-docs** is run. # FILES + *update.sh* : This is supposed to be a shell script located in your flake base directory, i.e., the directory which contains both a *flake.nix* and a *flake.lock* file. @@ -43,9 +49,11 @@ The allowance for the script is asked, when you run **fupdate** and the found sc : **fupdate** will store the hashes to the allowed *update.sh* files here. # BUGS + Report bugs to <https://codeberg.org/soispha/flake_update/issues>. # COPYRIGHT + Copyright (C) 2023 Soispha This program is free software: you can redistribute it and/or modify diff --git a/hm/soispha/pkgs/scripts/apps/fupdate.sh b/hm/soispha/pkgs/scripts/apps/fupdate.sh index 7722c070..c038fa69 100755 --- a/hm/soispha/pkgs/scripts/apps/fupdate.sh +++ b/hm/soispha/pkgs/scripts/apps/fupdate.sh @@ -3,11 +3,13 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH +UPDATE_SCRIPT_NAME="update.sh" +CONFIG_DIRECTORY_PATH="$HOME/.local/share/flake-update" -UPDATE_SCRIPT_NAME="update.sh"; -CONFIG_DIRECTORY_PATH="$HOME/.local/share/flake-update"; - +# Both are used in version() +# shellcheck disable=SC2034 AUTHORS="Soispha" +# shellcheck disable=SC2034 YEARS="2023" # Searches upward for a `UPDATE_SCRIPT_NAME` script @@ -22,68 +24,68 @@ check_for_update_script() { # Checks if a given path to the update script is allowed. # Takes the path as input # Return 0, if allowed, 1 if not. -check_for_allowed_update_script(){ - update_script="$1"; - config_path="${CONFIG_DIRECTORY_PATH}${update_script}"; - update_script_hash="$(sha256sum "$update_script")"; +check_for_allowed_update_script() { + update_script="$1" + config_path="${CONFIG_DIRECTORY_PATH}${update_script}" + update_script_hash="$(sha256sum "$update_script")" if [ -f "$config_path" ]; then - if [ "$(cat "$config_path")" = "$update_script_hash" ];then - dbg "Recorded hash matches"; - return 0; + if [ "$(cat "$config_path")" = "$update_script_hash" ]; then + dbg "Recorded hash matches" + return 0 else - dbg "Recorded hash \'$(cat "$config_path")\' does not match real hash \'$update_script_hash\', assuming not allowed"; - return 1; + dbg "Recorded hash \'$(cat "$config_path")\' does not match real hash \'$update_script_hash\', assuming not allowed" + return 1 fi else - dbg "Path \'$config_path\' does not exist, assuming not allowed"; - return 1; + dbg "Path \'$config_path\' does not exist, assuming not allowed" + return 1 fi } - # Asks the user if they want to allow a given script. # Takes the path as input -ask_to_allow_update_script(){ - update_script="$1"; - config_path="${CONFIG_DIRECTORY_PATH}${update_script}"; - update_script_hash="$(sha256sum "$update_script")"; - println "\033[2J"; # clear the screen - cat "$update_script"; - readp "Do you want to allow this script?[N/y]: " allow; - dbg "allow is: $allow"; +ask_to_allow_update_script() { + update_script="$1" + config_path="${CONFIG_DIRECTORY_PATH}${update_script}" + update_script_hash="$(sha256sum "$update_script")" + println "\033[2J" # clear the screen + cat "$update_script" + readp "Do you want to allow this script?[N/y]: " allow + # shellcheck disable=SC2154 + dbg "allow is: $allow" case "$allow" in - [yY]) - dbg "allowed script"; - dbg "storing contents in: $config_path"; - mkdir --parents "$(dirname "$config_path")"; - print "$update_script_hash" > "$config_path"; - ;; - *) - UPDATE_SCRIPT_NOT_ALLOWED=true; - ;; + [yY]) + dbg "allowed script" + dbg "storing contents in: $config_path" + mkdir --parents "$(dirname "$config_path")" + print "$update_script_hash" >"$config_path" + ;; + *) + UPDATE_SCRIPT_NOT_ALLOWED=true + ;; esac } # Runs the provided script and continues to update the nix flake # Takes the path to the script and the directory to the flake as arguments # If the path to the update script is empty, it will be ignored -update(){ - update_script="$1"; - flake_base_dir="$2"; +update() { + update_script="$1" + flake_base_dir="$2" - [ "$update_script" = "" ] || "$update_script"; - dbg "changed directory to: $flake_base_dir"; - cd "$flake_base_dir" || die "Provided dir \'$flake_base_dir\' can not be accessed"; + [ "$update_script" = "" ] || "$update_script" + dbg "changed directory to: $flake_base_dir" + cd "$flake_base_dir" || die "Provided dir \'$flake_base_dir\' can not be accessed" nix flake update - if grep '[^0-9]_[0-9]' flake.lock > /dev/null; then - batgrep '[^0-9]_[0-9]' flake.lock; - die "Your flake.nix contains duplicate inputs!"; + if grep '[^0-9]_[0-9]' flake.lock >/dev/null; then + batgrep '[^0-9]_[0-9]' flake.lock + die "Your flake.nix contains duplicate inputs!" fi } help() { -cat << EOF + cat <<EOF This is a Nix flake update manager. Usage: @@ -105,63 +107,63 @@ EOF main() { if ! [ "$UPDATE_SCRIPT_NOT_ALLOWED" = true ]; then - update_script="$(check_for_update_script)"; - flake_base_dir="$(search_flake_base_dir)"; # Assume, that the update script is in the base dir - dbg "update_script is: $update_script"; - dbg "flake_base_dir is: $flake_base_dir"; + update_script="$(check_for_update_script)" + flake_base_dir="$(search_flake_base_dir)" # Assume, that the update script is in the base dir + dbg "update_script is: $update_script" + dbg "flake_base_dir is: $flake_base_dir" if [ "$update_script" = "" ]; then - update "" "$flake_base_dir"; + update "" "$flake_base_dir" elif check_for_allowed_update_script "$update_script" && ! [ "$update_script" = "" ]; then - update "$update_script" "$flake_base_dir"; + update "$update_script" "$flake_base_dir" else - ask_to_allow_update_script "$update_script"; - main; + ask_to_allow_update_script "$update_script" + main fi fi } if [ "$#" -eq 0 ]; then - main; + main fi for input in "$@"; do case "$input" in - "--help" | "-h") - help; - exit 0; - ;; - "--version" | "-v") - version; - exit 0; - ;; - "--") - end_of_cli_options=true; - ;; + "--help" | "-h") + help + exit 0 + ;; + "--version" | "-v") + version + exit 0 + ;; + "--") + end_of_cli_options=true + ;; esac [ "$end_of_cli_options" = "true" ] && break done while [ "$#" -ne 0 ]; do case "$1" in - "flake") - main; - shift 1; - ;; - *) - command="$1"; - shift 1; - [ "$1" = "--" ] && shift 1 - if which update-"$command" > /dev/null 2>&1;then - if [ "$end_of_cli_options" = "true" ]; then - update-"$command" "$@"; - else - update-"$command"; - fi + "flake") + main + shift 1 + ;; + *) + command="$1" + shift 1 + [ "$1" = "--" ] && shift 1 + if which update-"$command" >/dev/null 2>&1; then + if [ "$end_of_cli_options" = "true" ]; then + update-"$command" "$@" else - die "command \"update-$command\" is not executable, or does not exist"; + update-"$command" fi - ;; + else + die "command \"update-$command\" is not executable, or does not exist" + fi + ;; esac [ "$end_of_cli_options" = "true" ] && break done diff --git a/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh b/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh index 9e73bed3..5992e02f 100755 --- a/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh +++ b/hm/soispha/pkgs/scripts/small_functions/screenshot_persistent.sh @@ -6,20 +6,17 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # only generate a path (this could lead to a time-of-check/time-of-use bug) tmp="$(mktmp --dry-run)" -if grim -g "$(slurp)" "$tmp" -then - name="$(rofi -dmenu -p "Name of screenshot: " -l 0)"; - screen_shot_path="$HOME/media/pictures/screenshots/$name.png"; - while [ -f "$screen_shot_path" ] - do +if grim -g "$(slurp)" "$tmp"; then + name="$(rofi -dmenu -p "Name of screenshot: " -l 0)" + screen_shot_path="$HOME/media/pictures/screenshots/$name.png" + while [ -f "$screen_shot_path" ]; do notify-send "Warning" 'Screenshot name already in use!' - name="$(rofi -dmenu -p "New name of screenshot: " -l 0)"; - screen_shot_path="$HOME/media/pictures/screenshots/$name.png"; + name="$(rofi -dmenu -p "New name of screenshot: " -l 0)" + screen_shot_path="$HOME/media/pictures/screenshots/$name.png" done - mv "$tmp" "$screen_shot_path"; - alacritty -e lf -command ":{{ set sortby atime; set reverse!; }}"; + mv "$tmp" "$screen_shot_path" + alacritty -e lf -command ":{{ set sortby atime; set reverse!; }}" fi - # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/small_functions/update-sys.sh b/hm/soispha/pkgs/scripts/small_functions/update-sys.sh index 20e38841..68fb342d 100755 --- a/hm/soispha/pkgs/scripts/small_functions/update-sys.sh +++ b/hm/soispha/pkgs/scripts/small_functions/update-sys.sh @@ -4,7 +4,7 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH help() { - cat << EOF + cat <<EOF This is a NixOS System flake update manager. Usage: @@ -18,61 +18,60 @@ Options: --help | -h output this help. EOF - exit "$1"; + exit "$1" } -default_branch=$(mktmp); -BRANCH=""; +default_branch=$(mktmp) +BRANCH="" -while [ "$#" -gt 0 ];do +while [ "$#" -gt 0 ]; do case "$1" in - "--help" | "-h") - help 0; - ;; - "--branch" | "-b") - if [ -n "$2" ];then - BRANCH="$2"; - else - error "$1 requires an argument"; - help 1; - fi - shift 2; - ;; - "--mode" | "-m") - if [ -n "$2" ];then - MODE="$2"; - else - error "$1 requires an argument"; - help 1; - fi - shift 2; - ;; - *) - error "the option $1 does not exist!"; - help 1; - ;; + "--help" | "-h") + help 0 + ;; + "--branch" | "-b") + if [ -n "$2" ]; then + BRANCH="$2" + else + error "$1 requires an argument" + help 1 + fi + shift 2 + ;; + "--mode" | "-m") + if [ -n "$2" ]; then + MODE="$2" + else + error "$1 requires an argument" + help 1 + fi + shift 2 + ;; + *) + error "the option $1 does not exist!" + help 1 + ;; esac done - -cd /etc/nixos || die "No /etc/nixos"; -msg "Starting system update..."; -git remote update origin --prune > /dev/null 2>&1; -if ! [ "$BRANCH" = "" ];then - git switch "$BRANCH" > /dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'"; +cd /etc/nixos || die "No /etc/nixos" +msg "Starting system update..." +git remote update origin --prune >/dev/null 2>&1 +if ! [ "$BRANCH" = "" ]; then + git switch "$BRANCH" >/dev/null 2>&1 && msg2 "Switched to branch '$BRANCH'" fi -msg2 "Updating git repository..."; -git pull --rebase; +msg2 "Updating git repository..." +git pull --rebase -git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' > "$default_branch" & +git remote show origin | grep 'HEAD' | cut -d':' -f2 | sed -e 's/^ *//g' -e 's/ *$//g' >"$default_branch" & -msg2 "Updating system..."; +msg2 "Updating system..." if [ -n "$MODE" ]; then - nixos-rebuild "$MODE"; + nixos-rebuild "$MODE" else - nixos-rebuild switch; + nixos-rebuild switch fi -git switch "$(cat "$default_branch")" > /dev/null 2>&1 && msg2 "Switched to branch '$(cat "$default_branch")'"; -msg "Finished Update!"; +git switch "$(cat "$default_branch")" >/dev/null 2>&1 && msg2 "Switched to branch '$(cat "$default_branch")'" +msg "Finished Update!" # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/specific/neorg/neorg_id_function.sh b/hm/soispha/pkgs/scripts/specific/neorg/neorg_id_function.sh index 413a18de..7c3fb2a3 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/neorg_id_function.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/neorg_id_function.sh @@ -1,12 +1,12 @@ #! /bin/sh -context="$(task _get rc.context)"; +context="$(task _get rc.context)" if [ "$context" ]; then - filter="project:$context"; + filter="project:$context" else - filter="0-10000"; + filter="0-10000" fi -tasks="$(task "$filter" _ids)"; +tasks="$(task "$filter" _ids)" if [ "$tasks" ]; then - echo "$tasks" | xargs task _zshids | awk -F: -v q="'" '{gsub(/'\''/, q "\\" q q ); print $1 ":" q $2 q}'; + echo "$tasks" | xargs task _zshids | awk -F: -v q="'" '{gsub(/'\''/, q "\\" q q ); print $1 ":" q $2 q}' fi diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh index bd700775..5a830a10 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/add.sh @@ -1,23 +1,23 @@ #!/usr/bin/env dash add0open_taskwarrior_project_file() { - task_project_file="%TASK_PROJECT_FILE"; + task_project_file="%TASK_PROJECT_FILE" cd "$(dirname $task_project_file)" || die "BUG: task_project_file ('$task_project_file') can't be accessed" - git_dir="$(search_flake_base_dir)"; + git_dir="$(search_flake_base_dir)" [ "$git_dir" ] || die "(BUG): No git directory?" cd "$git_dir" || die "Unreachable, this MUST exists" - nvim "$task_project_file"; - git add "$task_project_file"; + nvim "$task_project_file" + git add "$task_project_file" base_task_project_file_path="$(awk "{ gsub(\"$git_dir/\", \"\", \$0); print }" "$(ptmp "$task_project_file")")" - git add $task_project_file; + git add $task_project_file # Check that only the project file has been added (and that our file is actually # modified) if git status --porcelain=v2 | awk -v path="$base_task_project_file_path" 'BEGIN { hit = 0 } { if ($2 ~ /A./ || $2 ~ /M./) { if ($NF ~ path) { hit = 1 } else { hit = 0; exit 1 } } } END { if (hit == 1) { exit 0 } else { exit 1 } }'; then - git commit --verbose --message="chore($(dirname "$base_task_project_file_path")): Update" + git commit --verbose --message="chore($(dirname "$base_task_project_file_path")): Update" fi } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh index b9ae4463..7095847d 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/context.sh @@ -4,40 +4,40 @@ context0open_current_task_context() { current_context="$(utils0get_current_context)" if [ "$current_context" ]; then - context_path="$(utils0get_current_context_path "$current_context")"; + context_path="$(utils0get_current_context_path "$current_context")" - extended_neorg_project_dir="$(utils0get_neorg_project_dir)"; - cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"; + extended_neorg_project_dir="$(utils0get_neorg_project_dir)" + cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir" - nvim "$extended_neorg_project_dir/$context_path"; + nvim "$extended_neorg_project_dir/$context_path" - git add .; + git add . git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign else - warn "No context active"; + warn "No context active" fi } context0open_current_task_context_at_task_id() { - task_id="$1"; + task_id="$1" current_context="$(utils0get_current_context)" if [ "$current_context" ]; then - context_path="$(utils0get_current_context_path "$current_context")"; - extended_neorg_project_dir="$(utils0get_neorg_project_dir)"; + context_path="$(utils0get_current_context_path "$current_context")" + extended_neorg_project_dir="$(utils0get_neorg_project_dir)" task_uuid="$(task "$task_id" uuids)" - cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir"; + cd "$extended_neorg_project_dir" || die "(BUG?): Can not access the project dir: $extended_neorg_project_dir" if ! grep -q "% $task_uuid" "$extended_neorg_project_dir/$context_path"; then - echo "* TITLE (% $task_uuid)" >> "$extended_neorg_project_dir/$context_path" + echo "* TITLE (% $task_uuid)" >>"$extended_neorg_project_dir/$context_path" fi - nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid"; + nvim "$extended_neorg_project_dir/$context_path" -c "/% $task_uuid" - git add .; + git add . git commit --message="chore($(dirname "$context_path")): Update" --no-gpg-sign else - warn "No context active"; + warn "No context active" fi } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh index 36133004..73e9460a 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/dmenu.sh @@ -1,12 +1,12 @@ #!/usr/bin/env dash dmenu0open_context_in_browser() { - project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)"; + project="$(echo "%ALL_PROJECTS_PIPE" | rofi -sep "|" -dmenu)" if [ "$project" ]; then - project0open_project_in_browser "$project"; + project0open_project_in_browser "$project" else - notify-send "(neorg/dmenu) No project selected"; + notify-send "(neorg/dmenu) No project selected" exit 1 fi } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh index c75986a7..2423dd44 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_start.sh @@ -1,7 +1,7 @@ #!/usr/bin/env dash fstart0start_new_task() { - task_id="$1"; - fstop0stop_current_task; + task_id="$1" + fstop0stop_current_task task start "$task_id" } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh index d60cb46f..e4ff0b94 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/f_stop.sh @@ -2,6 +2,6 @@ fstop0stop_current_task() { # we ensured that only one task may be active - active="$(task +ACTIVE _ids)"; - [ "$active" ] && task stop "$active"; + active="$(task +ACTIVE _ids)" + [ "$active" ] && task stop "$active" } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh index 8def0930..64591850 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/project.sh @@ -1,33 +1,32 @@ #!/usr/bin/env dash project0open_current_context_in_browser() { - current_context="$(utils0get_current_context)"; - [ "$current_context" ] || die "No current context to use"; - project0open_context_in_browser "$(utils0context2project "$current_context")"; + current_context="$(utils0get_current_context)" + [ "$current_context" ] || die "No current context to use" + project0open_context_in_browser "$(utils0context2project "$current_context")" } project0open_project_in_browser() { - project="$1"; + project="$1" [ "$project" ] || die "BUG: No context supplied to project0open_context_in_browser" - old_context="$(utils0get_current_context)"; + old_context="$(utils0get_current_context)" # We have ensured that only one task may be active - old_started_task="$(task +ACTIVE _ids)"; + old_started_task="$(task +ACTIVE _ids)" - tracking="$(mktmp)"; - task "project:$project" _ids | xargs --no-run-if-empty task _zshids > "$tracking"; + tracking="$(mktmp)" + task "project:$project" _ids | xargs --no-run-if-empty task _zshids >"$tracking" task context "$(utils0project2context "$project")" while read -r description; do - desc="$(echo "$description" | awk -F: '{print $2}' )"; + desc="$(echo "$description" | awk -F: '{print $2}')" if [ "$desc" = "tracking" ]; then - task_id="$(echo "$description" | awk -F: '{print $1}' )"; - notify-send "(Neorg)" "Starting task $project -> $desc"; + task_id="$(echo "$description" | awk -F: '{print $1}')" + notify-send "(Neorg)" "Starting task $project -> $desc" task start "$task_id" break fi - done < "$tracking" - + done <"$tracking" firefox -P "$project" diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh index 91da811a..c3843e8e 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/functions/utils.sh @@ -3,19 +3,20 @@ # Runs it's first argument and then the second, regardless if the first failed or # succeeded utils0chain() { - eval "$1"; eval "$2" + eval "$1" + eval "$2" } utils0get_current_context() { - current_context="$(task _get rc.context)"; - printf "%s\n" "$current_context"; + current_context="$(task _get rc.context)" + printf "%s\n" "$current_context" } utils0get_current_context_path() { - current_context="$1"; - context_path="$(task _get rc.context."$current_context".rc.neorg_path 2>/dev/null)"; + current_context="$1" + context_path="$(task _get rc.context."$current_context".rc.neorg_path 2>/dev/null)" if ! [ "$context_path" ]; then - context_path="$(grep "context.$current_context.rc.neorg_path" "%HOME_TASKRC" | awk 'BEGIN {FS="="} {print $2}')"; + context_path="$(grep "context.$current_context.rc.neorg_path" "%HOME_TASKRC" | awk 'BEGIN {FS="="} {print $2}')" [ "$context_path" ] || die "All contexts should have a 'neorg_path' set!" fi printf "%s\n" "$context_path" @@ -23,18 +24,17 @@ utils0get_current_context_path() { utils0get_neorg_project_dir() { # Perform shell expansion of Tilde - neorg_project_dir="$(sed "s|^~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR")")"; + neorg_project_dir="$(sed "s|^~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR")")" printf "%s\n" "$neorg_project_dir" } - utils0project2context() { - project="$1"; - context="$(sed 's|\.|_|g' "$(ptmp "$project")")"; - printf "%s\n" "$context"; + project="$1" + context="$(sed 's|\.|_|g' "$(ptmp "$project")")" + printf "%s\n" "$context" } utils0context2project() { - context="$1"; - project="$(sed 's|_|\.|g' "$(ptmp "$context")")"; - printf "%s\n" "$project"; + context="$1" + project="$(sed 's|_|\.|g' "$(ptmp "$context")")" + printf "%s\n" "$project" } diff --git a/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh b/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh index 25b434fc..dc746ef8 100755 --- a/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh +++ b/hm/soispha/pkgs/scripts/specific/neorg/sh/main.sh @@ -14,7 +14,6 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH . ./functions/utils . ./functions/workspace - # these are used in version() # shellcheck disable=2034 AUTHORS="Soispha" @@ -24,7 +23,7 @@ YEARS="2023" NAME="neorg" help() { -cat << EOF + cat <<EOF This is the core interface to the system-integrated task management USAGE: @@ -82,75 +81,75 @@ EOF for arg in "$@"; do case "$arg" in - "--help" | "-h") - help; - exit 0; - ;; - "--version" | "-v") - version; - exit 0; - ;; + "--help" | "-h") + help + exit 0 + ;; + "--version" | "-v") + version + exit 0 + ;; esac done while [ "$#" -ne 0 ]; do case "$1" in - "t"*) # task - shift 1; - task_id="$1"; - [ "$task_id" ] || utils0chain context0open_current_task_context "exit 0" - context0open_current_task_context_at_task_id "$task_id"; - exit 0; - ;; - "w"*) # workspace - shift 1; - workspace_to_open="$1"; - # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> - [ "$workspace_to_open" ] || utils0chain workspace0open_neorg_workspace_prompt "exit 0"; - workspace0open_neorg_workspace "$workspace_to_open"; - exit 0; - ;; - "p"*) # project - shift 1; - project_to_open="$1"; - # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> - [ "$project_to_open" ] || utils0chain project0open_current_context_in_browser "exit 0"; - if ! grep -q "$project_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then - die "Your project ('$project_to_open') is not in the list of available projects: -%ALL_PROJECTS_COMMA"; - fi - project0open_project_in_browser "$project_to_open"; - exit 0; - ;; - "l"*) # list - list0list_all_contexts_newline; - exit 0 - ;; - "a"*) # add-project - add0open_taskwarrior_project_file; - exit 0 - ;; - "d"*) # dmenu - dmenu0open_context_in_browser; - exit 0 - ;; - "fsta"*) # fstart - shift 1; - task_id="$1"; - [ "$task_id" ] || die "No task id provided to fstart"; - fstart0start_new_task "$task_id"; - exit 0 - ;; - "fsto"*) # fstop - fstop0stop_current_task; - exit 0 - ;; - *) - die "Command '$1' does not exist! Please look at:\n $NAME --help"; - exit 0; - ;; + "t"*) # task + shift 1 + task_id="$1" + [ "$task_id" ] || utils0chain context0open_current_task_context "exit 0" + context0open_current_task_context_at_task_id "$task_id" + exit 0 + ;; + "w"*) # workspace + shift 1 + workspace_to_open="$1" + # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> + [ "$workspace_to_open" ] || utils0chain workspace0open_neorg_workspace_prompt "exit 0" + workspace0open_neorg_workspace "$workspace_to_open" + exit 0 + ;; + "p"*) # project + shift 1 + project_to_open="$1" + # TODO: Exit with 1 on error, instead of the 0 <2023-10-20> + [ "$project_to_open" ] || utils0chain project0open_current_context_in_browser "exit 0" + if ! grep -q "$project_to_open" "$(ptmp "%ALL_PROJECTS_NEWLINE")"; then + die "Your project ('$project_to_open') is not in the list of available projects: +%ALL_PROJECTS_COMMA" + fi + project0open_project_in_browser "$project_to_open" + exit 0 + ;; + "l"*) # list + list0list_all_contexts_newline + exit 0 + ;; + "a"*) # add-project + add0open_taskwarrior_project_file + exit 0 + ;; + "d"*) # dmenu + dmenu0open_context_in_browser + exit 0 + ;; + "fsta"*) # fstart + shift 1 + task_id="$1" + [ "$task_id" ] || die "No task id provided to fstart" + fstart0start_new_task "$task_id" + exit 0 + ;; + "fsto"*) # fstop + fstop0stop_current_task + exit 0 + ;; + *) + die "Command '$1' does not exist! Please look at:\n $NAME --help" + exit 0 + ;; esac done -context0open_current_task_context; +context0open_current_task_context # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/hibernate.sh b/hm/soispha/pkgs/scripts/wrappers/hibernate.sh index 96170bcb..f3e74732 100755 --- a/hm/soispha/pkgs/scripts/wrappers/hibernate.sh +++ b/hm/soispha/pkgs/scripts/wrappers/hibernate.sh @@ -3,14 +3,13 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -context="$(task _get rc.context)"; +context="$(task _get rc.context)" [ "$context" ] && task context none # We have ensured that only one task is active -active="$(task +ACTIVE _ids)"; +active="$(task +ACTIVE _ids)" [ "$active" ] && task stop "$active" systemctl hibernate "$@" - # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/lock.sh b/hm/soispha/pkgs/scripts/wrappers/lock.sh index 376773c6..f1c5c711 100755 --- a/hm/soispha/pkgs/scripts/wrappers/lock.sh +++ b/hm/soispha/pkgs/scripts/wrappers/lock.sh @@ -3,12 +3,11 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - -context="$(task _get rc.context)"; +context="$(task _get rc.context)" [ "$context" ] && task context none # We have ensured that only one task is active -active="$(task +ACTIVE _ids)"; +active="$(task +ACTIVE _ids)" [ "$active" ] && task stop "$active" swaylock diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh b/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh index f9107ff6..7385ce43 100755 --- a/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh +++ b/hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh @@ -3,13 +3,12 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites"; +FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites" -cd "$XDG_MUSIC_DIR" || die "No music dir!"; +cd "$XDG_MUSIC_DIR" || die "No music dir!" -[ -d "$FAV_DIR" ] || mkdir --parents "$FAV_DIR"; - -ln -sr "$(mpc --format '%file%' current)" "$FAV_DIR/" || die "Link failed!"; +[ -d "$FAV_DIR" ] || mkdir --parents "$FAV_DIR" +ln -sr "$(mpc --format '%file%' current)" "$FAV_DIR/" || die "Link failed!" # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh b/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh index cc01c322..03673dbe 100755 --- a/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh +++ b/hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh @@ -3,12 +3,8 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH - cd "$XDG_MUSIC_DIR" || die "No music dir!" -trash-put "$(mpc --format '%file%' current)"; -mpc del 0; - - - +trash-put "$(mpc --format '%file%' current)" +mpc del 0 # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/sort_song.sh b/hm/soispha/pkgs/scripts/wrappers/sort_song.sh index f539cf15..8195cfcf 100755 --- a/hm/soispha/pkgs/scripts/wrappers/sort_song.sh +++ b/hm/soispha/pkgs/scripts/wrappers/sort_song.sh @@ -3,31 +3,32 @@ # shellcheck source=/dev/null SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH -case "$("$1" | tr '[:upper:]' '[:lower:]')" in - "lyrics") - filter="LYRICS"; - directory="lyrics"; - ;; - "instrumental") - filter="INSTRUMENTAL"; - directory="instrumental"; - ;; - *) - die "Expected 'instrumental|lyrics' but got '$1'"; +case "$("$1" | tr '[:upper:]' '[:lower:]')" in +"lyrics") + filter="LYRICS" + directory="lyrics" + ;; +"instrumental") + filter="INSTRUMENTAL" + directory="instrumental" + ;; +*) + die "Expected 'instrumental|lyrics' but got '$1'" + ;; esac process() { mediainfo --Output=JSON "$1" | jq '.media.track | map(.Lyrics) | join("")' -}; +} -mkdir "../$directory"; +mkdir "../$directory" fd . --extension=opus | while read -r file; do if [ "$(process "$file")" = '""' ] || [ "$(process "$file")" = '"Instrumental"' ] || [ "$(process "$file")" = '"instrumental"' ]; then - echo "INSTRUMENTAL::$file"; + echo "INSTRUMENTAL::$file" else - echo "LYRICS::$file"; - fi; - done | grep "$filter" | awk 'BEGIN {FS="::"}{print $2}' | while read -r file; do ln -s "../all/$file" "../$directory/$file"; done + echo "LYRICS::$file" + fi +done | grep "$filter" | awk 'BEGIN {FS="::"}{print $2}' | while read -r file; do ln -s "../all/$file" "../$directory/$file"; done # vim: ft=sh diff --git a/hm/soispha/pkgs/scripts/wrappers/spodi.sh b/hm/soispha/pkgs/scripts/wrappers/spodi.sh index f8bc5337..8b4188b0 100755 --- a/hm/soispha/pkgs/scripts/wrappers/spodi.sh +++ b/hm/soispha/pkgs/scripts/wrappers/spodi.sh @@ -4,17 +4,15 @@ SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH # This path must not contain spaces -DOWN_DIR="/home/soispha/media/music/down/spotify"; - -download_url="$1"; - +DOWN_DIR="/home/soispha/media/music/down/spotify" +download_url="$1" already_downloaded_files="$(mktmp)" -fd . "$DOWN_DIR" --exclude spotdl.log --exclude spotdl-errors.log > "$already_downloaded_files"; +fd . "$DOWN_DIR" --exclude spotdl.log --exclude spotdl-errors.log >"$already_downloaded_files" config="$(mktmp)" -cat << EOF | clean > "$config" +cat <<EOF | clean >"$config" # Main options --audio slider-kz bandcamp youtube-music piped youtube soundcloud --lyrics genius musixmatch azlyrics synced @@ -41,7 +39,7 @@ cat << EOF | clean > "$config" --log-level INFO EOF -if [ -z "$NO_CHECK" ] && [ "$(wc -l < "$already_downloaded_files" )" -ne 0 ];then +if [ -z "$NO_CHECK" ] && [ "$(wc -l <"$already_downloaded_files")" -ne 0 ]; then die "something is already downloaded" fi @@ -49,7 +47,6 @@ rm "$DOWN_DIR/spotdl.log" cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR" touch "$DOWN_DIR/spotdl-errors.log" - # 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" diff --git a/hm/soispha/pkgs/scripts/wrappers/yti.sh b/hm/soispha/pkgs/scripts/wrappers/yti.sh index c07f6665..caa5f443 100755 --- a/hm/soispha/pkgs/scripts/wrappers/yti.sh +++ b/hm/soispha/pkgs/scripts/wrappers/yti.sh @@ -8,10 +8,10 @@ DOWN_DIR=/home/soispha/media/music/down/youtube tmp=$(mktmp) config=$(mktmp) -for e in "$DOWN_DIR"/*.opus;do echo "$e" >> "$tmp";done +for e in "$DOWN_DIR"/*.opus; do echo "$e" >>"$tmp"; done [ "$(wc -l "$tmp" | awk '{print $1}')" -gt 2 ] && die "something is already downloaded" -cat << EO > "$config" +cat <<EO >"$config" --paths home:"$DOWN_DIR" #--output %(fulltitle) --restrict-filenames @@ -25,7 +25,6 @@ cat << EO > "$config" --audio-format best EO - rm "$DOWN_DIR/yt-dlp.log" cd "$DOWN_DIR" || die "BUG: no $DOWN_DIR" |