diff --git a/scripts/status_bar.sh b/scripts/status_bar.sh new file mode 100755 index 0000000..f8d6e77 --- /dev/null +++ b/scripts/status_bar.sh @@ -0,0 +1,35 @@ +#!/bin/sh + +# Sets xsetroot name +# Copy to any location (e.g. ~/.config/dwm), modify as needed, and set this script to run +# in .xinitrc. Note make sure it is nonblocking (add & to end) or this will freeze the +# system + +print_date(){ + echo $(date "+%a, %b %d %R") +} + +print_mem(){ + available=$(cat /proc/meminfo | grep MemAvailable | awk '{print $2}') + echo "$((available/1024))M" +} + +print_ip(){ + # Print normal ip + normal_ip="$(ip addr show | grep enp4s0 | grep inet | awk '{print $2}' | awk -F/ '{print $1}')" + + # If I'm connected to a vpn, print vpn ip + vpn_ip="$(ip addr show | grep tun0 | grep inet | awk '{print $2}' | awk -F/ '{print $1}')" + if [ -z $vpn_ip ]; + then + echo "$normal_ip" + else + echo "$normal_ip | $vpn_ip" + fi +} + +while true +do + xsetroot -name "$(print_ip) | $(print_mem) | $(print_date)" + sleep 1 +done