forked from lambdalisue/vim-battery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbattery.txt
204 lines (166 loc) · 6.12 KB
/
battery.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
*battery.txt* A statusline/tabline component of Battery information
Version: 0.2.0
Author: Alisue <lambdalisue@hashnote.net>
Support: Neovim 0.1.6 or above
Support: Vim 8.0 or above
License: MIT license
=============================================================================
CONTENTS *battery-contents*
Introduction |battery-introduction|
Usage |battery-usage|
Interface |battery-interface|
Functions |battery-functions|
Variables |battery-variables|
=============================================================================
INTRODUCTION *battery-introduction*
*battery.vim* is a |statusline| or |tabline| component for Neovim/Vim.
It uses a job feature of Neovim/Vim to retrieve battery informations so that
the plugin won't block the main thread.
The implementation was translated to Vim script from a Bash script found on
https://github.com/b4b4r07/dotfiles/blob/master/bin/battery.
=============================================================================
USAGE *battery-usage*
Use |battery#component()| like:
>
set statusline=...%{battery#component()}...
set tabline=...%{battery#component()}...
<
Or with itchyny/lightline.vim
>
let g:lightline = {
\ ...
\ 'component_function': {
\ ...
\ 'battery': 'battery#component',
\ ...
\ },
\ ...
\}
<
Additionally, assign 1 to corresponding variables to immediately reflect the
changes to |statusline| or |tabline|.
>
let g:battery#update_tabline = 1 " For tabline.
let g:battery#update_statusline = 1 " For statusline.
<
=============================================================================
INTERFACE *battery-interface*
-----------------------------------------------------------------------------
FUNCTIONS *battery-functions*
*battery#backend()*
battery#backend()
Return a battery backend specified by |g:battery#backend|.
*battery#update()*
battery#update()
Call external program if no update process is executed and update the
internal information.
It is automatically called every |g:battery#update_interval|
milliseconds when |battery#watch()| has called.
*battery#value()*
battery#value()
Return a current battery percentage.
Note that the value is a cached value from |battery#update()|.
*battery#is_charging()*
battery#is_charging()
Return 1 if an AC power is plugged. Otherwise 0.
Note that the value is a cached value from |battery#update()|.
*battery#sign()*
battery#sign()
Return a unicode sign indicating if an AC power is plugged.
Note that the sign is built from a cached value from |battery#update()|.
See also |g:battery#symbol_charging| or |g:battery#symbol_discharging|.
Sttus Sign~
Discharging |g:battery#symbol_charging|
Charging |g:battery#symbol_discharging|
*battery#graph()*
battery#graph()
Return a battery indicator bar looks like ██░░░.
Return a unicode graph indicating the value which looks like "██░░░".
Note that the graph is built from a cached value from |battery#update()|.
See also |g:battery#graph_symbol_fill|, |g:battery#graph_symbol_null|
or |g:battery#graph_width|.
Value Graph (Default)~
0 ░░░░░
20 █░░░░
40 ██░░░
60 ███░░
80 ████░
100 █████
*battery#watch()*
battery#watch()
Start a timer to call |battery#update()| if there is no timer.
Users can control the interval by |g:battery#update_interval|.
Note that this function is automatically called on startup when
|g:battery_watch_on_startup| is specified.
*battery#unwatch()*
battery#unwatch()
Stop an existing timer. Do nothing if there is no timer.
*battery#component()*
battery#component()
Return a battery component for |statusline| or |tabline| which looks
like "♥ 40% ██░░░".
Users can customize the format by |g:battery#component_format|.
-----------------------------------------------------------------------------
VARIABLES *battery-variables*
*g:battery_watch_on_startup*
g:battery_watch_on_startup
1 to automatically call |battery#watch()| on startup.
Default is 1
*g:battery#backend*
g:battery#backend
A backend used to retrieve the battery information.
It is automatically determined if user has not explicitly specified.
Currently the following backends are available.
Name Description~
dummy A dummy backend which does nothing
pmset For Mac OS X
ioreg For Mac OS X
linux For Linux
powershell For Windows
*g:battery#update_interval*
g:battery#update_interval
A millisecond interval used to update the battery information when
|battery#watch| has called.
Use smaller value when you prefer to reflect the current status
immediately.
Default is 30000.
*g:battery#update_tabline*
g:battery#update_tabline
1 to update |tabline| when the battery information has retrieved.
It is required to immediately update your tabline whenever the battery
information has retrieved.
Users should not enable this option unless the |battery#component()| is
used in |tabline|.
Default is 0.
*g:battery#update_statusline*
g:battery#update_statusline
1 to update |statusline| when the battery information has retrieved.
It is required to immediately update your tabline whenever the battery
information has retrieved.
Users should not enable this option unless the |battery#component()| is
used in |statusline|.
Default is 0.
*g:battery#component_format*
g:battery#component_format
A string format used in |battery#component()|.
Character Represent~
%v A value of the battery
%s A sign indicating if an AC power is plugged
%g A graph
%x x
%% %
Default is "%s %v%% %g"
*g:battery#graph_symbol_fill*
g:battery#graph_symbol_fill
A character used to indicate a fill reagion in |battery#graph()|.
Default is "█"
*g:battery#graph_symbol_null*
g:battery#graph_symbol_null
A character used to indicate a null reagion in |battery#graph()|.
Default is "░"
*g:battery#graph_width*
g:battery#graph_width
The number of characters used in |battery#graph()|.
Default is 5
=============================================================================
vim:tw=78:fo=tcq2mM:ts=8:ft=help:norl