timproved netip() function and changed style abit - scripts - various script and utils
(HTM) git clone git://z3bra.org/scripts
(DIR) Log
(DIR) Files
(DIR) Refs
---
(DIR) commit 3da0037757c08b1356528410ee3302216d9de494
(DIR) parent 91664c7685b96143d06b0e11f54c7c4a9ce497c6
(HTM) Author: z3bra <willy@mailoo.org>
Date: Fri, 17 Oct 2014 12:09:45 +0200
improved netip() function and changed style abit
Diffstat:
M mkbar | 38 ++++++++++++++++----------------
1 file changed, 19 insertions(+), 19 deletions(-)
---
(DIR) diff --git a/mkbar b/mkbar
t@@ -16,20 +16,20 @@
# configuration variables
refresh_rate=0.75 # how often will the bar update
datefmt="%d %b %H:%M" # date time format
-maildir=~/var/mail/INBOX/new # where do new mails arrive ?
+maildir=~/var/mail/inbox/new # where do new mails arrive ?
alsactl=Master # which alsa channel to display
#battery=BAT0 # battery index
# find battery name in a smart way
battery=$(ls /sys/class/power_supply | grep BAT)
barch=''
-barfg='%{F#ff666666}'
-barmg='%{F#ff2288cc}'
+barfg='%{F#ff888888}'
+barmg='%{F#ffffffff}'
barbg='%{F#00888888}'
-grpfg='%{F#ff111111} '
+grpfg='%{F#ffffff00} '
grpmg='%{F#ff2288cc} '
-grpbg='%{F#ffbbbbbb} '
+grpbg='%{F#ffffffff} '
# no need to modify anything else here
t@@ -75,10 +75,16 @@ netstate() {
}
netip() {
- # local ip
- #ip addr show $(netint) | grep 'inet ' | awk '{print $2}'
- # extern ip
- curl http://canihazip.com/s
+ case $1 in
+ local)
+ # local ip
+ ip addr show $(netint) | grep 'inet ' | awk '{print $2}'
+ ;;
+ *)
+ # extern ip
+ curl http://canihazip.com/s
+ ;;
+ esac
}
nettrafic() {
t@@ -165,9 +171,9 @@ makebar() {
for v in $(seq 0 $((max - 1))); do
if [ "$v" -lt "$cur" ]; then
- bar="${bar}${barfg}${barch}"
+ bar="${bar}${barmg}${barch}"
else
- bar="${bar}${barbg}${barch}"
+ bar="${bar}${barfg}${barch}"
fi
done
t@@ -179,14 +185,8 @@ buf="%{l} "
# Set icon depending on the interface that is up
buf="${buf}${barmg} "
-if test "$(netint)" = "eth0"; then
- buf="${buf}${barfg}"
-elif test "$(netint)" = "wlan0"; then
- buf="${buf}${barfg}"
-else
- buf="${buf}${barfg}"
-fi
-buf="$buf $(netstate) "
+buf="${buf}${barfg}"
+buf="$buf $(netip local) "
buf="${buf}${barmg} ${barfg} $(nettrafic down) "
buf="${buf}${barmg} ${barfg} $(nettrafic up) "