defname / rofi-iwd-wifi-menu

Minimalistic WiFi network chooser for iwd using rofi
GNU General Public License v3.0
61 stars 2 forks source link

No such file or directory: 'rfkill' #2

Closed vykng closed 1 year ago

vykng commented 1 year ago

Getting this error when calling the script, rfkill is running. Running fedora 36.

Traceback (most recent call last): File "/home/sdf/rofi-iwd-wifi-menu/./iwdrofimenu.py", line 85, in iwdrofimenu.Main(DEVICE, args) File "/home/sdf/rofi-iwd-wifi-menu/iwdrofimenu/main.py", line 73, in init if self.wifi_is_blocked(): File "/home/sdf/rofi-iwd-wifi-menu/iwdrofimenu/main.py", line 137, in wifi_is_blocked result = subprocess.run(["rfkill", "-n", "-r"], File "/usr/lib64/python3.10/subprocess.py", line 503, in run with Popen(*popenargs, **kwargs) as process: File "/usr/lib64/python3.10/subprocess.py", line 971, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/lib64/python3.10/subprocess.py", line 1847, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) FileNotFoundError: [Errno 2] No such file or directory: 'rfkill'

defname commented 1 year ago

Hi, thanks for the info. It looks, like rfkill isn't installed. I forgot that this is also a dependency. It is a common tool to enable/disable network devices. It should work if you install it (or try to run rfkill in the terminal first to be sure).

dnf install rfkill

should install it.

I will update the readme and the aur package asap.

vykng commented 1 year ago

I have rfkill already running. I checked to make sure prior to submitting the issue. The rfkill command can also be executed from terminal.

defname commented 1 year ago

hmm, I don't have a explanation for this. Maybe the PATH environment variable python uses is somehow different, from your terminal's one.

Could you try to change "rfkill" to the complete path to rfkill (on my system it is "/bin/rfkill") in Line 137 in "/home/sdf/rofi-iwd-wifi-menu/iwdrofimenu/main.py" There should be the line

result = subprocess.run(["rfkill", "-n", "-r"],

Change it to

result = subprocess.run(["/bin/rfkill", "-n", "-r"],

hopefully it works then.

An other reason could be that rfkill is not accessable for normal users. Is it possible to use it as user or do you have to be root?

vykng commented 1 year ago

Changing it to the full path actually worked, on fedora it is /sbin/rfkill. Thanks.

defname commented 1 year ago

I just added a config option for this problem. You can set rfkill_cmd in the general section of the config file to specify the full path of rfkill.

[general]
rfkill_cmd = /sbin/rfkill

the default value is still rfkill assuming it's found in PATH

vykng commented 1 year ago

Thanks.