1
0
Fork 0
mirror of https://github.com/roles-ansible/ansible_role_sway.git synced 2024-08-16 13:49:49 +02:00

update i3wm weather and wifi

This commit is contained in:
L3D 2021-04-16 12:42:28 +02:00
parent 8914cb560b
commit c1f7cf6952
Signed by: l3d
GPG key ID: CD08445BFF4313D1
3 changed files with 78 additions and 5 deletions

View file

@ -3,14 +3,18 @@ separator_block_width=15
markup=pango
[weather]
command=curl -Ss 'https://wttr.in?0&T&Q' | cut -c 16- | head -2 | xargs echo
interval=3600
command=curl -Ss 'https://wttr.in?0&T' | cut -c 16- | head -4 | tail -2 | xargs echo
interval=1800
color=#A4C2F4
[volume]
interval=30
signal=10
[wlan]
interval=1
signal=10
[ip]
command=hostname -i | awk '{ print " IPv4: " $1 }'
interval=120
@ -18,11 +22,11 @@ label=🖥️
color=#91E78B
[clock]
label=🕒
label=🕒
command=date --iso-8601=seconds
interval=1
[ddate]
label=🚀
label=🚀
command=ddate +'%{%A, %d %B%}, %Y %N%tCelebrate %H'
interval=120

69
files/i3blocks/wlan Executable file
View file

@ -0,0 +1,69 @@
#!/usr/bin/env bash
#
# i3blocks blocklet script to display wifi signal in dBm and IP address, if WIFI is available
# try to detect interface name
if [[ -z "$IFACE" ]] ; then
if ( ip a s dev wlp3s0 ) > /dev/null 2>& 1 ; then
IFACE="wlp3s0"
elif ( ip a s dev wlan0 ) > /dev/null 2>& 1 ; then
IFACE="wlan0"
else
exit 1
fi
fi
USE_PERCENT=${USE_PERCENT:-0}
IW=$(which iw || echo "/sbin/iw")
if [[ ! -x $IW ]]; then
echo "No iw binary was found on the system." 1>2
exit 1
fi
while getopts p opt; do
case "$opt" in
p) USE_PERCENT=1 ;;
esac
done
if ( ip a s dev $IFACE | grep "state DOWN" ) > /dev/null 2>& 1 ; then
echo "📶 DOWN"
fi
dbm=$($IW dev "$IFACE" link | grep 'dBm$' | grep -Eoe '-[0-9]{2}')
ssid=$($IW dev "$IFACE" link | grep 'SSID' | cut -d ':' -f2 | sed "s/\ //g")
ipv4=$(ip -o -4 addr list "$IFACE" | awk '{print $4}')
ipv6=$(ip -o -6 addr list "$IFACE" | awk '{print $4}')
[[ -n "$dbm" ]] || exit 1
[[ -n "$ssid" ]] || exit 1
if [[ $USE_PERCENT -eq 0 ]]; then
echo "📶($ssid) $dbm"dBm
echo "📶($ssid) $dbm"dBm
else
if [[ "$dbm" -le -100 ]]; then
quality=0
elif [[ $dbm -ge -50 ]]; then
quality=100
else
quality=$((2 * (dbm + 100)))
fi
echo "📶($ssid) $quality%"
echo "📶($ssid) $quality%"
fi
if [[ $dbm -ge -55 ]]; then
echo "#00FF00"
elif [[ $dbm -ge -60 ]]; then
echo "#CCFF00"
elif [[ $dbm -ge -70 ]]; then
echo "#FFFF00"
elif [[ $dbm -ge -80 ]]; then
echo "#FFAA00"
else
echo "#FF0000"
fi

View file

@ -33,5 +33,5 @@ __i3_workspaces:
user: "{{ i3wm_user }}"
playbook_version_number: 9018 # should be int
playbook_version_number: 9019 # should be int
playbook_version_path: 'role-i3wm_chaos-bodensee_github.com.version'