mirror of
https://github.com/Misterio77/Foundry.git
synced 2026-08-24 10:04:09 -05:00
add autotype to pass-wofi
This commit is contained in:
@@ -233,7 +233,10 @@ in {
|
||||
lib.optionals config.programs.password-store.enable [
|
||||
",Scroll_Lock,exec,${pass-wofi}" # fn+k
|
||||
",XF86Calculator,exec,${pass-wofi}" # fn+f12
|
||||
"SUPER,semicolon,exec,pass-wofi"
|
||||
"SUPER,semicolon,exec,${pass-wofi}"
|
||||
"SHIFT,Scroll_Lock,exec,${pass-wofi} fill" # fn+k
|
||||
"SHIFT,XF86Calculator,exec,${pass-wofi} fill" # fn+f12
|
||||
"SHIFTSUPER,semicolon,exec,${pass-wofi} fill"
|
||||
]
|
||||
)
|
||||
);
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
{
|
||||
lib,
|
||||
pkgs,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
makeWrapper,
|
||||
pass,
|
||||
jq,
|
||||
wofi,
|
||||
libnotify,
|
||||
wl-clipboard,
|
||||
wtype,
|
||||
findutils,
|
||||
gnused,
|
||||
coreutils,
|
||||
}:
|
||||
with lib;
|
||||
stdenv.mkDerivation {
|
||||
name = "pass-wofi";
|
||||
version = "1.0";
|
||||
@@ -29,12 +27,13 @@ with lib;
|
||||
install -Dm 0755 $src $out/bin/pass-wofi
|
||||
wrapProgram $out/bin/pass-wofi --prefix PATH ':' \
|
||||
"${
|
||||
makeBinPath [
|
||||
lib.makeBinPath [
|
||||
pass
|
||||
jq
|
||||
wofi
|
||||
libnotify
|
||||
wl-clipboard
|
||||
wtype
|
||||
findutils
|
||||
gnused
|
||||
coreutils
|
||||
@@ -44,8 +43,8 @@ with lib;
|
||||
|
||||
meta = {
|
||||
description = "A wofi graphical menu for pass";
|
||||
license = licenses.mit;
|
||||
platforms = platforms.all;
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.all;
|
||||
mainProgram = "pass-wofi";
|
||||
};
|
||||
}
|
||||
|
||||
+29
-10
@@ -23,31 +23,50 @@ selected=$(find -L . -not -path '*\/.*' -path "*.gpg" -type f -printf '%P\n' | \
|
||||
username=$(echo "$selected" | cut -d '/' -f2)
|
||||
url=$(echo "$selected" | cut -d '/' -f1)
|
||||
|
||||
fields="Password
|
||||
if [ -n "$1" ]; then
|
||||
field="$1"
|
||||
shift 1
|
||||
else
|
||||
fields="Password
|
||||
Username
|
||||
OTP
|
||||
URL"
|
||||
URL
|
||||
Fill"
|
||||
|
||||
field=$(printf "$fields" | wofi -S dmenu) || field="Password"
|
||||
field=$(printf "$fields" | wofi -S dmenu) || field="password"
|
||||
fi
|
||||
|
||||
case "$field" in
|
||||
"Password")
|
||||
case "${field,,}" in
|
||||
"password")
|
||||
value="$(pass "$selected" | head -n 1)" && [ -n "$value" ] || \
|
||||
{ notify-send "Error" "No password for $selected" -i error -t 6000; exit 3; }
|
||||
;;
|
||||
"Username")
|
||||
"username")
|
||||
value="$username"
|
||||
;;
|
||||
"URL")
|
||||
"url")
|
||||
value="$url"
|
||||
;;
|
||||
"OTP")
|
||||
"otp")
|
||||
value="$(pass otp "$selected")" || \
|
||||
{ notify-send "Error" "No OTP for $selected" -i error -t 6000; exit 3; }
|
||||
;;
|
||||
"fill")
|
||||
password="$(pass "$selected" | head -n 1)" && [ -n "$password" ] || \
|
||||
{ notify-send "Error" "No password for $selected" -i error -t 6000; exit 3; }
|
||||
wtype "$username"
|
||||
wtype -k tab
|
||||
wtype "$password"
|
||||
if otp="$(pass otp "$selected")" && [ -n "$otp" ]; then
|
||||
field="OTP"
|
||||
value="$otp"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
exit 4
|
||||
esac
|
||||
|
||||
wl-copy "$value"
|
||||
notify-send "Copied $field:" "$value" -i edit-copy -t 4000
|
||||
if [ -n "$value" ]; then
|
||||
wl-copy "$value"
|
||||
notify-send "Copied $field:" "$value" -i edit-copy -t 4000
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user