updated dwmblocks

This commit is contained in:
Solomon Laing 2023-04-24 23:15:34 +09:30
parent 3c973282ad
commit 3d1dad6d2f
8 changed files with 89 additions and 33 deletions

View File

@ -1,5 +1,12 @@
#!/bin/bash
case $BUTTON in
3) notify-send "Scroll to change adjust backlight." ;;
4) mod_backlight up ;;
5) mod_backlight down ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
icon=""
IFS=" " read -ra parts <<< "$(bash-status-bat)"

11
.local/bin/status-clock Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
case $BUTTON in
1) notify-send "This Month" "$(cal --color=always | sed "s/..7m/<b><span color=\"red\">/;s|..27m|</span></b>|")" && notify-send "Appointments" "$(calcurse -d3)" ;;
2) setsid -f "$TERMINAL" -e calcurse ;;
3) notify-send "Time/date module" "\- Left click to show upcoming appointments for the next three days via \`calcurse -d3\` and show the month via \`cal\`
- Middle click opens calcurse if installed" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
echo " $(date '+%a %Y-%m-%d %H:%M')"

View File

@ -2,7 +2,13 @@
homeval=$(df -h -B 1048576 | grep "/home")
if [[ ! -z $homeval ]]; then
case $BUTTON in
1) notify-send "Disk space" "$(df -h --output=target,used,size)" ;;
3) notify-send "Disk module" "Click to show all disk info." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
if [[ -n $homeval ]]; then
homefreemb=$(echo "$homeval" | awk -F ' ' '{ print $4 }')
homefreegb=$(echo "$homeval" | awk -F ' ' '{ print $4/1024 }')
fi
@ -18,7 +24,7 @@ else
out="$out / $(printf "%0.2fGb" "$rootfreegb")"
fi
if [[ ! -z $homeval ]]; then
if [[ -n $homeval ]]; then
if [ "$homefreemb" -lt 1024 ]; then
out="$out ~ $(printf "%0.2fMb" "$homefreemb")"
else

13
.local/bin/status-mem Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
case $BUTTON in
1) notify-send "Memory hogs" "$(ps axch -o cmd:15,%mem --sort=-%mem | head)" ;;
2) setsid -f "$TERMINAL" -e htop ;;
3) notify-send "Memory module" "\- Shows Memory Used/Total.
- Click to show memory hogs.
- Middle click to open htop." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
free --mebi | sed -n '2{p;q}' | awk '{printf (" %2.2fGiB/%2.2fGiB\n", ( $3 / 1024), ($2 / 1024))}'

View File

@ -1,37 +1,27 @@
#!/bin/bash
dev_wifi=$(<"$HOME"/.config/net-cfg/dev_wifi)
dev_eth=$(<"$HOME"/.config/net-cfg/dev_eth)
dev_vpn=$(<"$HOME"/.config/net-cfg/dev_vpn)
# Show wifi  and percent strength or 󰖪 if none.
# Show  if connected to ethernet or ❎ if none.
# Show 🔒 if a vpn connection is active
wifi_icon=" "
case $BLOCK_BUTTON in
1) "$TERMINAL" -e nmtui; pkill -RTMIN+15 dwmblocks ;;
3) notify-send "Internet module" "\- Click to connect
❌: wifi disabled
󰖪 : no wifi connection
 : wifi connection with quality
❎: no ethernet
 : ethernet working
🔒: vpn is active
" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
eth="$(ip -o address | grep -i "$dev_eth *inet ")"
if [ -n "$eth" ]
then
speed="$(cat "/sys/class/net/$dev_eth/speed")"
case $speed in
10) speed="10Base-T" ;;
100) speed="100Base-T" ;;
1000) speed="Gigabit" ;;
*) speed="UNKNOWN $speed" ;;
esac
eth_status="  $speed"
if grep -xq 'up' /sys/class/net/w*/operstate 2>/dev/null ; then
ssid="$(iw dev $(cat /proc/net/wireless | grep '^.*:' | sed 's/:.*//') link | grep -i SSID)"
wifiicon="$(awk '/^\s*w/ { print " ", int($3 * 100 / 70) "%" }' /proc/net/wireless) ${ssid##*SSID: } "
elif grep -xq 'down' /sys/class/net/w*/operstate 2>/dev/null ; then
grep -xq '0x1003' /sys/class/net/w*/flags && wifiicon="󰖪 " || wifiicon="❌ "
fi
ssid="$(iw dev "$dev_wifi" link | grep -i SSID)"
if [ -n "$ssid" ]
then
signal="$(awk '/^\s*w/ { print int($3 * 100 / 70) "%" }' /proc/net/wireless)"
wifi_status="$wifi_icon ${signal} ${ssid##*SSID: }"
fi
vpn="$(ip -o address | grep -i "$dev_vpn *inet ")"
if [ -n "$vpn" ]
then
vpn_status=""
else
vpn_status=""
fi
echo "${vpn_status} $wifi_status$eth_status"
printf "%s%s%s\n" "$wifiicon" "$(sed "s/down/❎/;s/up/🌐/" /sys/class/net/e*/operstate 2>/dev/null)" "$(sed "s/.*/🔒/" /sys/class/net/tun*/operstate 2>/dev/null)"

View File

@ -1,3 +1,12 @@
#!/bin/bash
case $BUTTON in
1) setsid -f "$TERMINAL" -e status-popupgrade ;;
2) notify-send "$(/usr/bin/pacman -Qu)" ;;
3) notify-send "Upgrade module" "Number of upgradable packages
- Left click to upgrade packages
- Middle click to show upgradable packages" ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
pacman -Qu | grep -Fcv "[ignored]" | sed "s/^/ /;s/^ 0$//g"

9
.local/bin/status-popupgrade Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
printf "Beginning upgrade.\\n"
yay -Syu
pkill -RTMIN+8 "${STATUSBAR:-dwmblocks}"
printf "\\nUpgrade complete.\\nPress <Enter> to exit window.\\n\\n"
read -r _

View File

@ -2,6 +2,17 @@
# Prints the current volume or  if muted.
case $BUTTON in
1) setsid -f "$TERMINAL" -e pulsemixer ;;
2) wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle ;;
4) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%+ ;;
5) wpctl set-volume @DEFAULT_AUDIO_SINK@ 1%- ;;
3) notify-send "Volume module" "\- Shows volume,  if muted.
- Middle click to mute.
- Scroll to change." ;;
6) "$TERMINAL" -e "$EDITOR" "$0" ;;
esac
vol="$(wpctl get-volume @DEFAULT_AUDIO_SINK@)"
# If muted, print 🔇 and exit.