https://wiki.vifm.info/api.php?action=feedcontributions&user=2600%3A1700%3AB4F0%3A8D20%3A0%3A0%3A0%3A2E&feedformat=atom
Vifm Wiki - User contributions [en]
2024-03-28T10:52:36Z
User contributions
MediaWiki 1.35.1
https://wiki.vifm.info/index.php?title=How_to_use_Vifm_as_your_music_player&diff=2557
How to use Vifm as your music player
2021-05-22T16:09:22Z
<p>2600:1700:B4F0:8D20:0:0:0:2E: </p>
<hr />
<div>If you have [https://github.com/MusicPlayerDaemon/mpc mpc] then with some scripting you can use Vifm as your music player!<br />
Simply copy and paste this into your vifmrc:<br />
<br />
{{NOTE|text=You need [https://github.com/junegunn/fzf fzf] for this}}<br />
{{NOTE|text=You should also have the most recent version of mpc compiled from github.}}<br />
<br />
You '''can''' use older versions of mpc and still get 99% of the functionality, but certain mappings will have to be adjusted for displaying the current status.<br />
Make you that you set the shell variables at the beginning here to their appropriate locations on the harddrive.<br />
<br />
<source lang="vim"><br />
" {{{1 MUSIC PLAYER<br />
let $SONG_FORMAT="[[%artist% - ]%title%]|[%file%]"<br />
let $MUSIC_DIR=expand("$HOME/music")<br />
let $PLAY_LIST=expand("$HOME/music/play_list")<br />
" {{{2 MAPPINGS<br />
nnoremap L :!mpc seek +5%% %i<cr>:mpcStat 2<cr><br />
nnoremap B :!mpc seek -5%% %i<cr>:mpcStat 2<cr><br />
nnoremap l :!mpc seek +5 %i<cr>:mpcStat 2<cr><br />
nnoremap b :!mpc seek -5 %i<cr>:mpcStat 2<cr><br />
nnoremap rmp :!mpc toggle %i<cr>:mpcStat 2<cr><br />
nnoremap rmw :ShowSong<cr><br />
nnoremap rmg :GotoSong<cr><br />
nnoremap rmt :mpcStat 2<cr><br />
nnoremap rm3 :echo system('mpc status "vol:%volume% rep %repeat% rand %random% single %single%"')<cr><br />
nnoremap rm0 :let $IGNORE = system('mpd_restart')<cr>:echo 'Music player daemon has been restarted'<cr><br />
nnoremap rmi :mpcinsert<cr>:!echo Song %f:t inserted. %S<cr><br />
nnoremap rma :mpcadd<cr>:!echo Song %f:t added. %S<cr><br />
nnoremap rmm :!echo "%f" | sed -e 's/\([^\]\) /\1\n/g' -e 's/\\//g' | xargs -d '\n' -L 1 realpath --relative-to=$MUSIC_DIR %M | sort -nr | xargs -d '\n' -L 1 mpc insert<cr>:mpcplay<cr>:ShowSong<cr><br />
nnoremap rmd :Delfind<cr><br />
nnoremap rmf :goto $MUSIC_DIR<cr>i:FZFfind<cr><br />
nnoremap rms :Playfind<cr><br />
nnoremap rmc :!mpc crop %i<cr>:echo 'Playlist cropped'<cr><br />
nnoremap rme :!mpc clear %i<cr>:echo 'Playlist cleared'<cr><br />
nnoremap rmn :let $IGNORE = system('mpc next')<cr>:ShowSong<cr><br />
nnoremap rmv :let $IGNORE = system('mpc prev')<cr>:ShowSong<cr><br />
nnoremap rmr :let $IGNORE = system('mpc seek 0%')<cr>:let $IGNORE = system('mpc play')<cr>:mpcStat 1<cr><br />
nnoremap rmR :let $IGNORE = system('mpc stop')<cr>:!mpc play 1 %i<cr><br />
nnoremap rmx :let $IGNORE = system('mpc random')<cr>:echo system('mpc status "Random is %random%"')<cr><br />
nnoremap rml :let $IGNORE = system('mpc repeat')<cr>:echo system('mpc status "Repeat is %repeat%"')<cr><br />
nnoremap rmS :let $IGNORE = system('mpc single')<cr>:echo system('mpc status "Single is %single%"')<cr><br />
nnoremap rmh :!mpc shuffle %i<cr>:echo 'Playlist shuffled'<cr><br />
nnoremap rmL :PlayListfind<cr>:!sleep 0.2 %i<cr>:Playfind<cr><br />
nnoremap + :!mpc volume +5 %i<cr>:echo system('mpc status "Volume is:%volume%"')<cr><br />
nnoremap - :!mpc volume -5 %i<cr>:echo system('mpc status "Volume is:%volume%"')<cr><br />
" }}}2<br />
" {{{2 COMMANDS<br />
command! Playfind :exe '!mpc play "'.system('mpc playlist | nl | grep -Fv "$(mpc | sed -ne "1p" --)" | fzf --height 40 --with-nth 2.. 2>/dev/tty | cut -f 1 | tr -d " "').'" &>/dev/null %IU' | redraw<br />
command! PlayListfind :exe '!mpc load "'.system('mpc lsplaylist | fzf --height 40 2>/dev/tty').'"' | redraw<br />
command Delfind :exe '!mpc del "'.system('mpc playlist | nl | fzf --height 40 --with-nth 2.. 2>/dev/tty | cut -f 1 | tr -d " "').'" & &>/dev/null %IU' | redraw<br />
command ShowSong mpc -f "$SONG_FORMAT" current %S<br />
command GotoSong :exe 'goto "$MUSIC_DIR/'.system('mpc -f "%%file%%" | sed -ne "1p" --').'"'<br />
command mpcadd :let $IGNORE = system(expand('mpc search filename "$(realpath --relative-to=$MUSIC_DIR %%f)" | mpc add'))<br />
command pls mpc save %a | echo "Playlist saved." %i<br />
command pll mpc load %a %i<br />
command mpcStat :echo system('mpc | sed -ne '.%a.'p --')<br />
command mpcls mpc playlist | sed -e "s%%$(mpc | sed -ne '1p')%%& *%%" -- %M<br />
" Unfortunitly vifm doesn't have the capability to give a user command the functionality of<br />
" something like :rename<br />
" command mpcEdit !mpc playlist | $EDITOR - /tmp/tmp.m3u<br />
command mpcplay :if system('mpc | sed -ne 2p -- | cut -d " " -f 1') == '' | execute '!mpc toggle &' | else | execute '!mpc next &' | endif<br />
" }}}2<br />
" }}}1<br />
</source><br />
<br />
Here's a video showcasing almost all the features [https://youtu.be/6JNZKT7VgIg]:</div>
2600:1700:B4F0:8D20:0:0:0:2E