# sysutils/screen with battery status -- how to!



## meine (May 3, 2019)

I use sysutils/screen a lot, but on my netbook I also needed to keep track of the battery load. Here is my documentation:

screen has no buit-in trigger for battery status, and also doesn't seem to handle shell code very well in its .screenrc. Therefor you can use a small file that gives you the output you need and make screen read that.

To get the battery load, I installed sysutils/upower, that "listens to device events and querying history and statistics." With some found code you get the battery load percentage as output:


```
#!/bin/sh

upower -d | grep percentage | sed -n "1p" | sed -e 's/^.* //'
```

This sh-script is stored in my home directory. It is important to make the file executable!

Now in .screenrc you can call this script for use in the statusline:


```
# screenrc 20190503
# added percentage battery load through sh script

backtick 1 0 1 /home/meine/.bin/batt-status.sh

[screens to be opened at start]
altscreen on
term screen-256color

# change the hardstatus settings to give an window list at the bottom of the
# screen, with the time and date and with the current window highlighted                                                                         
hardstatus alwayslastline "<skipped code>  [%{Y} %1` %{g}]  <skipped code>"
```

The `backtick' line calls the script and uses `1' to refer to in the statusline code (hardstatus). The following `0' is for its lifespan and the trailing `1' is for the autorefresh interval. To trigger the backtick, the status line code should point to it with `%1`' (percentage-one-backtick).

To emphasis the battery load I gave it a yellow color. The screenshot (double meaning) is below, also giving the entire code for my status line.






I like to share my solution here, because IMHO the Forum is not just for asking, but also for telling you lot how things can be done.

TNX,


----------

