about summary refs log tree commit diff stats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--hm/soispha/pkgs/scripts.nix17
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/mpc-fav13
-rwxr-xr-xhm/soispha/pkgs/scripts/wrappers/sort_song33
3 files changed, 63 insertions, 0 deletions
diff --git a/hm/soispha/pkgs/scripts.nix b/hm/soispha/pkgs/scripts.nix
index a7b055fa..57aff326 100644
--- a/hm/soispha/pkgs/scripts.nix
+++ b/hm/soispha/pkgs/scripts.nix
@@ -151,6 +151,16 @@
     };
   };
 
+  mpc-fav-scr = write_shell {
+    name = "mpc-fav";
+    path = "wrappers";
+    dependencies = builtins.attrValues {
+      inherit
+        (pkgs)
+        mpc-cli
+        ;
+    };
+  };
 
   mpc-rm-scr = write_shell {
     name = "mpc-rm";
@@ -247,6 +257,11 @@
     dependencies = builtins.attrValues {inherit (pkgs) less locale;};
   };
 
+  sort_song-src = write_shell {
+    name = "sort_song";
+    path = "wrappers";
+    dependencies = builtins.attrValues {inherit (pkgs) mediainfo jq gawk;};
+  };
 
   spodi-scr = write_shell {
     name = "spodi";
@@ -281,12 +296,14 @@ in [
   ll-scr
   lock-scr
   lyrics-scr
+  mpc-fav-scr
   mpc-rm-scr
   nato-scr
   neorg-scr
   screenshot_persistent-scr
   screenshot_temporary-scr
   show-scr
+  sort_song-src
   spodi-scr
   update-sys-scr
   virsh-del-scr
diff --git a/hm/soispha/pkgs/scripts/wrappers/mpc-fav b/hm/soispha/pkgs/scripts/wrappers/mpc-fav
new file mode 100755
index 00000000..59121c86
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/mpc-fav
@@ -0,0 +1,13 @@
+#!/usr/bin/env dash
+
+# shellcheck source=/dev/null
+SHELL_LIBRARY_VERSION="2.0.13" . %SHELL_LIBRARY_PATH
+
+FAV_DIR="$XDG_MUSIC_DIR/playlists/favourites";
+
+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!";
+
+
+# vim: ft=sh
diff --git a/hm/soispha/pkgs/scripts/wrappers/sort_song b/hm/soispha/pkgs/scripts/wrappers/sort_song
new file mode 100755
index 00000000..f539cf15
--- /dev/null
+++ b/hm/soispha/pkgs/scripts/wrappers/sort_song
@@ -0,0 +1,33 @@
+#!/usr/bin/env dash
+
+# 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'";
+esac
+
+process() {
+    mediainfo --Output=JSON "$1" | jq '.media.track | map(.Lyrics) | join("")'
+};
+
+mkdir "../$directory";
+
+fd . --extension=opus | while read -r file; do
+    if [ "$(process "$file")" = '""' ] || [ "$(process "$file")" = '"Instrumental"' ] || [ "$(process "$file")" = '"instrumental"' ]; then
+        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
+
+# vim: ft=sh