diff options
author | Soispha <soispha@vhack.eu> | 2024-02-20 17:21:42 +0100 |
---|---|---|
committer | Soispha <soispha@vhack.eu> | 2024-02-20 17:21:42 +0100 |
commit | f2bdeaed0bcf97a880fe36cfc8a050d1643120b8 (patch) | |
tree | ba4fe9c3ddf076529701c0e776ffef2104ac23d5 /hm/soispha/pkgs/scripts/wrappers | |
parent | refactor(treewide): Add a `.sh` extension to shell scripts (diff) | |
download | nixos-config-f2bdeaed0bcf97a880fe36cfc8a050d1643120b8.zip |
refactor(treewide): Reformat all files with treefmt
This includes getting all shellscripts to pass shellcheck. To accomplish this, some old scripts were removed
Diffstat (limited to '')
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/hibernate.sh | 5 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/lock.sh | 5 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/mpc-fav.sh | 9 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/mpc-rm.sh | 8 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/sort_song.sh | 35 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/spodi.sh | 13 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/yti.sh | 5 |
7 files changed, 35 insertions, 45 deletions
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" |