Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
005a161bb1 | |||
973ad49c33 | |||
8a973038ab | |||
2ced9fe955 | |||
6dc332843d | |||
102b7e044a | |||
92270735c5 | |||
e98543973a | |||
62b63dc3e1 | |||
d302782073 | |||
ff2d5600eb |
@ -76,6 +76,10 @@ pin: 123456
|
|||||||
|
|
||||||
To copy the pin start the search with `:pin` and for the username with `:user`.
|
To copy the pin start the search with `:pin` and for the username with `:user`.
|
||||||
|
|
||||||
|
## Disabling notifications
|
||||||
|
|
||||||
|
Set the `DISABLE_NOTIFICATIONS` environment variable to `True`.
|
||||||
|
|
||||||
# Alternative password providers
|
# Alternative password providers
|
||||||
|
|
||||||
## Gopass and other pass-compatible tools
|
## Gopass and other pass-compatible tools
|
||||||
@ -127,9 +131,9 @@ This implements the `org.gnome.Shell.SearchProvider2` D-Bus API and has been tes
|
|||||||
|
|
||||||
## Environment variables have no effect
|
## Environment variables have no effect
|
||||||
|
|
||||||
If you are configuring `pass` through environment variables, such as `PASSWORD_STORE_DIR`, make sure to set them in a way that will propagate to the search provider executable, not just in your shell.
|
If you are configuring `pass` using environment variables, such as `PASSWORD_STORE_DIR`, make sure to set them in a way that will propagate to the search provider executable, not just in your shell.
|
||||||
|
|
||||||
Setting them in `~/.profile` should be sufficient, but keep in mind that stuff in shell-specific files such as `~/.bashrc` only affects the command-line shell and will not propagate to the script. On systemd-based OSes, you can also directly set them in `~/.config/environment.d/*.conf` (see `man environment.d`).
|
On systemd-based OSes, you can directly set them in `~/.config/environment.d/*.conf` (see `man environment.d`). On other systems, setting them in `~/.profile` should be sufficient, but keep in mind that some shell-specific files such as `~/.bashrc` might be only loaded in non-login interactive shells and will thus not propagate to the script.
|
||||||
|
|
||||||
If your values have no effect, make sure they propagate to the script environment. You can check this by displaying the process environment with `ps` and looking for your values here:
|
If your values have no effect, make sure they propagate to the script environment. You can check this by displaying the process environment with `ps` and looking for your values here:
|
||||||
```
|
```
|
||||||
|
@ -67,6 +67,9 @@ class SearchPassService(dbus.service.Object):
|
|||||||
self.password_executable = getenv("PASSWORD_EXECUTABLE") or "pass"
|
self.password_executable = getenv("PASSWORD_EXECUTABLE") or "pass"
|
||||||
self.password_mode = getenv("PASSWORD_MODE") or "pass"
|
self.password_mode = getenv("PASSWORD_MODE") or "pass"
|
||||||
self.clipboard_executable = getenv("CLIPBOARD_EXECUTABLE") or "wl-copy"
|
self.clipboard_executable = getenv("CLIPBOARD_EXECUTABLE") or "wl-copy"
|
||||||
|
self.disable_notifications = (
|
||||||
|
getenv("DISABLE_NOTIFICATIONS", "false").lower() == "true"
|
||||||
|
)
|
||||||
|
|
||||||
@dbus.service.method(in_signature="sasu", **sbn)
|
@dbus.service.method(in_signature="sasu", **sbn)
|
||||||
def ActivateResult(self, id, terms, timestamp):
|
def ActivateResult(self, id, terms, timestamp):
|
||||||
@ -102,6 +105,11 @@ class SearchPassService(dbus.service.Object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def get_bw_result_set(self, terms):
|
def get_bw_result_set(self, terms):
|
||||||
|
if terms[0].startswith(":"):
|
||||||
|
field = terms[0][1:]
|
||||||
|
terms = terms[1:]
|
||||||
|
else:
|
||||||
|
field = None
|
||||||
name = "".join(terms)
|
name = "".join(terms)
|
||||||
|
|
||||||
password_list = subprocess.check_output(
|
password_list = subprocess.check_output(
|
||||||
@ -114,6 +122,8 @@ class SearchPassService(dbus.service.Object):
|
|||||||
name, password_list, limit=5, scorer=fuzz.partial_ratio
|
name, password_list, limit=5, scorer=fuzz.partial_ratio
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
if field is not None:
|
||||||
|
results = [f":{field} {r}" for r in results]
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_pass_result_set(self, terms):
|
def get_pass_result_set(self, terms):
|
||||||
@ -191,17 +201,21 @@ class SearchPassService(dbus.service.Object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def send_password_to_clipboard(self, name):
|
def send_password_to_clipboard(self, name):
|
||||||
field = None
|
|
||||||
if self.password_mode == "bw":
|
|
||||||
base_args = [self.password_executable, "get"]
|
|
||||||
elif name.startswith("otp "):
|
|
||||||
base_args = [self.password_executable, "otp", "code"]
|
|
||||||
name = name[4:]
|
|
||||||
else:
|
|
||||||
base_args = [self.password_executable, "show"]
|
|
||||||
if name.startswith(":"):
|
if name.startswith(":"):
|
||||||
field, name = name.split(" ", 1)
|
field, name = name.split(" ", 1)
|
||||||
field = field[1:]
|
field = field[1:]
|
||||||
|
else:
|
||||||
|
field = None
|
||||||
|
|
||||||
|
if self.password_mode == "bw":
|
||||||
|
base_args = [self.password_executable, "get", "--full"]
|
||||||
|
elif name.startswith("otp "):
|
||||||
|
base_args = [self.password_executable, "otp", "code"]
|
||||||
|
name = name[4:]
|
||||||
|
field = None
|
||||||
|
else:
|
||||||
|
base_args = [self.password_executable, "show"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
self.send_password_to_gpaste(base_args, name, field)
|
self.send_password_to_gpaste(base_args, name, field)
|
||||||
@ -220,6 +234,8 @@ class SearchPassService(dbus.service.Object):
|
|||||||
self.notify("Failed to copy password or field!", body=str(e), error=True)
|
self.notify("Failed to copy password or field!", body=str(e), error=True)
|
||||||
|
|
||||||
def notify(self, message, body="", error=False):
|
def notify(self, message, body="", error=False):
|
||||||
|
if not error and self.disable_notifications:
|
||||||
|
return
|
||||||
try:
|
try:
|
||||||
self.session_bus.get_object(
|
self.session_bus.get_object(
|
||||||
"org.freedesktop.Notifications", "/org/freedesktop/Notifications"
|
"org.freedesktop.Notifications", "/org/freedesktop/Notifications"
|
||||||
|
Reference in New Issue
Block a user