Skip to content

feat/add gsm support #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions docs/CONFIG.md
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ set -g @dracula-mpc-format "%title% - %artist%"

`set -g @dracula-refresh-rate 5` affects this widget
### network - [up](#table-of-contents)
This widget displays one of three states: offline, ethernet connected, or wifi connected.
however, per default **this will only display the wifi you're connected to, if it provides internet access!**
This widget displays one of four states: offline, ethernet connected, wifi connected, or gsm connected.
however, per default **this will only display the ethernet/wifi/gsm you're connected to, if it provides internet access!**

You can use different hosts to ping in order to check for a wifi or wired connection.
If you frequently use networks without internet access, you can use local ip-addresses here to still display the connection.
Expand All @@ -483,14 +483,15 @@ Possible nerdfont settings for network info:
```bash
set -g @dracula-network-ethernet-label "󰈀 Eth"
set -g @dracula-network-offline-label "󱍢 "
set -g @dracula-network-wifi-label " "
set -g @dracula-network-wifi-label " "
set -g @dracula-network-gsm-label " "
```

Nerdfont icons to consider:
```
ethernet: 󰈀 󰒪 󰒍 󰌗 󰌘
offline: 󰖪 󱍢
wifi:    󰖩 󰘊 󰒢
wifi/gsm:    󰖩 󰘊 󰒢
```

Known issues:
Expand Down
10 changes: 10 additions & 0 deletions scripts/network.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source $current_dir/utils.sh
# set your own hosts so that a wifi is recognised even without internet access
HOSTS=$(get_tmux_option "@dracula-network-hosts" "google.com github.com example.com")
wifi_label=$(get_tmux_option "@dracula-network-wifi-label" "")
gsm_label=$(get_tmux_option "@dracula-network-gsm-label" "GSM")
ethernet_label=$(get_tmux_option "@dracula-network-ethernet-label" "Ethernet")

get_ssid()
Expand All @@ -16,8 +17,17 @@ get_ssid()
case $(uname -s) in
Linux)
SSID=$(iw dev | sed -nr 's/^\t\tssid (.*)/\1/p')
if [ ! -x "$(which nmcli 2> /dev/null)" ];then
nmcli connection show --active | grep gsm
gsm_connected=$?
else
gsm_connected=false
fi
if [ -n "$SSID" ]; then
echo "$wifi_label$SSID"
elif $gsm_connected; then
gsm_carrier=$(nmcli connection show --active | grep gsm | cut -d ' ' -f 1)
echo "$gsm_label$gsm_carrier"
else
echo "$ethernet_label"
fi
Expand Down