--- hid/__init__.py.orig	2022-12-15 21:22:07.000000000 +0600
+++ hid/__init__.py	2022-12-15 21:49:43.000000000 +0600
@@ -1,12 +1,13 @@
 import os
 import ctypes
+from ctypes import util
 import atexit
 
 __all__ = ['HIDException', 'DeviceInfo', 'Device', 'enumerate']
 
 
 hidapi = None
-library_paths = (
+library_names = (
     'libhidapi-hidraw.so',
     'libhidapi-hidraw.so.0',
     'libhidapi-libusb.so',
@@ -15,18 +16,20 @@
     'libhidapi-iohidmanager.so.0',
     'libhidapi.dylib',
     'hidapi.dll',
-    'libhidapi-0.dll'
+    'libhidapi-0.dll',
 )
 
-for lib in library_paths:
+for libname in library_names:
     try:
-        hidapi = ctypes.cdll.LoadLibrary(lib)
-        break
+        libpath = util.find_library(libname)
+        if libpath:
+            hidapi = ctypes.cdll.LoadLibrary(libpath)
+            break
     except OSError:
         pass
 else:
     error = "Unable to load any of the following libraries:{}"\
-        .format(' '.join(library_paths))
+        .format(' '.join(library_names))
     raise ImportError(error)
 
 
