summaryrefslogtreecommitdiffstats
path: root/awesome_bar.sh
blob: e2b2a62a9c4408b1062eef478379f67a55f67e7e (plain)
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
#!/bin/zsh

SCREEN=0

func_power() {
	if [ -e /proc/acpi/battery/BAT0/info ]; then
		CAP=$(grep full /proc/acpi/battery/BAT0/info | awk '{print $4}')
		REM=$(grep remaining /proc/acpi/battery/BAT0/state | awk '{print $3}')
		CHARGING=$(grep "charging state" /proc/acpi/battery/BAT0/state | awk '{print $3}')
		STATE=$(($REM * 100 / $CAP))"%"

		if [ "$CHARGING" = "charged" ]; then
			echo $SCREEN widget_tell topbar power_logo image /home/xeno/etc/icons/tango/actions/go-next.png | awesome-client
		elif [ "$CHARGING" = "discharging" ]; then
			echo $SCREEN widget_tell topbar power_logo image /home/xeno/etc/icons/tango/actions/go-down.png | awesome-client
		elif [ "$CHARGING" = "charging" ]; then
			echo $SCREEN widget_tell topbar power_logo image /home/xeno/etc/icons/tango/actions/go-up.png | awesome-client
		fi

		echo $STATE
	else
		echo "No Battery"
	fi
}

func_mem() {
        TOT=$(free -m | grep Mem | awk '{print $2}')
        USE=$(free -m | grep buffers/cache | awk '{print $3}')
        MEM=$(($USE * 100 / $TOT))
        echo $MEM
}

while true; do
		echo $SCREEN widget_tell topbar power text " `func_power` " | awesome-client
		echo $SCREEN widget_tell topbar mem data mem_state " `func_mem` " | awesome-client
		echo $SCREEN widget_tell topbar hdd data hdd_root `df / | tail -n 1 | awk '{print $4+100-100}'` | awesome-client
		echo $SCREEN widget_tell topbar hdd data hdd_home `df /home | tail -n 1 | awk '{print $4+100-100}'` | awesome-client
		echo $SCREEN widget_tell topbar wlan text " `/sbin/ifconfig | grep -A 1 wlan0 | tail -n 1 | awk '{print $2}' | sed 's/Adresse://g'` " | awesome-client
		echo $SCREEN widget_tell topbar clock text " `date +"%x %T"` " | awesome-client
		echo $SCREEN widget_tell topbar hostname text " `hostname` " | awesome-client

		sleep 1
done

# vim: set tw=0 ts=4: