From 9932f86276bff26b2b687c29784caef60477a317 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 9 Nov 2014 05:43:10 -0500 Subject: plugin/auditory.vim: Play sounds using absolute path Without this, the audio files wouldn't be able to play unless you were cd'ed into the script's root directory. We want them to play no matter where your pwd is. --- plugin/auditory.vim | 90 ++++++++++++++++++++++++++++------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) (limited to 'plugin') diff --git a/plugin/auditory.vim b/plugin/auditory.vim index dd9b636..641a506 100644 --- a/plugin/auditory.vim +++ b/plugin/auditory.vim @@ -1,3 +1,7 @@ +" Get the script path so we can resolve the audio file paths +let s:script_path = resolve(expand(':p:h')) . '/..' + + " Pid " === @@ -13,12 +17,12 @@ endfunction " Play audio function! auditory#Play(file) - call system("mplayer " . a:file . " &") + call system("mplayer " . s:script_path . a:file . " &") endfunction " Insert mode functions function! s:PlayInsertEnter() - call auditory#Play("./private/test-track.mp3") + call auditory#Play("/private/test-track.mp3") let s:insert_mode_pid = s:GetPid() endfunction @@ -45,7 +49,7 @@ function! s:PlayScale() let play_scale_previous_note = note - call auditory#Play('./Resources/Scale_C#/' . scale[note]) + call auditory#Play('/Resources/Scale_C#/' . scale[note]) endfunction @@ -86,7 +90,7 @@ function! s:GalaxyFarFarAway() \ 'Cantina_8.4.wav' \ ] - call auditory#Play('./Resources/Cantina/' . cantina[s:galaxy_far_far_away_index]) + call auditory#Play('/Resources/Cantina/' . cantina[s:galaxy_far_far_away_index]) let s:galaxy_far_far_away_index += 1 @@ -98,55 +102,55 @@ endfunction " Normal mode function! s:NormalModeMappings() - nnoremap h :call auditory#Play('./Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'h' - nnoremap j :call auditory#Play('./Resources/Normal_Mode/Down.wav') \| exec 'normal!' v:count1 . 'j' - nnoremap k :call auditory#Play('./Resources/Normal_Mode/Up.wav') \| exec 'normal!' v:count1 . 'k' - nnoremap l :call auditory#Play('./Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'l' + nnoremap h :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'h' + nnoremap j :call auditory#Play('/Resources/Normal_Mode/Down.wav') \| exec 'normal!' v:count1 . 'j' + nnoremap k :call auditory#Play('/Resources/Normal_Mode/Up.wav') \| exec 'normal!' v:count1 . 'k' + nnoremap l :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'l' - nnoremap gj :call auditory#Play('./Resources/Normal_Mode/Down.wav') \| exec 'normal!' v:count1 . 'gj' - nnoremap gk :call auditory#Play('./Resources/Normal_Mode/Up.wav') \| exec 'normal!' v:count1 . 'gk' + nnoremap gj :call auditory#Play('/Resources/Normal_Mode/Down.wav') \| exec 'normal!' v:count1 . 'gj' + nnoremap gk :call auditory#Play('/Resources/Normal_Mode/Up.wav') \| exec 'normal!' v:count1 . 'gk' - nnoremap 0 :call auditory#Play('./Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '0' - nnoremap ^ :call auditory#Play('./Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '^' - nnoremap _ :call auditory#Play('./Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '_' - nnoremap $ :call auditory#Play('./Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . '$' - nnoremap g_ :call auditory#Play('./Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'g_' - nnoremap % :call auditory#Play('./Resources/Normal_Mode/Jump.wav')% + nnoremap 0 :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '0' + nnoremap ^ :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '^' + nnoremap _ :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . '_' + nnoremap $ :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . '$' + nnoremap g_ :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'g_' + nnoremap % :call auditory#Play('/Resources/Normal_Mode/Jump.wav')% - nnoremap b :call auditory#Play('./Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'b' - nnoremap w :call auditory#Play('./Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'w' - nnoremap e :call auditory#Play('./Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'e' - nnoremap B :call auditory#Play('./Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'B' - nnoremap W :call auditory#Play('./Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'W' - nnoremap E :call auditory#Play('./Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'E' + nnoremap b :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'b' + nnoremap w :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'w' + nnoremap e :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'e' + nnoremap B :call auditory#Play('/Resources/Normal_Mode/Left.wav') \| exec 'normal!' v:count1 . 'B' + nnoremap W :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'W' + nnoremap E :call auditory#Play('/Resources/Normal_Mode/Right.wav') \| exec 'normal!' v:count1 . 'E' - nnoremap p :call auditory#Play('./Resources/Normal_Mode/Paste.wav') \| exec 'normal!' v:count1 . 'p' - nnoremap P :call auditory#Play('./Resources/Normal_Mode/Paste.wav') \| exec 'normal!' v:count1 . 'P' + nnoremap p :call auditory#Play('/Resources/Normal_Mode/Paste.wav') \| exec 'normal!' v:count1 . 'p' + nnoremap P :call auditory#Play('/Resources/Normal_Mode/Paste.wav') \| exec 'normal!' v:count1 . 'P' - nnoremap / :call auditory#Play('./Resources/Normal_Mode/Search.wav')/ - nnoremap n :call auditory#Play('./Resources/Normal_Mode/Search.wav')n - nnoremap N :call auditory#Play('./Resources/Normal_Mode/Search.wav')N - nnoremap # :call auditory#Play('./Resources/Normal_Mode/Search.wav')# - nnoremap * :call auditory#Play('./Resources/Normal_Mode/Search.wav')* + nnoremap / :call auditory#Play('/Resources/Normal_Mode/Search.wav')/ + nnoremap n :call auditory#Play('/Resources/Normal_Mode/Search.wav')n + nnoremap N :call auditory#Play('/Resources/Normal_Mode/Search.wav')N + nnoremap # :call auditory#Play('/Resources/Normal_Mode/Search.wav')# + nnoremap * :call auditory#Play('/Resources/Normal_Mode/Search.wav')* - nnoremap zt :call auditory#Play('./Resources/Normal_Mode/Jump.wav')zt - nnoremap z. :call auditory#Play('./Resources/Normal_Mode/Jump.wav')z. - nnoremap zz :call auditory#Play('./Resources/Normal_Mode/Jump.wav')zz - nnoremap zb :call auditory#Play('./Resources/Normal_Mode/Jump.wav')zb + nnoremap zt :call auditory#Play('/Resources/Normal_Mode/Jump.wav')zt + nnoremap z. :call auditory#Play('/Resources/Normal_Mode/Jump.wav')z. + nnoremap zz :call auditory#Play('/Resources/Normal_Mode/Jump.wav')zz + nnoremap zb :call auditory#Play('/Resources/Normal_Mode/Jump.wav')zb - nnoremap ( :call auditory#Play('./Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '(' - nnoremap ) :call auditory#Play('./Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . ')' - nnoremap { :call auditory#Play('./Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '{' - nnoremap } :call auditory#Play('./Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '}' + nnoremap ( :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '(' + nnoremap ) :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . ')' + nnoremap { :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '{' + nnoremap } :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '}' - nnoremap :call auditory#Play('./Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' - nnoremap :call auditory#Play('./Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' + nnoremap :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' + nnoremap :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . '' - nnoremap gg :call auditory#Play('./Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . 'gg' - nnoremap G :call auditory#Play('./Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count . 'G' + nnoremap gg :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count1 . 'gg' + nnoremap G :call auditory#Play('/Resources/Normal_Mode/Jump.wav') \| exec 'normal!' v:count . 'G' - nnoremap x :call auditory#Play('./Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . 'x' - vnoremap x :call auditory#Play('./Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . 'x' + nnoremap x :call auditory#Play('/Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . 'x' + vnoremap x :call auditory#Play('/Resources/Normal_Mode/Delete.wav') \| exec 'normal!' v:count1 . 'x' endfunction call s:NormalModeMappings() -- cgit v1.2.3