Skip to content
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

[wifi] "Link Quality" field is missing unless "sudo" #82

Open
lihebi opened this issue Sep 6, 2017 · 6 comments
Open

[wifi] "Link Quality" field is missing unless "sudo" #82

lihebi opened this issue Sep 6, 2017 · 6 comments

Comments

@lihebi
Copy link
Contributor

lihebi commented Sep 6, 2017

When I enable wifi in mode-line by "%I", I got "The value NIL is not of type VECTOR" in the mode line.

Diving into the code, I found the following code cause the bug:

(qual (multiple-value-bind (match? sub)
                         (cl-ppcre:scan-to-strings "Link Quality=(\\d+)/(\\d+)" iwconfig)
                       (truncate (float (* (/ (parse-integer (aref sub 0))
                                              (parse-integer (aref sub 1)))
                                           100)))))

The cause is iwconfig does not report "Link Quality" unless run as root.

I'm using a macbook, thus not sure if this is the case for other hardware, but I guess so. The fix might be:
Option 1. remove the Link Quality
Option 2. run the command iwconfig in root priviliage

@kriyative
Copy link
Contributor

@lihebi - is this on MacOS? I'm running with the %I formatter on Ubuntu Linux and it works without root privilege. Your Option 1 is pretty drastic - displaying the signal strength in the modeline is quite useful IMHO. For your Option 2, you could try:

(setq *iwconfig-path* "sudo /sbin/iwconfig")

and edit /etc/sudoers to permit /sbin/iwconfig to run without password.

@PuercoPop
Copy link
Member

Option 3. Use handle-{case,bind} to handle the condition gracefully. Maybe print a red square or a short message in the status bar?

Something along the lines of 9369f5b but in this case it probably wouldn't be a need for interactive handling of the condition as the causes for the module failing are too many.

@lihebi
Copy link
Contributor Author

lihebi commented Sep 9, 2017

Thanks for the help, Ram.
Sorry about the improper description of "option 1", what I meant was to add another option, say %X, to present only ESSID.
I'm using macbook pro as hardware, but running archlinux natively. So it should not be a macOS problem. To be precise, on arch, the iwconfig gives me:

wlp3s0    IEEE 802.11  ESSID:"IASTATE"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 64:F6:9D:66:4F:20   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off

While sudo iwconfig gives me

wlp3s0    IEEE 802.11  ESSID:"IASTATE"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 64:F6:9D:66:4F:20   
          Bit Rate=216.5 Mb/s   Tx-Power=200 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=46/70  Signal level=-64 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

I believe this is a root privilege issue.

I tried your suggestion for setting *iwconfig-path* to a sudo command. It worked, but only if I modify it in the original wifi.lisp file. Setting the variable *iwconfig-path* in my configuration file does not work.
I'm not sure why. Evaluating the *iwconfig-path* in stumpwm gives me unbounded variable error. I do see the variable is exported in package.lisp. I'm learning common lisp, I cannot tell what was exactly happening yet ..

@kriyative
Copy link
Contributor

@lihebi - ah, I think this may help: (setq wifi:*iwconfig-path* "sudo /sbin/iwconfig")

@lihebi
Copy link
Contributor Author

lihebi commented Sep 10, 2017

Here we go, this works, thanks!

@lihebi lihebi closed this as completed Sep 10, 2017
@lihebi lihebi reopened this Sep 22, 2017
@lihebi
Copy link
Contributor Author

lihebi commented Sep 22, 2017

Hi, I encounter some exceptions even if I added sudo privilege. Sometimes (on my archlinux machine), sudo iwconfig still miss "Link Quality" section.

Instead of just printing multiple line "The value NIL is not of type VECTOR" in the mode line, it might be better to just give user options to retrieve link quality or not. For me, I don't think the link quality is important, but I really need to know whether I connected to the right wifi.

I propose two ways:

  1. for backward compatibility, keep %I as ESSID + Quality, and add a new formatter %i as ESSID only. Something like this commit
  2. add %i for ESSID, %j for Quality, so user can use %i %j to achieve the original %I, while also has the flexibility to use %i only

@dmb2 dmb2 changed the title wifi "Link Quality" field is missing unless "sudo" [wifi] "Link Quality" field is missing unless "sudo" May 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants