#!/bin/sh BAT0_NOW=$(cat /sys/class/power_supply/BAT0/energy_now) BAT0_FULL=$(cat /sys/class/power_supply/BAT0/energy_full) BAT1_NOW=$(cat /sys/class/power_supply/BAT1/energy_now) BAT1_FULL=$(cat /sys/class/power_supply/BAT1/energy_full) AC_ONLINE=$(cat /sys/class/power_supply/AC/online) NOW=$(echo "$BAT0_NOW+$BAT1_NOW" | bc) FULL=$(echo "$BAT0_FULL+$BAT1_FULL" | bc) PERCENT=$(echo "($NOW*100)/$FULL" | bc) DATE=$(date "+%Y-%m-%d %H:%M") ping -q -c 1 -W 1 10.13.37.1 >/dev/null 2>&1 VPN=$? if [ ${VPN} -eq 0 ] ; then VPNINFO="" else VPNINFO="" fi SPACEINFO=$(curl -s "http://status.mainframe.io/api/spaceInfo" | jq -r '.state.message') WLANPWR=$(/usr/sbin/rfkill --json | /usr/bin/jq -r '.""[] | select(.type == "wlan") | select(.device == "phy0") .soft') WLANSSID=$(/sbin/iw dev wlan0 info | grep ssid | cut -d ' ' -f "2-") WLANFREQ=$(/sbin/iw dev wlan0 info | grep channel | cut -d ' ' -f 3 | sed "s/(//g") if [ "${WLANPWR}" = "unblocked" ] ; then if [ "${WLANSSID}" = "" ] ; then WLANINFO="" else WLANINFO="${WLANSSID} (${WLANFREQ} MHz)" fi else WLANINFO="" fi BTPWR=$(/usr/sbin/rfkill --json | /usr/bin/jq -r '.""[] | select(.type == "bluetooth") | select(.device == "hci0") .soft') if [ "${BTPWR}" = "unblocked" ] ; then BTINFO="" else BTINFO="" fi if [ $PERCENT -lt 10 ] ; then BATSTYLE="bgcolor='#ff0000' color='#000000' weight='bold'" elif [ $PERCENT -lt 20 ] ; then BATSTYLE="bgcolor='#f0f000' color='#000000' weight='bold'" fi if [ $AC_ONLINE -eq 1 ] ; then BATICON="AC" else BATICON="BAT" fi echo "Space: ${SPACEINFO} | VPN: ${VPNINFO} | WLAN ${WLANINFO} | BT ${BTINFO} | ${BATICON} ${PERCENT}% | ${DATE}"