|
- #!/bin/sh
-
- font=;
-
- clock() {
- date '+%H:%M %d-%m-%y'
- }
-
- # get the battery capacity and status
- battery() {
- BATC=/sys/class/power_supply/BAT0/capacity
- BATS=/sys/class/power_supply/BAT0/status
-
- # prepend percentage with a '+' if charging, '-' otherwise
- test "`cat $BATS`" = "Charging" && echo -n '+' || echo -n '-'
- echo $BATC
- }
-
- volume() {
- # get master volume level from amixer
-
- # parse amixer output to get ONLY the level. Will output "84%"
- # we need `uniq` because on some hardware, The master is listed twice in
- # "Front Left" and Front Right" (because laptop speakers I guess)
- amixer get Master | sed -n 's/^.*\[\([0-9]\+\)%.*$/\1/p'| uniq
- }
-
- network() {
- infs=$(ip link | sed -n 's/^[0-9]: \(.*\):.*$/\1/p')
- lo=$(echo $infs | awk '{print $1}')
- int1=$(echo $infs | awk '{print $2}')
- int2=$(echo $infs | awk '{print $3}')
-
- #iwconfig returns an error code if the interface tested has no wireless extensions
- if iwconfig $int1 >/dev/null 2>&1; then
- wifi=$int1
- eth0=$int2
- else
- wifi=$int2
- eth0=$int1
- fi
-
- ip link show $eth0 | grep 'state UP' >/dev/null && int=$eth0 || int=$wifi
- printf $int
- ping -c1 -s1 8.8.8.8 >/dev/null 2>&1 && echo "connected" || echo "disconnected"
-
- }
-
- # get cpu load (TODO- get this using iostat)
-
-
- # get ram usage
- memused() {
- # store the total and free memory in two variables
- t=$(grep -E 'MemTotal' /proc/meminfo |awk '{print $2}')
- f=$(grep -E 'MemFree' /proc/meminfo |awk '{print $2}')
- b=$(grep -E '^(Buffers)' /proc/meminfo |awk '{print $2}')
- c=$(grep -E '^(Cached)' /proc/meminfo |awk '{print $2}')
-
- # then, calcultate the percentage of memory used
- bc | "100($t -$f -$c -$b) / $t"
- }
|