aboutsummaryrefslogtreecommitdiffstats
path: root/hm/soispha/pkgs
diff options
context:
space:
mode:
authorSoispha <soispha@vhack.eu>2024-02-07 20:54:29 +0100
committerSoispha <soispha@vhack.eu>2024-02-07 21:02:24 +0100
commit04e4fe4fe6329a279c220496d2c78ba5a9bc186d (patch)
treec81389a2a57815641f4a02cba669a496f37d5bf8 /hm/soispha/pkgs
parentrefactor(hm/pkgs/scrs): Sort the declarations alphabetical (diff)
downloadnixos-config-04e4fe4fe6329a279c220496d2c78ba5a9bc186d.zip
feat(hm/pkgs/scrs): Add `mpc-fav` and `sort_song`
Diffstat (limited to 'hm/soispha/pkgs')
-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