Browse Source

Merge pull request #7 from procrastimax/master

Adds network information support for connman
main
Joe Standring 4 years ago
committed by GitHub
parent
commit
433fbe9b9e
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 0 deletions
  1. +7
    -0
      README.md
  2. +42
    -0
      bar-functions/dwm_connman.sh
  3. +2
    -0
      dwm_bar.sh

+ 7
- 0
README.md View File

@ -22,6 +22,7 @@ A modular statusbar for dwm
- [dwm_ccurse](#dwm_ccurse)
- [dwm_transmission](#dwm_transmission)
- [dwm_backlight](#dwm_backlight)
- [dwm_connman](#dwm_connman)
- [dwm_loadavg](#dwm_loadavg)
- [Installation](#installation)
- [Reccomendations](#reccomendations)
@ -141,6 +142,12 @@ Displays the current backlight level with xbacklight
[☀ 80]
```
Dependencies: ```xbacklight```
### dwm_connman
Shows network information IP, SSID, WLan strength (if connected to WLan) using connman.
```
[🌐 192.169.189.12 HomeNetworkName 53%]
```
Dependencies: ```connman```
### dwm_loadavg
Displays the average system load
```


+ 42
- 0
bar-functions/dwm_connman.sh View File

@ -0,0 +1,42 @@
#!/bin/sh
# A dwm_bar function to show the current network connection/SSID, Wifi Strength, private IP using Connmanctl.
# procrastimax <heykeroth.dev@gmail.com>
# GNU GPLv3
# Dependencies: connman
dwm_connman () {
printf "%s" "$SEP1"
if [ "$IDENTIFIER" = "unicode" ]; then
printf "🌐 "
else
printf "NET "
fi
# get the connmanctl service name
# this is a UID starting with 'vpn_', 'wifi_', or 'ethernet_', we dont care for the vpn one
# if the servicename string is empty, there is no online connection
SERVICENAME=$(connmanctl services | grep -E "^\*AO|^\*O" | grep -Eo 'wifi_.*|ethernet_.*')
if [ ! "$SERVICENAME" ]; then
printf "OFFLINE"
printf "%s\n" "$SEP2"
return
else
STRENGTH=$(connmanctl services "$SERVICENAME" | sed -n -e 's/Strength =//p' | tr -d ' ')
CONNAME=$(connmanctl services "$SERVICENAME" | sed -n -e 's/Name =//p' | tr -d ' ')
IP=$(connmanctl services "$SERVICENAME" | grep 'IPv4 =' | awk '{print $5}' | sed -n -e 's/Address=//p' | tr -d ',')
fi
# if STRENGTH is empty, we have a wired connection
if [ "$STRENGTH" ]; then
printf "%s %s %s%%" "$IP" "$CONNAME" "$STRENGTH"
else
printf "%s %s" "$IP" "$CONNAME"
fi
printf "%s\n" "$SEP2"
}
dwm_connman

+ 2
- 0
dwm_bar.sh View File

@ -40,11 +40,13 @@ export SEP2="]"
. "$DIR/bar-functions/dwm_keyboard.sh"
. "$DIR/bar-functions/dwm_ccurse.sh"
. "$DIR/bar-functions/dwm_date.sh"
. "$DIR/bar-functions/dwm_connman.sh"
. "$DIR/bar-functions/dwm_loadavg.sh"
# Update dwm status bar every second
while true
do
xsetroot -name "$(dwm_connman)$(dwm_countdown)$(dwm_alarm.sh)$(dwm_transmission)$(dwm_cmus)$(dwm_mpc)$(dwm_spotify)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_backlight)$(dwm_alsa)$(dwm_pulse)$(dwm_weather)$(dwm_vpn)$(dwm_networkmanager)$(dwm_keyboard)$(dwm_ccurse)$(dwm_date)"
xsetroot -name "$(dwm_countdown)$(dwm_alarm.sh)$(dwm_transmission)$(dwm_cmus)$(dwm_mpc)$(dwm_spotify)$(dwm_resources)$(dwm_battery)$(dwm_mail)$(dwm_backlight)$(dwm_alsa)$(dwm_pulse)$(dwm_weather)$(dwm_vpn)$(dwm_networkmanager)$(dwm_keyboard)$(dwm_ccurse)$(dwm_date)$(dwm_loadavg)"
sleep 1
done

Loading…
Cancel
Save