Skip to content

Commit

Permalink
Better choose music scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
minijackson committed Apr 8, 2018
1 parent 5503f5d commit 9ed5a1f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 10 additions & 3 deletions home.nix
Original file line number Diff line number Diff line change
Expand Up @@ -582,12 +582,19 @@ in
src = ./scripts/choose_album.sh;
isExecutable = true;

mpc = pkgs.mpc_cli + /bin/mpc;
uniq = pkgs.coreutils + /bin/uniq;
rofi = pkgs.rofi + /bin/rofi;
inherit (pkgs) mpc_cli coreutils rofi;
};
in "exec --no-startup-id ${choose_album}";

"KP_Prior" = let
choose_artist = pkgs.substituteAll {
src = ./scripts/choose_artist.sh;
isExecutable = true;

inherit (pkgs) mpc_cli rofi;
};
in "exec --no-startup-id ${choose_artist}";

"XF86AudioPlay" = "exec --no-startup-id ${pkgs.mpc_cli}/bin/mpc toggle";
"XF86AudioNext" = "exec --no-startup-id ${pkgs.mpc_cli}/bin/mpc next";
"XF86AudioPrev" = "exec --no-startup-id ${pkgs.mpc_cli}/bin/mpc prev";
Expand Down
4 changes: 2 additions & 2 deletions scripts/choose_album.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ IFS=$'\n\t'

separator=""

result="$(@mpc@ --format="%albumartist% $separator %album%" listall | @uniq@ | @rofi@ -dmenu -fullscreen -columns 2 -i)"
result="$(@mpc_cli@/bin/mpc --format="%albumartist% $separator %album%" listall | @coreutils@/bin/uniq | @rofi@/bin/rofi -dmenu -fullscreen -columns 2 -i)"

IFS="$separator" read -ra artistalbum <<< "$result"

# Strip the whitespace
artist="${artistalbum[0]% }"
album="${artistalbum[1]# }"

@mpc@ findadd albumartist "$artist" album "$album"
@mpc_cli@/bin/mpc findadd albumartist "$artist" album "$album"
8 changes: 8 additions & 0 deletions scripts/choose_artist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -euo pipefail
IFS=$'\n\t'

artist="$(@mpc_cli@/bin/mpc list albumartist | @rofi@/bin/rofi -dmenu -fullscreen -columns 2 -i)"

@mpc_cli@/bin/mpc findadd albumartist "$artist"

0 comments on commit 9ed5a1f

Please sign in to comment.