2019-05-19 14:25:57 +02:00
|
|
|
#!/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
|
|
|
|
}
|
|
|
|
|
|
|
|
print_volume() {
|
2019-05-24 08:35:52 +02:00
|
|
|
[ "$(pulsemixer --get-mute)" = "1" ] && printf "" && exit
|
2019-05-19 14:25:57 +02:00
|
|
|
vol=$(pulsemixer --get-volume | awk '{print $1}')
|
2019-05-24 08:35:52 +02:00
|
|
|
printf "%s%%\\n" " $vol"
|
2019-05-19 14:25:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print_wifi()
|
|
|
|
{
|
2019-05-24 08:35:52 +02:00
|
|
|
ESSID="`iw dev wlan0 link | grep SSID| sed -r 's/SSID://' | sed -e 's/^[ \t]*//'`"
|
|
|
|
if test -z "$ESSID"
|
|
|
|
then
|
|
|
|
echo -e ""
|
|
|
|
else
|
|
|
|
echo -e " $ESSID"
|
|
|
|
fi
|
2019-05-19 14:25:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print_mem(){
|
|
|
|
memfree=$(($(grep -m1 'MemAvailable:' /proc/meminfo | awk '{print $2}') / 1024))
|
2019-05-20 14:40:18 +02:00
|
|
|
echo -e "$memfree"
|
2019-05-19 14:25:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print_temp(){
|
2019-05-24 08:35:52 +02:00
|
|
|
echo -e " $(sensors | awk '/Core 0/ {print $3}') +$(nvidia-smi -q -d temperature | grep -i "GPU Current" |sed -r 's/GPU Current Temp ://'| sed -r 's/ C//' |sed -e 's/^[ \t]*//').0°C"
|
2019-05-19 14:25:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print_bat(){
|
|
|
|
hash acpi || return 0
|
|
|
|
onl="$(grep "on-line" <(acpi -V))"
|
|
|
|
charge="$(awk '{ sum += $1 } END { print sum }' /sys/class/power_supply/BAT*/capacity)"
|
|
|
|
if test -z "$onl"
|
|
|
|
then
|
|
|
|
# suspend when we close the lid
|
|
|
|
#systemctl --user stop inhibit-lid-sleep-on-battery.service
|
2019-05-24 08:35:52 +02:00
|
|
|
if [ "$charge" -ge 75 ]; then
|
|
|
|
echo -e " ${charge}%"
|
|
|
|
elif [ "$charge" -ge 50 ]; then
|
|
|
|
echo -e " ${charge}%"
|
|
|
|
elif [ "$charge" -ge 25 ]; then
|
|
|
|
echo -e " ${charge}%"
|
|
|
|
else
|
|
|
|
echo -e " !${charge}%"
|
|
|
|
fi
|
2019-05-19 14:25:57 +02:00
|
|
|
else
|
|
|
|
# On mains! no need to suspend
|
|
|
|
#systemctl --user start inhibit-lid-sleep-on-battery.service
|
2019-05-24 08:35:52 +02:00
|
|
|
echo -e " ${charge}%"
|
2019-05-19 14:25:57 +02:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print_date(){
|
2019-05-24 08:35:52 +02:00
|
|
|
echo -e " $(date +"%m-%e %H:%M")"
|
2019-05-19 14:25:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
print_mail(){
|
|
|
|
RESULT=$(echo "$(du -a ~/.mailbox/*/inbox/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon_$USER 2>/dev/null)")
|
|
|
|
if [ -z $RESULT ]; then
|
|
|
|
echo "0"
|
|
|
|
else
|
|
|
|
echo "$(du -a ~/.mailbox/*/inbox/new/* 2>/dev/null | sed -n '$=')$(cat /tmp/imapsyncicon_$USER 2>/dev/null)"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
echo AUTOSTART
|
|
|
|
feh --bg-fill $HOME/.wall.jpg &
|
|
|
|
xset s off -dpms&
|
|
|
|
xset b off&
|
|
|
|
xset s off&
|
|
|
|
xset -dpms&
|
|
|
|
redshift -l 52.2327:18.3036 -t 6500:3200&
|
|
|
|
nm-applet --sm-disable&
|
|
|
|
/usr/local/bin/st -e "tmux-my"&
|
|
|
|
"/mnt/mega/Systems/Gentoo/apps/KeePass.AppImage"&
|
|
|
|
megasync&
|
|
|
|
dunst -config&
|
|
|
|
/usr/bin/ibus-daemon -d&
|
|
|
|
sh /home/yorune/.xsessionrc&
|
|
|
|
keepassxc&
|
|
|
|
transmission-daemon&
|
|
|
|
teamviewer&
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
2019-05-24 08:35:52 +02:00
|
|
|
xsetroot -name "$(print_temp) $(sh /home/yorune/dwm/weather.sh) $(print_wifi) $(print_bat) $(print_volume) $(print_date)"
|
2019-05-19 14:25:57 +02:00
|
|
|
|
|
|
|
# Update old values to perform new calculations
|
|
|
|
old_received_bytes=$received_bytes
|
|
|
|
old_transmitted_bytes=$transmitted_bytes
|
|
|
|
old_time=$now
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
done
|
|
|
|
|