diff options
| author | Teddy Wing | 2014-11-08 18:02:45 -0500 |
|---|---|---|
| committer | Teddy Wing | 2014-11-08 18:02:45 -0500 |
| commit | da0b8849cd516a878ebd49de2eda0f3e85488f52 (patch) | |
| tree | 6bae1e57de90898bf4c1fd6eb466a5d7ea8938c3 /plugin | |
| parent | 6c8e3819821fbb18d3d7756bf9a64068a6a4f144 (diff) | |
| download | auditory.vim-da0b8849cd516a878ebd49de2eda0f3e85488f52.tar.bz2 | |
Get audio playing working with insert autocmds
* Move test .vim file into the plugin/ directory. Some of the functions
added in this commit should be moved to autoload/ when this is more
together
* Add functions:
* Get & kill pids for mplayer
* Play audio
* Insert autocmd handlers
* Add InsertEnter & InsertLeave autocmds that start playing the test
song when entering insert mode and stop playing when you leave insert
mode.
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/auditory.vim | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/plugin/auditory.vim b/plugin/auditory.vim new file mode 100644 index 0000000..6ca711e --- /dev/null +++ b/plugin/auditory.vim @@ -0,0 +1,42 @@ +" Pid +" === + +" Get most recent mplayer pid +function! s:GetPid() + return system("ps | grep mplayer | head -n1 | awk '{printf $1}'") +endfunction + +" Run system kill +function! s:KillPid(pid) + echom a:pid + return system("kill " . a:pid) +endfunction + +" Play audio +function! auditory#Play() + call system("mplayer ./private/test-track.mp3 &") +endfunction + +" Insert mode functions +function! s:PlayInsertEnter() + call auditory#Play() + let s:insert_mode_pid = s:GetPid() +endfunction + +function! s:PlayInsertLeave() + call s:KillPid(s:insert_mode_pid) +endfunction + + +nnoremap <silent> <leader>i :call auditory#Play()<cr> + +nnoremap <leader>x :echo call s:GetPid()<cr> + +augroup auditoryeinsert_mode + autocmd! + autocmd InsertEnter * call s:PlayInsertEnter() + autocmd InsertLeave * call s:PlayInsertLeave() +augroup END + + +nnoremap <leader>so :source %<cr> |
