diff --git a/README.md b/README.md index 7f5935c..aedeb6a 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,7 @@ A modular statusbar for DWM - [dwm_countdown](#dwm_countdown) - [dwm_keyboard](#dwm_keyboard) - [dwm_resources](#dwm_resources) + - [dwm_battery](#dwm_battery) - [dwm_cmus](#dwm_cmus) - [dwm_date](#dwm_date) - [dwm_mail](#dwm_mail) @@ -53,6 +54,11 @@ Displays information regarding memory, CPU temperature, and storage ``` [🖥 MEM 1.3Gi/15Gi CPU 45C STO 2.3G/200G: 2%] ``` +### dwm_battery +Displays battery level and status +``` +[🔌 55 Charging] +``` ### dwm_cmus displays current cmus status, artist, track, position, duration, and shuffle ``` @@ -75,7 +81,7 @@ Displays the current weather provided by [wttr.in](https://wttr.in) [☀ +20°C] ``` ### dwm_network -Displays the current network connection, private IP, and public IP +Displays the current network connection/SSID, private IP, and public IP ``` [🌐 enp7s0: 192.168.0.1/24 | 185.199.109.153] ``` diff --git a/bar-functions/dwm_battery.sh b/bar-functions/dwm_battery.sh new file mode 100755 index 0000000..e46c5d0 --- /dev/null +++ b/bar-functions/dwm_battery.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +# A dwm_bar function to read the battery level and status +# Joe Standring +# GNU GPLv3 + +dwm_battery () { + # Change BAT1 to whatever your battery is identified as. Typically BAT0 or BAT1 + CHARGE=$(cat /sys/class/power_supply/BAT1/capacity) + STATUS=$(cat /sys/class/power_supply/BAT1/status) + + if [ "$IDENTIFIER" = "unicode" ]; then + if [ "$STATUS" = "Charging" ]; then + printf "[🔌 %s %s]\n" "$CHARGE" "$STATUS" + else + printf "[🔋 %s %s]\n" "$CHARGE" "$STATUS" + fi + else + printf "[BAT %s %s]\n" "$CHARGE" "$STATUS" + fi +} + +dwm_battery + diff --git a/bar-functions/dwm_network.sh b/bar-functions/dwm_network.sh index e7d044c..536fe7c 100755 --- a/bar-functions/dwm_network.sh +++ b/bar-functions/dwm_network.sh @@ -1,6 +1,6 @@ #!/bin/sh -# A dwm_bar function to show the current network connection, private IP, and public IP +# A dwm_bar function to show the current network connection/SSID, private IP, and public IP # Joe Standring # GNU GPLv3 @@ -8,6 +8,10 @@ dwm_network () { CONNAME=$(nmcli -a | grep 'Wired connection' | awk 'NR==1{print $1}') + if [ "$CONNAME" = "" ]; then + CONNAME=$(nmcli -t -f active,ssid dev wifi | grep '^yes' | cut -c 5-) + fi + PRIVATE=$(nmcli -a | grep 'inet4 192' | awk '{print $2}') PUBLIC=$(curl -s https://ipinfo.io/ip)