diff options
author | Rasmus Steinke <rasi@xssn.at> | 2017-07-26 15:16:37 +0200 |
---|---|---|
committer | Rasmus Steinke <rasi@xssn.at> | 2017-07-26 15:16:37 +0200 |
commit | 3072639cbb079ce7e637b0af4aef8872bcb7d6a5 (patch) | |
tree | dfff7c8f6e966e7f9a41263b22a30c2a454d1b4b /clerk_fzf | |
parent | ded7273de7cd163ee3fa89f073c7550bc31d1cf3 (diff) | |
download | perl-app-clerk-3072639cbb079ce7e637b0af4aef8872bcb7d6a5.tar.gz perl-app-clerk-3072639cbb079ce7e637b0af4aef8872bcb7d6a5.tar.xz |
add playlist support
Diffstat (limited to 'clerk_fzf')
-rwxr-xr-x | clerk_fzf/clerk_fzf | 47 | ||||
-rw-r--r-- | clerk_fzf/tmux.clerk | 9 |
2 files changed, 52 insertions, 4 deletions
diff --git a/clerk_fzf/clerk_fzf b/clerk_fzf/clerk_fzf index 36ee08f..d97498c 100755 --- a/clerk_fzf/clerk_fzf +++ b/clerk_fzf/clerk_fzf @@ -228,6 +228,7 @@ fi tmux new-session -s music2 -n albums -d 'clerk_fzf --albums' tmux new-window -t music2 -n tracks 'clerk_fzf --tracks' tmux new-window -t music2 -n latest 'clerk_fzf --latest' +tmux new-window -t music2 -n playlists 'clerk_fzf --playlists' tmux new-window -t music2 -n queue 'ncmpcpp' tmux rename-session -t music music_old @@ -241,6 +242,49 @@ if [[ $1 == "--create-caches" ]]; then fi } +playlists () { + pls=( + "$(mpc lsplaylists)" + "---" + "Save current Queue as Playlist") + + + plsmenu="$(printf '%s\n' "${pls[@]}" | fzf --no-sort -m -e --reverse -i --ansi --bind "ctrl-a:select-all,ctrl-n:deselect-all")" + clear + echo "${plsmenu}" + val=$? + if [[ $val -eq 130 ]]; then + playlists + fi + if [[ $plsmenu == "Save current Queue as Playlist" ]]; then + mpc save "$(date +'%Y-%m-%d_%H:%M:%S').m3u" + tmux findw -t music queue + else + playlistactions + fi +} + +playlistactions () { + menu_content=( + "Load Playlist" + "Add Playlist" + "Cancel") + + plmenu="$(printf '%s\n' "${menu_content[@]}" | fzf --reverse -i --ansi)" + if [[ $val -eq 130 ]]; then + playlists + fi + if [[ $plmenu == "Load Playlist" ]]; then + mpc clear > /dev/null; mpc load "${plsmenu}" > /dev/null; mpc play > /dev/null + tmux findw -t music queue + elif [[ $plmenu == "Add Playlist" ]]; then + mpc load "${plsmenu}" > /dev/null + tmux findw -t music queue + elif [[ $plmenu == "Cancel" ]]; then + playlists + fi +} + clerk_help () { grep -A14 '^## Key Bindings' "${tmux_config}" | awk -F '-n ' '{ print $2 }' | \ sed 's/clerk_fzf --//g; s/run-shell//g; s/findw//g; s/\x27//g; s/--quiet//g; s/mpc //g; s/clerk_update --create-caches/create caches/; s/_/ /g; s/kill-session -t music/ kill session/g; s/ /\t/g' | \ @@ -308,6 +352,7 @@ main() { tmux -f "${tmux_config}" new-session -s music -n albums -d 'clerk_fzf --albums' tmux new-window -t music -n tracks 'clerk_fzf --tracks' tmux new-window -t music -n latest 'clerk_fzf --latest' + tmux new-window -t music -n playlists 'clerk_fzf --playlists' tmux new-window -t music -n queue 'ncmpcpp' fi tmux attach -t music @@ -345,4 +390,6 @@ elif [[ $1 == "--help" ]]; then clerk_help elif [[ $1 == "--caches" ]]; then updateCache +elif [[ $1 == "--playlists" ]]; then + playlists fi diff --git a/clerk_fzf/tmux.clerk b/clerk_fzf/tmux.clerk index d7c7bf7..980a65a 100644 --- a/clerk_fzf/tmux.clerk +++ b/clerk_fzf/tmux.clerk @@ -24,10 +24,11 @@ setw -g window-status-current-format ' #[fg=yellow,bold]#[bg=colour235]#W ' bind-key -n F1 findw albums bind-key -n F2 findw tracks bind-key -n F3 findw latest -bind-key -n F4 findw queue -bind-key -n F5 run-shell 'mpc prev --quiet' -bind-key -n F6 run-shell 'mpc toggle --quiet' -bind-key -n F7 run-shell 'mpc stop --quiet' +bind-key -n F4 findw playlists +bind-key -n F5 findw queue +bind-key -n F6 run-shell 'mpc prev --quiet' +bind-key -n F7 run-shell 'mpc toggle --quiet' +bind-key -n C-F7 run-shell 'mpc stop' bind-key -n F8 run-shell 'mpc next --quiet' bind-key -n C-F12 run-shell 'forceupdate="true" clerk_fzf --update' bind-key -n F12 run-shell 'clerk_fzf --update' |