Skip to content

Commit

Permalink
Update config settings
Browse files Browse the repository at this point in the history
  • Loading branch information
alyosha committed Sep 26, 2020
1 parent d84e04c commit d62f5f3
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,29 @@ MPRIS properly/at all so available functionality can vary. At some point I will
through and properly add debug messages where functionality is not supported, but
for now I've just tried to cover those places that throw errors when unavailable.

Throw an env like the following in your .zshrc/.bashrc to configure your preferred default player:
Rhythmbox is an example of a fully-implemented player, while a player like chromium
is still very limited in terms of supported functionality.

`export DEFAULT_VIMEDIA_PLAYER=chromium`
## Config
To configure a default media player, add a line like the following to your
vimrc dotfile:

`let g:vimedia_default_player = "rhythmbox"`

If you're unsure of the name to set here, try opening the media player and running `:SelectPlayer`
from within Vim to get a list of options (remember the players need to be running/active to detect).

By default the statusline is enabled and will show playback metadata when
available, but you can disable the statusline in the following way:

`let g:vimedia_statusline_enabled = 0`

## Coming soon
- Seek forward/backwards
- Restart
- Hard previous (instead of just restarting when playback is past a certain point)
- Make status bar optional

Suggestions/contributions welcome.

## Installation
Using your preferred plugin manager or if all else fails:

`git clone https://github.com/alyosha/vimedia ~/.vim/bundle/vimedia`
`git clone https://github.com/alyosha/vimedia ~/.vim/bundle/vimedia`
17 changes: 15 additions & 2 deletions plugin/vimedia.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ endif

set timeout timeoutlen=1000 ttimeoutlen=0

if !exists('g:vimedia_statusline_enabled')
let g:vimedia_statusline_enabled = 1
endif

let s:plugin_root_dir = fnamemodify(resolve(expand('<sfile>:p:h')), ':h')

" *************************************************************************** "
Expand Down Expand Up @@ -181,6 +185,10 @@ fu! PlaybackTicker()
endfu

fu! s:UpdateStatusline(timer)
if g:vimedia_statusline_enabled == 0
return
endif

if s:selected_player == "N/A" || s:current_artist_name == "N/A" || s:current_track_name == "N/A"
return
endif
Expand All @@ -201,7 +209,12 @@ let timer = timer_start(1000, function('s:UpdateStatusline'), {'repeat':-1})
" *************************************************************************** "

fu! s:init_player_config()
let s:selected_player_abbrev = $DEFAULT_VIMEDIA_PLAYER
let s:selected_player_abbrev = ""

if exists('g:vimedia_default_player')
let s:selected_player_abbrev = g:vimedia_default_player
endif

let s:selected_player = "N/A"

call job_start(s:GetActivePlayersCmd(), {"out_cb": function("s:SetPlayerCallback")})
Expand Down Expand Up @@ -350,4 +363,4 @@ com! -nargs=0 Unmute call s:Unmute()
com! -nargs=0 SelectPlayer call job_start(s:GetActivePlayersCmd(), {"out_cb": function("s:SelectPlayerCallback")})
com! -nargs=0 ActivePlayer call s:ActivePlayer()

let g:vimedia_plugin_loaded = 1
let g:vimedia_plugin_loaded = 1

0 comments on commit d62f5f3

Please sign in to comment.