-
Notifications
You must be signed in to change notification settings - Fork 0
/
.dwm
executable file
·59 lines (50 loc) · 1.52 KB
/
.dwm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash
# script made for dwm status bar
WLAN_NAME=wlp0s20f3
ETH_NAME=enp0s31f6
BATPATH=/sys/class/power_supply/BAT0
#override above global variables
if [ -e .dwm.local ]; then
source .dwm.local
fi
function batteryStatus() {
batpath=$BATPATH
discharging=$(grep -qi "discharging" $batpath/status && echo "" || echo "chrg.")
bat_capacity=$batpath/capacity
charge="$(cat $bat_capacity)"
echo "BAT:$charge%$discharging"
}
function getDate(){
date '+%a %D %T'
}
function diskUsage(){
df -hT | grep -v tmpfs|grep -v efivars|grep -v boot|grep /| awk '{printf(" %s %s(%s)", $7,$5,$6)}'
}
function getEthStatus() {
up="$(cat /sys/class/net/$ETH_NAME/operstate)"
if [ "$up" = "down" ]; then
echo 'eth0:'
else
echo "eth0:$(ip address show dev $ETH_NAME | grep -P '\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\/\d' | awk '{printf("%s",$2)}')"
fi
}
function getWiFi(){
up="$(cat /sys/class/net/$WLAN_NAME/operstate)"
connected="$(nmcli c | grep $WLAN_NAME | wc -l)"
if [ "$up" = "down" ]; then
echo "wlan0:"
else
connected="$(nmcli c |grep "$WLAN_NAME" |awk '{printf("%s",$1)}')"
signal="$(iw dev $WLAN_NAME link | grep signal | awk '{$abs=$2*-1; printf("%s",$abs)}')"
echo "wlan0:$connected sig:$signal"
fi
}
while :; do
DISKUSAGE=$(diskUsage)
DATETIME=$(getDate)
BATTERY=$(batteryStatus)
ETH0=$(getEthStatus)
WIFI=$(getWiFi)
xsetroot -name "${WIFI} | ${ETH0} | ${BATTERY} | ${DISKUSAGE} | ${DATETIME}"
sleep 1
done