-
Notifications
You must be signed in to change notification settings - Fork 335
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
base: master
Are you sure you want to change the base?
feat/add gsm support #350
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -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() | ||||||||||||||||||||||||||
|
@@ -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 | ||||||||||||||||||||||||||
Comment on lines
26
to
31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Incorrect boolean test and fragile carrier extraction.
Apply this diff: - 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"
+ if [ -n "$SSID" ]; then
+ echo "$wifi_label$SSID"
+ elif [ "$gsm_connected" = true ]; then
+ gsm_carrier="$(nmcli -t -f NAME,TYPE connection show --active | awk -F: '$2=="gsm"{print $1; exit}')"
+ echo "$gsm_label$gsm_carrier" 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents
|
||||||||||||||||||||||||||
echo "$ethernet_label" | ||||||||||||||||||||||||||
fi | ||||||||||||||||||||||||||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Broken nmcli presence check (inverted) and unnecessary execution when missing.
The guard is inverted: you run nmcli when it’s not present. Use command -v and set a boolean accordingly.
Apply this diff:
📝 Committable suggestion
🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure if i understand, since i've tried it and it seemed to work. please double check and so will i
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
@Theoreticallyhugo Let me double-check this logic by testing it directly to make sure I understand it correctly.
🏁 Script executed:
Length of output: 1462
@Theoreticallyhugo I've confirmed my analysis - the logic is indeed inverted. Here's what's happening:
Current behavior:
nmcli
is NOT installed: condition is TRUE → tries to runnmcli
commands (which fail)nmcli
IS installed: condition is FALSE → setsgsm_connected=false
(never checks GSM)This means GSM detection is disabled when nmcli is actually available!
You can verify this on your system:
If nmcli is installed on your system, you'll see "Would set gsm_connected=false", meaning GSM detection never runs. The fact that it "works" for you might be because:
The fix ensures GSM detection only runs when nmcli is available:
🏁 Script executed:
Length of output: 650
🏁 Script executed:
Length of output: 40
@Theoreticallyhugo The diagnostic confirms the logic issue. Since you mentioned it works for you, I suspect one of these scenarios:
You tested on a system without nmcli installed - the inverted logic would attempt GSM detection (though it fails), which might appear to "work"
You have nmcli but GSM detection never actually runs - you might be seeing the ethernet label instead of GSM detection
To verify what's happening on your system, please run these commands:
If you have nmcli installed and see "Would set gsm_connected=false", then GSM detection is currently disabled. The fix ensures GSM detection only runs when nmcli is actually available, which is the intended behavior.
The corrected logic is essential for proper GSM detection when nmcli is present on the system.
🧬 Code Graph Analysis Results
get_tmux_option() {
local option="$1"
local default_value="$2"
local option_value="$(tmux show-option -gqv "$option")"
if [ -z "$option_value" ]; then
echo "$default_value"
else
echo "$option_value"
fi
}