Skip to content

Instantly share code, notes, and snippets.

@rufo
Created June 2, 2017 20:07
Show Gist options
  • Save rufo/33e23e64028274b70ee594cfdd7827fc to your computer and use it in GitHub Desktop.
Save rufo/33e23e64028274b70ee594cfdd7827fc to your computer and use it in GitHub Desktop.
Change vim settings settings based on power status
" requires vim 8 for timer support
function! UpdatePowerSaving(timerId)
if executable('pmset')
call system("pmset -g batt | head -1 | grep 'Battery'")
if !v:shell_error
" on battery
let g:ale_lint_delay=10000
else
" power adapter
let g:ale_lint_delay=200
endif
endif
endfunction
call UpdatePowerSaving(0)
let powerTimer=timer_start(10000, "UpdatePowerSaving")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment