refractoring
This commit is contained in:
parent
8c8203927c
commit
05bc0370b0
7
config
7
config
@ -10,6 +10,9 @@ label=☼
|
|||||||
# label=☀,☼,✱,✲,✳,✴,✵,✺
|
# label=☀,☼,✱,✲,✳,✴,✵,✺
|
||||||
instance=color
|
instance=color
|
||||||
|
|
||||||
|
# [iface]
|
||||||
|
# label=iface
|
||||||
|
|
||||||
[storage]
|
[storage]
|
||||||
label=⛁
|
label=⛁
|
||||||
# label=⛀,⛁,⛂,⛃
|
# label=⛀,⛁,⛂,⛃
|
||||||
@ -25,9 +28,9 @@ label=⚟
|
|||||||
[cpu]
|
[cpu]
|
||||||
label=☷
|
label=☷
|
||||||
|
|
||||||
# [ip]
|
[ip]
|
||||||
# label=ip
|
# label=ip
|
||||||
# label=⎋
|
label=⎋
|
||||||
# interval=once
|
# interval=once
|
||||||
|
|
||||||
# if you have more than one batteries attached to your device and ou like
|
# if you have more than one batteries attached to your device and ou like
|
||||||
|
@ -10,7 +10,7 @@ else
|
|||||||
[[ -f "$DIR/BAT$BLOCK_INSTANCE/uevent" ]] && BATS="$DIR/BAT$BLOCK_INSTANCE/uevent"
|
[[ -f "$DIR/BAT$BLOCK_INSTANCE/uevent" ]] && BATS="$DIR/BAT$BLOCK_INSTANCE/uevent"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "${BATS}" == "" ]]; then
|
if [[ "$BATS" == "" ]]; then
|
||||||
echo " no battery "
|
echo " no battery "
|
||||||
echo "n/a"
|
echo "n/a"
|
||||||
exit 33
|
exit 33
|
||||||
|
38
modules/iface
Executable file
38
modules/iface
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Use the provided interface, otherwise the device used for the default route.
|
||||||
|
if [[ -n $BLOCK_INSTANCE ]]; then
|
||||||
|
IF=$BLOCK_INSTANCE
|
||||||
|
else
|
||||||
|
IF=$(ip route | awk '/^default/ { print $5 ; exit }')
|
||||||
|
fi
|
||||||
|
|
||||||
|
# As per #36 -- It is transparent: e.g. if the machine has no battery or wireless
|
||||||
|
# connection (think desktop), the corresponding block should not be displayed.
|
||||||
|
[[ ! -d /sys/class/net/${IF} ]] && exit
|
||||||
|
|
||||||
|
if [[ "$(cat /sys/class/net/$IF/operstate)" = 'down' ]]; then
|
||||||
|
echo down # full text
|
||||||
|
echo down # short text
|
||||||
|
echo \#FF0000 # color
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
-4)
|
||||||
|
AF=inet ;;
|
||||||
|
-6)
|
||||||
|
AF=inet6 ;;
|
||||||
|
*)
|
||||||
|
AF=inet6? ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
# if no interface is found, use the first device with a global scope
|
||||||
|
IPADDR=$(ip addr show $IF | perl -n -e "/$AF ([^\/]+).* scope global/ && print \$1 and exit")
|
||||||
|
|
||||||
|
case $BLOCK_BUTTON in
|
||||||
|
3) echo -n "$IPADDR" | xclip -q -se c ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "$IPADDR" # full text
|
||||||
|
echo "$IPADDR" # short text
|
18
modules/ip
18
modules/ip
@ -1,6 +1,22 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
|
if [[ -n "$BLOCK_INSTANCE" ]]; then
|
||||||
|
IF="$BLOCK_INSTANCE"
|
||||||
|
else
|
||||||
|
IF=$(ip route | awk '/^default/ { print $5 ; exit }')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d "/sys/class/net/$IF" ]]; then
|
||||||
|
echo " no network interface "
|
||||||
|
echo "not found"
|
||||||
|
echo ""
|
||||||
|
exit 33
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo $IF
|
||||||
|
|
||||||
|
WAN_IP=$(curl -s checkip.dyndns.org | sed -e 's/.*Current IP Address: //' -e 's/<.*$//')
|
||||||
|
LAN_IP=$(ip addr | gawk '/
|
||||||
|
|
||||||
echo "$IP"
|
echo "$IP"
|
||||||
echo "$IP"
|
echo "$IP"
|
||||||
|
@ -1,30 +1,29 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
df | gawk '
|
df | gawk '
|
||||||
/\/$/ {
|
/\/$/ {
|
||||||
sfg=$4/1024^2
|
free_storage=$4/1024^2
|
||||||
sfm=$4/1024
|
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
if (sfg < 1) {
|
if (free_storage < 1) {
|
||||||
printf(" full \n")
|
printf(" full \n")
|
||||||
printf("full\n")
|
printf("full\n")
|
||||||
exit 33
|
exit 33
|
||||||
} else if (sfg > 5) {
|
} else if (free_storage > 5) {
|
||||||
printf("%.1f G\n", sfg)
|
printf("%.1f G\n", free_storage)
|
||||||
printf("%dG\n", sfg)
|
printf("%dG\n", free_storage)
|
||||||
} else {
|
} else {
|
||||||
printf("%.0f M\n", sfm)
|
printf("%.0f M\n", free_storage / 1024)
|
||||||
printf("%dG\n", sfm)
|
printf("%dM\n", free_storage / 1024)
|
||||||
}
|
}
|
||||||
if (sfg > 20) {
|
if (free_storage > 20) {
|
||||||
print("#04B431\n")
|
print("#04B431\n")
|
||||||
} else if (sfg > 15) {
|
} else if (free_storage > 15) {
|
||||||
print("#A8FF00\n")
|
print("#A8FF00\n")
|
||||||
} else if (sfg > 10) {
|
} else if (free_storage > 10) {
|
||||||
print("#FFF600\n")
|
print("#FFF600\n")
|
||||||
} else if (sfg > 5) {
|
} else if (free_storage > 5) {
|
||||||
print("#FFAE00\n")
|
print("#FFAE00\n")
|
||||||
} else if (sfg > 1) {
|
} else if (free_storage > 1) {
|
||||||
print("#FF0000\n")
|
print("#FF0000\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user