config

My configuration files and custom scripts.
git clone https://git.tronto.net/config
Download | Log | Files | Refs

status-linux (1150B)


      1 #!/bin/sh
      2 
      3 # Prints some status info to stdout. Includes:
      4 #	- date and time
      5 #	- battery
      6 #	- wifi (requires nmcli)
      7 #	- past notifications (requires notify)
      8 
      9 # Usage: status [separator]
     10 
     11 sep=${1:-" | "}
     12 
     13 time=$(date +"%H:%M")
     14 date=$(date +"%a %d %b")
     15 
     16 if [ "$(pulsemixer --get-mute)" -eq 1 ]; then
     17 	volume="Muted"
     18 else
     19 	volume="Vol $(pulsemixer --get-volume | awk '{print $1}')%"
     20 fi
     21 
     22 bat="/sys/class/power_supply/BAT0"
     23 if [ -d $bat ]; then
     24 	charge_status="$(cat $bat/status | awk '{print substr ($0, 0, 2)}')"
     25 	battery="Bat $(cat $bat/capacity)% $charge_status"
     26 else
     27 	battery="No battery"
     28 fi
     29 
     30 # Thank you iwctl for saving us from this dreadful existence
     31 network="$(iwctl station wlan0 show | grep 'Connected network' | \
     32 	awk '{$1=$2=""; $0=$0; print}' | sed 's/^ .//')"
     33 if [ "$(cat /sys/class/net/eth1/carrier 2>/dev/null)" = 1 ]; then
     34 	if [ -z "$network" ]; then
     35 		network="eth"
     36 	else
     37 		network="eth & $network"
     38 	fi
     39 fi
     40 
     41 noticount=$(notify show | wc -l)
     42 
     43 printf '%s' "$network$sep$volume$sep$battery$sep$date$sep$time"
     44 [ "$noticount" = "1" ] && printf '%s' "$sep$(notify show)"
     45 [ "$noticount" -gt "1" ] && printf '%s' "${sep}[$noticount]"
     46 printf '\n'