You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-19Lines changed: 29 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -2,36 +2,44 @@
2
2
3
3
`battstat` is a shell script that displays formatted information about the status of your battery.
4
4
5
-
Information is displayed in the order the format tokens are written. For example, the screenshots below show my __tmux__ status line running the command `battstat --percent-when-charged {i} {t} {p}`. This will display an icon, the time remaining when charging and discharging, and finally the percentage but only when the battery is fully charged. Format tokens can be written in any order and as many times as you like.

5
+

10
6
11
7
## Examples
12
8
13
9
There are a few ways to customize the output of `battstat`. Charging and discharging icons can be replaced with single character or multi-character strings. The `-c` flag sets the charging string and the `-d` flag sets the discharging string.
14
10
15
11
```
16
-
$ battstat -d "🍕" {t} {i}
17
-
10:30 🍕
12
+
~ % battstat -d "💀"
13
+
11:25 74% 💀
14
+
15
+
~ % battstat -d "😎" -f "{i} ({t})"
16
+
😎 (11:15)
18
17
19
-
$ battstat {t} {i}
20
-
11:47 🔋
18
+
~ % battstat -c "AC:" -d "BAT:" -f "{i} {p} {t}"
19
+
BAT: 74% 11:35
21
20
22
-
$ battstat -c "AC:" -d "BAT:" {i} {p} {t}
23
-
BAT: 82% 12:11
21
+
~ % battstat -d "Battery:" -f "{i} {p}"
22
+
Battery: 74%
23
+
```
24
24
25
-
$ battstat {i} {p}
26
-
🔋 81%
25
+
## Formatting
27
26
28
-
$ battstat -d "Battery:" {i} {p}
29
-
Battery: 81%
27
+
`battstat` uses printf style formatting when using the `-f` flag. This means you can print replacement tokens however you want.
28
+
29
+
```
30
+
~ % battstat -f "{i}\t{t}\t({p})"
31
+
🔋 11:55 (74%)
32
+
33
+
~ % battstat -f "{i}\nType whatever you want.\n{t}\n({p})"
Using [bitbar](https://github.com/matryer/bitbar) you can add the output of `battstat` to the menu bar on macOS. There are many ways to customize the output so I suggest reading over the [writing plugins](https://github.com/matryer/bitbar#writing-plugins) section to understand what's possible.
37
45
@@ -40,7 +48,7 @@ The screenshot above is using the following shell script. Make sure the script i
40
48
```
41
49
#!/bin/sh
42
50
43
-
time=$(/usr/local/bin/battstat {t})
51
+
time=$(/usr/local/bin/battstat -f {t})
44
52
45
53
echo "($time) | size=13"
46
54
```
@@ -79,12 +87,14 @@ options:
79
87
-h, --help display help information
80
88
-c, --charging-icon string to display in icon's place when battery is charging
81
89
-d, --discharging-icon string to display in icon's place when battery is discharging
90
+
-f, --format formatted output of battstat
82
91
--percent-when-charged only display percent when charged
83
92
84
-
format:
93
+
format replacement tokens:
85
94
{i} display icon
86
95
{t} display time remaining
87
96
{p} display percent
88
97
89
-
Note: There must be a space between each format token.
0 commit comments