add display status

This commit is contained in:
Morgan McMillian 2021-04-07 14:55:55 -07:00
parent 4d08c12db7
commit b3aaf792a5

View file

@ -2,10 +2,10 @@
#DATE=$(while date +'%Y-%m-%d %l:%M:%S %p'; do sleep 1; done)
DATE=$(date +'%Y-%m-%d %k:%M')
BATTERY=$(upower --enumerate|grep battery)
POWER="| $(upower -i $BATTERY|grep percentage|awk '{print $2}')"
BSTATE=$(upower -i $BATTERY|grep state|awk '{print $2}')
# fully-charged 🔌
# charging ⚡
# discharging 🔋
@ -24,6 +24,34 @@ case "$BSTATE" in
;;
esac
SSHDSTATUS=$(systemctl is-active ssh)
if [[ $SSHDSTATUS == "active" ]];
then
SSHWARN="⚠️ |"
else
SSHWARN=""
fi
source $HOME/.config/sway/displays.sh
# swaymsg -t get_outputs
# LAPTOP="eDP-1"
# EXTERNAL="HDMI-A-1"
LAPSTAT=$(swaymsg -t get_outputs -r|jq --arg DISP "$LAPTOP" '.[] | select(.name==$DISP) | .active')
if [[ $LAPSTAT == "true" ]];
then
L=" 💻"
else
L=""
fi
EXTSTAT=$(swaymsg -t get_outputs -r|jq --arg DISP "$EXTERNAL" '.[] | select(.name==$DISP) | .active')
if [[ $EXTSTAT == "true" ]];
then
E=" 🖥️"
else
E=""
fi
DISPSTAT="$E$L"
# weather (https://github.com/chubin/wttr.in)
# add %l for location
WCACHE=~/.cache/thrrgilag/wttr
@ -58,4 +86,4 @@ then
MTEXT=""
fi
echo "$MTEXT $WEATHER $POWER $STATE $DATE |"
echo "$MTEXT $WEATHER $DISPSTAT $POWER $STATE $DATE | $SSHWARN"