Skip to content

Commit 0bdef71

Browse files
committed
Provide actual locations to the 1Password lib
The possible list of locations is built based on operating system
1 parent ea77aa1 commit 0bdef71

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/onepassword/desktop_core.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,37 @@
11
import ctypes
22
import json
33
import os
4+
import platform
45
import base64
6+
from pathlib import Path
57
from ctypes import c_uint8, c_size_t, c_int32, POINTER, byref, c_void_p
68
from .core import UniffiCore
79
from onepassword.errors import raise_typed_exception
810

911

1012
def find_1password_lib_path():
11-
locations = [
12-
"/Users/andititu/core/target/debug/libop_sdk_ipc_client.dylib"
13-
]
13+
os_name = platform.system()
14+
15+
# Define paths based on OS
16+
if os_name == "Darwin": # macOS
17+
locations = [
18+
"/Applications/1Password.app/Contents/Frameworks/libop_sdk_ipc_client.dylib",
19+
str(Path.home() / "Applications/1Password.app/Contents/Frameworks/libop_sdk_ipc_client.dylib"),
20+
]
21+
elif os_name == "Linux":
22+
locations = [
23+
"/usr/bin/1password/libop_sdk_ipc_client.so",
24+
"/opt/1password/libop_sdk_ipc_client.so",
25+
"/snap/bin/1password/libop_sdk_ipc_client.so",
26+
]
27+
elif os_name == "Windows":
28+
locations = [
29+
r"C:\Program Files\1Password\op_sdk_ipc_client.dll",
30+
r"C:\Program Files (x86)\1Password\op_sdk_ipc_client.dll",
31+
str(Path.home() / r"AppData\Local\1Password\op_sdk_ipc_client.dll"),
32+
]
33+
else:
34+
raise OSError(f"Unsupported operating system: {os_name}")
1435

1536
for lib_path in locations:
1637
if os.path.exists(lib_path):

0 commit comments

Comments
 (0)