Added files

This commit is contained in:
Marcin Wozniak
2019-05-31 08:54:58 +02:00
parent fd394125d2
commit 60908a0dfa
7 changed files with 1803 additions and 31 deletions

View File

@ -1,21 +1,4 @@
#!/bin/bash
#function get_bytes {
#interface=$(ip route get 8.8.8.8 2>/dev/null| awk '{print $5}')
#line=$(grep $interface /proc/net/dev | cut -d ':' -f 2 | awk '{print "received_bytes="$1, "transmitted_bytes="$9}')
#eval $line
#now=$(date +%s%N)
#}
#
## Function which calculates the speed using actual and old byte number.
## Speed is shown in KByte per second when greater or equal than 1 KByte per second.
## This function should be called each second.
#
#function get_velocity {
#value=$1
#old_value=$2
#now=$3
#}
testweather() {
[ "$(stat -c %y "/tmp/weatherreport" 2>/dev/null | cut -d' ' -f1)" != "$(date '+%Y-%m-%d')" ] && ping -q -c 1 1.1.1.1 >/dev/null && curl -s "wttr.in/$location" > "/tmp/weatherreport" && notify-send "🌞 Weather" "New weather forecast for today."
@ -127,21 +110,7 @@ getforecast&
while true
do
# Get new transmitted, received byte number values and current time
get_bytes
# Calculates speeds
vel_recv=$(get_velocity $received_bytes $old_received_bytes $now)
vel_trans=$(get_velocity $transmitted_bytes $old_transmitted_bytes $now)
xsetroot -name " $(print_temp) | $(usageData) | $(testweather) | $(print_wifi) | $(batLevel) | $(print_volume) | $(print_date)"
# Update old values to perform new calculations
old_received_bytes=$received_bytes
old_transmitted_bytes=$transmitted_bytes
old_time=$now
sleep 2
done