Show current Amarok song in status bar

For Amarok users this is a pretty cool addition. It places the currently playing song and remaining time in the status bar of Vim.

The function grabs the current track and time remaining from dcop (KDE's interprocess communication protocol). The last two lines add it to the status line and makes sure the status line is always showing.

Plainfun! CurrentTrackAndTime() let totaltime = system("dcop amarok player trackTotalTime") let totaltime = substitute( totaltime, "\n","","") let track = system("dcop amarok player nowPlaying") let track = substitute( track, "\n", "","") let time = system("dcop amarok player trackCurrentTime") let time = totaltime - time let minutes = time / 60 let seconds = time % 60 if minutes < 10 let minutes = "0" . minutes endif if seconds < 10 let seconds = "0" . seconds endif let status = track." -".minutes.":".seconds return status endfun set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P\ %1*%{CurrentTrackAndTime()}%* set laststatus=2
Add Comment