better looking status bar modules!

This commit is contained in:
tavo-wasd 2023-07-31 02:51:39 -06:00
parent 91f3d5dfad
commit 8047ecbd1f
6 changed files with 127 additions and 29 deletions

View file

@ -5,11 +5,23 @@
bat=$(grep "[0-9]" /sys/class/power_supply/BAT0/capacity)
stat=$(cat /sys/class/power_supply/BAT0/status)
# Append charging indicator if status file indicates such state
# Print only charge % otherwise
[ "$stat" = "Charging" ] &&
echo "$bat% " && exit ||
echo "$bat%"
case 1 in
$((bat >= 98)) ) bar="━━━━━━━━━━" ;;
$((bat >= 90)) ) bar="━━━━━━━━━─" ;;
$((bat >= 80)) ) bar="━━━━━━━━──" ;;
$((bat >= 70)) ) bar="━━━━━━━───" ;;
$((bat >= 60)) ) bar="━━━━━━────" ;;
$((bat >= 50)) ) bar="━━━━━─────" ;;
$((bat >= 40)) ) bar="━━━━──────" ;;
$((bat >= 30)) ) bar="━━━───────" ;;
$((bat >= 20)) ) bar="━━────────" ;;
$((bat >= 10)) ) bar="━!────────" ;;
$((bat >= 0)) ) bar="CHARGE NOW" ;;
esac
# Charging indicator if status file indicates such state
[ "$stat" != "Charging" ] && icon="󰁹" || icon=""
echo "$icon $bar"
# Warning when battery is under 10% capacity and not charging
[ $((bat)) -lt 15 ] && [ "$stat" != "Charging" ] &&

View file

@ -1,4 +1,5 @@
#!/bin/sh
# Get current keyboard layout
setxkbmap -query | grep layout | awk '{print $2}'
setxkbmap -query | grep layout | awk '{print $2}' |
sed 's/latam/la/'

View file

@ -4,12 +4,31 @@
# Get volume levels
vol=$(amixer | grep "Capture" | grep -o '[0-9]*[0-9]%' | tail -n 1)
vol="${vol%\%*}" # Remove percentage sign
# If device is off (muted), notify mute, print volume otherwise
if amixer scontents | grep "Capture" | grep -q "\[off\]"; then
echo " M"
echo " ──────────"
notify-send -u low --replace-id=11 " Microphone" "Mute"
else
echo "$vol"
notify-send -u low --replace-id=11 " Microphone" "$vol"
exit
fi
# Define bar progress with volume
case 1 in
$((vol >= 100)) ) bar="━━━━━━━━━━" ;;
$((vol >= 90)) ) bar="━━━━━━━━━─" ;;
$((vol >= 80)) ) bar="━━━━━━━━──" ;;
$((vol >= 70)) ) bar="━━━━━━━───" ;;
$((vol >= 60)) ) bar="━━━━━━────" ;;
$((vol >= 50)) ) bar="━━━━━─────" ;;
$((vol >= 40)) ) bar="━━━━──────" ;;
$((vol >= 30)) ) bar="━━━───────" ;;
$((vol >= 20)) ) bar="━━────────" ;;
$((vol >= 10)) ) bar="━─────────" ;;
$((vol >= 0)) ) bar="──────────" ;;
$((vol = 0)) ) bar="──────────" ;;
esac
# Print and notify
echo " $bar"
notify-send -u low --replace-id=11 " Microphone" "$bar"

View file

@ -1,17 +1,47 @@
#!/bin/sh
# Modified version of Luke Smith's network usage script
# Print cache so it doesn't get stuck in dwmblocks
cat "$XDG_CACHE_HOME"/netstat
int() { # Type of interface & status
# Store transferred and recieved bytes
rstart="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
tstart="$(($(cat /sys/class/net/[ew]*/statistics/tx_bytes | paste -sd '+')))"
sleep 1
rend="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
tend="$(($(cat /sys/class/net/[ew]*/statistics/tx_bytes | paste -sd '+')))"
# If active ethernet, just exit with icon
grep -xq 'up' /sys/class/net/e*/operstate 2>/dev/null && echo "󰛳" && return 0
# Format correctly and print
dow=$(printf "%2sB\n" "$(numfmt --to=iec $(($rend-$rstart)))")
up=$(printf "%2sB\n" "$(numfmt --to=iec $(($tend-$tstart)))")
printf "$dow|$up" | sed 's/ //g' > "$XDG_CACHE_HOME"/netstat
# 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="──────────" ;;
$((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
}
# Run 'int'
info=$(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
[ -e "$vpn" ] && info="$(printf "$info" | sed 's/󰛳//' | sed 's/󰖩//')"
# Print $info
printf "%s" "$info"

17
scripts/nettraf Executable file
View file

@ -0,0 +1,17 @@
#!/bin/sh
# Modified version of Luke Smith's network usage script
# Print cache so it doesn't get stuck in dwmblocks
cat "$XDG_CACHE_HOME"/netstat
# Store transferred and recieved bytes
rstart="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
tstart="$(($(cat /sys/class/net/[ew]*/statistics/tx_bytes | paste -sd '+')))"
sleep 1
rend="$(($(cat /sys/class/net/[ew]*/statistics/rx_bytes | paste -sd '+')))"
tend="$(($(cat /sys/class/net/[ew]*/statistics/tx_bytes | paste -sd '+')))"
# Format correctly and print
dow=$(printf "%2sB\n" "$(numfmt --to=iec $(($rend-$rstart)))")
up=$(printf "%2sB\n" "$(numfmt --to=iec $(($tend-$tstart)))")
printf "$dow|$up" | sed 's/ //g' > "$XDG_CACHE_HOME"/netstat

View file

@ -1,15 +1,34 @@
#!/bin/sh
# Fetch current audio levels
# Fetch current audio level
# (in current default output)
# Get volume levels
# Get volume level
vol=$(amixer | grep "Playback" | grep -o '[0-9]*[0-9]%' | head -n 1)
vol="${vol%\%*}" # Remove percentage sign
# If device is off (muted), notify mute, print volume otherwise
if amixer scontents | grep "Playback" | grep -q "\[off\]"; then
echo " M"
echo "󰖁 ──────────"
notify-send -u low --replace-id=10 "󰖁 Volume" "Mute"
else
echo "$vol"
notify-send -u low --replace-id=10 "󰕾 Volume" "$vol"
exit
fi
# Define bar progress with volume
case 1 in
$((vol >= 100)) ) bar="━━━━━━━━━━" ;;
$((vol >= 90)) ) bar="━━━━━━━━━─" ;;
$((vol >= 80)) ) bar="━━━━━━━━──" ;;
$((vol >= 70)) ) bar="━━━━━━━───" ;;
$((vol >= 60)) ) bar="━━━━━━────" ;;
$((vol >= 50)) ) bar="━━━━━─────" ;;
$((vol >= 40)) ) bar="━━━━──────" ;;
$((vol >= 30)) ) bar="━━━───────" ;;
$((vol >= 20)) ) bar="━━────────" ;;
$((vol >= 10)) ) bar="━─────────" ;;
$((vol >= 0)) ) bar="──────────" ;;
$((vol = 0)) ) bar="──────────" ;;
esac
# Print and notify
echo "󰕾 $bar"
notify-send -u low --replace-id=10 "󰕾 Volume" "$bar"