Compare commits
No commits in common. "master" and "1.1.0" have entirely different histories.
@ -1,3 +0,0 @@
|
|||||||
the .tito/packages directory contains metadata files
|
|
||||||
named after their packages. Each file has the latest tagged
|
|
||||||
version and the project's relative directory.
|
|
@ -1 +0,0 @@
|
|||||||
1.3.2-1 ./
|
|
@ -1,5 +0,0 @@
|
|||||||
[buildconfig]
|
|
||||||
builder = tito.builder.Builder
|
|
||||||
tagger = tito.tagger.VersionTagger
|
|
||||||
changelog_do_not_remove_cherrypick = 0
|
|
||||||
changelog_format = %s (%ae)
|
|
@ -76,10 +76,6 @@ 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
|
||||||
@ -131,9 +127,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` 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.
|
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.
|
||||||
|
|
||||||
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.
|
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`).
|
||||||
|
|
||||||
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,9 +67,6 @@ 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):
|
||||||
@ -105,33 +102,18 @@ 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(
|
||||||
[self.password_executable, "list"], universal_newlines=True
|
[self.password_executable, "list"], universal_newlines=True
|
||||||
).split("\n")[:-1]
|
).split("\n")[:-1]
|
||||||
|
|
||||||
results = list(filter(lambda p: p.startswith(name), password_list))[:5]
|
results = [
|
||||||
|
|
||||||
remaining = 5 - len(results)
|
|
||||||
|
|
||||||
if remaining > 0:
|
|
||||||
fuzzy_results = [
|
|
||||||
e[0]
|
e[0]
|
||||||
for e in process.extract(
|
for e in process.extract(
|
||||||
name, password_list, limit=remaining, scorer=fuzz.token_sort_ratio
|
name, password_list, limit=5, scorer=fuzz.partial_ratio
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
results.extend(fuzzy_results)
|
|
||||||
|
|
||||||
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):
|
||||||
@ -157,76 +139,51 @@ class SearchPassService(dbus.service.Object):
|
|||||||
path = path_join(dir_path, filename)[:-4]
|
path = path_join(dir_path, filename)[:-4]
|
||||||
password_list.append(path)
|
password_list.append(path)
|
||||||
|
|
||||||
results = list(sorted(filter(lambda p: p.startswith(name), password_list)))[:5]
|
results = [
|
||||||
|
|
||||||
remaining = 5 - len(results)
|
|
||||||
|
|
||||||
if remaining > 0:
|
|
||||||
containing_results = list(
|
|
||||||
sorted(filter(lambda p: name in p, password_list))
|
|
||||||
)[:remaining]
|
|
||||||
|
|
||||||
results.extend(containing_results)
|
|
||||||
|
|
||||||
remaining = 5 - len(results)
|
|
||||||
|
|
||||||
if remaining > 0:
|
|
||||||
fuzzy_results = [
|
|
||||||
e[0]
|
e[0]
|
||||||
for e in process.extract(
|
for e in process.extract(
|
||||||
name, password_list, limit=remaining, scorer=fuzz.token_sort_ratio
|
name, password_list, limit=5, scorer=fuzz.partial_ratio
|
||||||
)
|
)
|
||||||
]
|
]
|
||||||
|
|
||||||
results.extend(fuzzy_results)
|
|
||||||
|
|
||||||
if field == "otp":
|
if field == "otp":
|
||||||
results = [f"otp {r}" for r in results]
|
results = [f"otp {r}" for r in results]
|
||||||
elif field is not None:
|
elif field is not None:
|
||||||
results = [f":{field} {r}" for r in results]
|
results = [f":{field} {r}" for r in results]
|
||||||
return results
|
return results
|
||||||
|
|
||||||
def get_value_from_output(self, output, field=None):
|
|
||||||
if field is not None:
|
|
||||||
match = re.search(
|
|
||||||
rf"^{field}:\s*(?P<value>.+?)$", output, flags=re.I | re.M
|
|
||||||
)
|
|
||||||
if match:
|
|
||||||
value = match.group("value")
|
|
||||||
else:
|
|
||||||
raise RuntimeError(
|
|
||||||
f"The field {field} was not found in the password entry."
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
value = output.split("\n", 1)[0]
|
|
||||||
return value
|
|
||||||
|
|
||||||
def send_password_to_gpaste(self, base_args, name, field=None):
|
def send_password_to_gpaste(self, base_args, name, field=None):
|
||||||
gpaste = self.session_bus.get_object(
|
gpaste = self.session_bus.get_object(
|
||||||
"org.gnome.GPaste.Daemon", "/org/gnome/GPaste"
|
"org.gnome.GPaste.Daemon", "/org/gnome/GPaste"
|
||||||
)
|
)
|
||||||
|
|
||||||
output = subprocess.check_output(base_args + [name], universal_newlines=True)
|
output = subprocess.check_output(base_args + [name], universal_newlines=True)
|
||||||
value = self.get_value_from_output(output, field)
|
if field is not None:
|
||||||
|
match = re.search(
|
||||||
|
rf"^{field}:\s*(?P<value>.+?)$", output, flags=re.I | re.M
|
||||||
|
)
|
||||||
|
if match:
|
||||||
|
password = match.group("value")
|
||||||
|
else:
|
||||||
|
raise RuntimeError(f"The field {field} was not found in the pass file.")
|
||||||
|
else:
|
||||||
|
password = output.split("\n", 1)[0]
|
||||||
try:
|
try:
|
||||||
gpaste.AddPassword(name, value, dbus_interface="org.gnome.GPaste1")
|
gpaste.AddPassword(name, password, dbus_interface="org.gnome.GPaste1")
|
||||||
except dbus.DBusException:
|
except dbus.DBusException:
|
||||||
gpaste.AddPassword(name, value, dbus_interface="org.gnome.GPaste2")
|
gpaste.AddPassword(name, password, dbus_interface="org.gnome.GPaste2")
|
||||||
|
|
||||||
def send_password_to_native_clipboard(self, base_args, name, field=None):
|
def send_password_to_native_clipboard(self, base_args, name, field=None):
|
||||||
if self.password_mode == "bw":
|
|
||||||
output = subprocess.check_output(
|
|
||||||
base_args + [name], universal_newlines=True
|
|
||||||
)
|
|
||||||
value = self.get_value_from_output(output, field)
|
|
||||||
p1 = subprocess.run(self.clipboard_executable, input=value, text=True)
|
|
||||||
if p1.returncode:
|
|
||||||
raise RuntimeError(
|
|
||||||
f"Error while running copying to clipboard: got return code: {p1.returncode}."
|
|
||||||
)
|
|
||||||
else:
|
|
||||||
if field is not None:
|
if field is not None:
|
||||||
raise RuntimeError("This feature requires GPaste.")
|
raise RuntimeError("This feature requires GPaste.")
|
||||||
|
|
||||||
|
if self.password_mode == "bw":
|
||||||
|
p1 = subprocess.Popen(base_args + [name], stdout=subprocess.PIPE)
|
||||||
|
p2 = subprocess.run(self.clipboard_executable, stdin=p1.stdout)
|
||||||
|
if p1.returncode or p2.returncode:
|
||||||
|
raise RuntimeError(
|
||||||
|
f"Error while running rbw: got return codes: {p1.returncode} {p2.returncode}."
|
||||||
|
)
|
||||||
|
else:
|
||||||
result = subprocess.run(base_args + ["-c", name])
|
result = subprocess.run(base_args + ["-c", name])
|
||||||
if result.returncode:
|
if result.returncode:
|
||||||
raise RuntimeError(
|
raise RuntimeError(
|
||||||
@ -234,21 +191,17 @@ class SearchPassService(dbus.service.Object):
|
|||||||
)
|
)
|
||||||
|
|
||||||
def send_password_to_clipboard(self, name):
|
def send_password_to_clipboard(self, name):
|
||||||
if name.startswith(":"):
|
|
||||||
field, name = name.split(" ", 1)
|
|
||||||
field = field[1:]
|
|
||||||
else:
|
|
||||||
field = None
|
field = None
|
||||||
|
|
||||||
if self.password_mode == "bw":
|
if self.password_mode == "bw":
|
||||||
base_args = [self.password_executable, "get", "--full"]
|
base_args = [self.password_executable, "get"]
|
||||||
elif name.startswith("otp "):
|
elif name.startswith("otp "):
|
||||||
base_args = [self.password_executable, "otp", "code"]
|
base_args = [self.password_executable, "otp", "code"]
|
||||||
name = name[4:]
|
name = name[4:]
|
||||||
field = None
|
|
||||||
else:
|
else:
|
||||||
base_args = [self.password_executable, "show"]
|
base_args = [self.password_executable, "show"]
|
||||||
|
if name.startswith(":"):
|
||||||
|
field, name = name.split(" ", 1)
|
||||||
|
field = field[1:]
|
||||||
try:
|
try:
|
||||||
try:
|
try:
|
||||||
self.send_password_to_gpaste(base_args, name, field)
|
self.send_password_to_gpaste(base_args, name, field)
|
||||||
@ -267,8 +220,6 @@ 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"
|
||||||
|
@ -1,23 +1,25 @@
|
|||||||
Name: gnome-pass-search-provider
|
Name: gnome-pass-search-provider
|
||||||
Version: 1.3.3
|
Version: master
|
||||||
Release: %autorelease
|
Release: 1
|
||||||
Summary: Gnome Shell search provider for zx2c4/pass
|
|
||||||
License: GPL-3.0+
|
License: GPL-3.0+
|
||||||
Url: https://git.dm1sh.ru/dm1sh/%{name}
|
Summary: Gnome Shell search provider for zx2c4/pass
|
||||||
Source0: https://git.dm1sh.ru/dm1sh/%{name}/archive/%{version}.tar.gz
|
Url: https://github.com/jle64/gnome-pass-search-provider
|
||||||
|
Source: https://github.com/jle64/%{name}/archive/master.tar.gz
|
||||||
Requires: gnome-shell
|
Requires: gnome-shell
|
||||||
Requires: (pass or gopass)
|
Requires: pass
|
||||||
Requires: python3-gobject
|
Requires: python3-gobject
|
||||||
Requires: python3-dbus
|
Requires: python3-dbus
|
||||||
Requires: python3-fuzzywuzzy
|
Requires: python3-fuzzywuzzy
|
||||||
Requires: python3-Levenshtein
|
Requires: python3-Levenshtein
|
||||||
|
BuildRoot: %{_tmppath}/%{name}-%{version}-build
|
||||||
|
|
||||||
|
%global debug_package %{nil}
|
||||||
|
|
||||||
%description
|
%description
|
||||||
A Gnome Shell passwords search provider for zx2c4/pass (passwordstore.org) or compatibles and Bitwarden/Vaultwarden that sends passwords to clipboard (or GPaste).
|
A Gnome Shell passwords search provider for zx2c4/pass (passwordstore.org) or compatibles and Bitwarden/Vaultwarden that sends passwords to clipboard (or GPaste).
|
||||||
|
|
||||||
%prep
|
%prep
|
||||||
%autosetup -n %{name}
|
%setup -q -n %{name}-%{version}
|
||||||
|
|
||||||
%define debug_package %{nil}
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
|
|
||||||
@ -27,13 +29,10 @@ sed -i -e 's|LIBDIR=|LIBDIR=$RPM_BUILD_ROOT|' install.sh
|
|||||||
./install.sh
|
./install.sh
|
||||||
|
|
||||||
%files
|
%files
|
||||||
|
%defattr(-,root,root,-)
|
||||||
%doc README.md
|
%doc README.md
|
||||||
%license LICENSE
|
|
||||||
%{_prefix}/lib/gnome-pass-search-provider/gnome-pass-search-provider.py
|
%{_prefix}/lib/gnome-pass-search-provider/gnome-pass-search-provider.py
|
||||||
%{_prefix}/lib/systemd/user/org.gnome.Pass.SearchProvider.service
|
%{_prefix}/lib/systemd/user/org.gnome.Pass.SearchProvider.service
|
||||||
%{_prefix}/share/dbus-1/services/org.gnome.Pass.SearchProvider.service
|
%{_prefix}/share/dbus-1/services/org.gnome.Pass.SearchProvider.service
|
||||||
%{_prefix}/share/applications/org.gnome.Pass.SearchProvider.desktop
|
%{_prefix}/share/applications/org.gnome.Pass.SearchProvider.desktop
|
||||||
%{_prefix}/share/gnome-shell/search-providers/org.gnome.Pass.SearchProvider.ini
|
%{_prefix}/share/gnome-shell/search-providers/org.gnome.Pass.SearchProvider.ini
|
||||||
|
|
||||||
%changelog
|
|
||||||
%autochangelog
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user