Skip to content

Commit

Permalink
Merge pull request #16 from xu3s/new_branch
Browse files Browse the repository at this point in the history
fixing termux backend for charging status and termux backend checker
  • Loading branch information
lambdalisue authored Apr 5, 2021
2 parents f7a6ab0 + 4a1da7e commit 9e93f4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions autoload/battery.vim
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ function! s:get_available_backend() abort
return 'powershell'
elseif battery#backend#linux#is_available()
return 'linux'
elseif battery#backend#freebsd#is_available()
return 'freebsd'
elseif battery#backend#termux#is_available()
return 'termux'
elseif battery#backend#freebsd#is_available()
return 'freebsd'
endif
return 'dummy'
endfunction
Expand Down
7 changes: 4 additions & 3 deletions autoload/battery/backend/termux.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ function! s:on_stdout(buffer, data) abort
endfunction

function! s:on_exit(backend, buffer, exitval) abort
let content = join(a:buffer, '')
let a:backend.is_charging = json_decode(content).status !=# 'NOT_CHARGING'
let a:backend.value = json_decode(content).percentage + 0
let obj = json_decode(join(a:buffer, ''))
let status = get(obj, 'status', '')
let a:backend.is_charging = !(status ==# 'NOT_CHARGING' || status ==# 'DISCHARGING')
let a:backend.value = get(obj, 'percentage', 0) + 0
endfunction

function! battery#backend#termux#define() abort
Expand Down

0 comments on commit 9e93f4a

Please sign in to comment.