Skip to content

Instantly share code, notes, and snippets.

@omar2205
Last active December 27, 2020 08:48
Show Gist options
  • Save omar2205/c98c5467a3b6fc561dad7c07f120a0cf to your computer and use it in GitHub Desktop.
Save omar2205/c98c5467a3b6fc561dad7c07f120a0cf to your computer and use it in GitHub Desktop.
gnu screen w/ battery
# Turn off that annoying start up message
startup_message off
# Turn the even more annoying whole-screen-flash-on-tab-complete "feature"
vbell off
# Window list at the bottom. hostname, centered tabs and redmarked active windows:
#shelltitle '$ |'
backtick 1 1 1 $HOME/bin/battery
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%1`%{g}][%{B} %m-%d %{W}%c %{g}]'
defscrollback 50000
mousetrack on
# 256 colors
attrcolor b ".I"
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'
defbce on

Add battery info to gnu screen status

image

#!/usr/bin/bash
# battery status (wsl)
b='/sys/class/power_supply/BAT1/capacity'
blif=$( awk '{ power=$1; \
if (power < 20) { color="\005{..r}"; } \
else if (power < 60) { color="\005{..y}"; } \
else { color="\005{..g}";} \
printf "%s%d\n",color,power; exit}' $b)
# check charging
st=$(cat /sys/class/power_supply/BAT1/status)
if [[ $st = "Charging" ]]
then
c="⚡"
else
c="🔋"
fi
echo "$c$blif%"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment