apts & todos
This commit is contained in:
parent
03579f2aab
commit
d15787824f
1 changed files with 64 additions and 5 deletions
|
@ -1,5 +1,50 @@
|
|||
#!/bin/sh
|
||||
|
||||
get_int() { # Type of interface & status
|
||||
# If active ethernet, just exit with icon
|
||||
grep -xq 'up' /sys/class/net/e*/operstate 2>/dev/null && echo "" && return 0
|
||||
|
||||
# If active WiFi, print link strength
|
||||
if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
|
||||
strength="$(awk 'NR==3 {printf("%.0f\n",$3*10/7)}' /proc/net/wireless)"
|
||||
case 1 in
|
||||
$((strength >= 100)) ) bar="━━━━━━━━━━" ;;
|
||||
$((strength >= 90)) ) bar="━━━━━━━━━─" ;;
|
||||
$((strength >= 80)) ) bar="━━━━━━━━──" ;;
|
||||
$((strength >= 70)) ) bar="━━━━━━━───" ;;
|
||||
$((strength >= 60)) ) bar="━━━━━━────" ;;
|
||||
$((strength >= 50)) ) bar="━━━━━─────" ;;
|
||||
$((strength >= 40)) ) bar="━━━━──────" ;;
|
||||
$((strength >= 30)) ) bar="━━━───────" ;;
|
||||
$((strength >= 20)) ) bar="━━────────" ;;
|
||||
$((strength >= 10)) ) bar="━─────────" ;;
|
||||
$((strength >= 0)) ) bar="──────────" ;;
|
||||
esac
|
||||
echo " $bar"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# If down interfaces, exit with icon
|
||||
grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null && echo " ──────────" && return 0
|
||||
grep -xq 'down' /sys/class/net/e*/operstate 2>/dev/null && echo "" && return 0
|
||||
}
|
||||
|
||||
get_net() {
|
||||
# Run 'int'
|
||||
info=$(get_int)
|
||||
|
||||
# Check if a VPN is enabled
|
||||
vpn="$( \
|
||||
sed "s/.*//" /sys/class/net/tun*/operstate 2>/dev/null
|
||||
sed "s/.*//" /sys/class/net/wg*/operstate 2>/dev/null \
|
||||
)"
|
||||
# If so, change icon
|
||||
[ -n "$vpn" ] && info="$(printf "$info" | sed 's///' | sed 's///')"
|
||||
|
||||
# Print $info
|
||||
printf "%s" "$info"
|
||||
}
|
||||
|
||||
get_vol() {
|
||||
vol=$(amixer | grep "Playback" | grep -o '[0-9]*[0-9]%' | head -n 1)
|
||||
vol="${vol%\%*}" # Remove percentage sign
|
||||
|
@ -52,10 +97,6 @@ get_mic() {
|
|||
echo " $bar"
|
||||
}
|
||||
|
||||
get_net() {
|
||||
netstat
|
||||
}
|
||||
|
||||
get_bat() {
|
||||
total=0
|
||||
batteries=0
|
||||
|
@ -95,10 +136,28 @@ get_layout() {
|
|||
echo " $layout"
|
||||
}
|
||||
|
||||
get_apts() {
|
||||
apts="$(calcurse -a | grep -c '\*')"
|
||||
[ "$apts" = "0" ] && return 0
|
||||
echo " $apts"
|
||||
}
|
||||
|
||||
get_todo() {
|
||||
todo="$(calcurse -t | wc -l)"
|
||||
[ "$todo" = "0" ] && return 0
|
||||
echo " $todo"
|
||||
}
|
||||
|
||||
while true ; do
|
||||
status=""
|
||||
separator=" "
|
||||
|
||||
todo="$(get_todo)"
|
||||
! [ -z "$todo" ] && status="$status$separator$todo"
|
||||
|
||||
apts="$(get_apts)"
|
||||
! [ -z "$apts" ] && status="$status$separator$apts"
|
||||
|
||||
volume="$(get_vol)"
|
||||
! [ -z "$volume" ] && status="$status$separator$volume"
|
||||
|
||||
|
@ -114,7 +173,7 @@ while true ; do
|
|||
layout="$(get_layout)"
|
||||
! [ -z "$layout" ] && status="$status$separator$layout"
|
||||
|
||||
date_time="$(date "+%I:%M%p$separator %a %Y-%m-%d")"
|
||||
date_time="$(date "+%I:%M%p$separator %a %Y-%m-%d")"
|
||||
! [ -z "$date_time" ] && status="$status$separator $date_time"
|
||||
|
||||
printf "%s\n" "$status"
|
||||
|
|
Loading…
Reference in a new issue