Better wl-clipedit and rbw-fzf
This commit is contained in:
parent
ca4e245fd0
commit
1deb75a769
6 changed files with 95 additions and 3 deletions
|
|
@ -118,6 +118,7 @@
|
|||
inherit
|
||||
(pkgs)
|
||||
keyboard-switch
|
||||
rbw-fzf
|
||||
wl-clipedit
|
||||
wl-lockscreen
|
||||
wl-update-background
|
||||
|
|
@ -178,6 +179,7 @@
|
|||
packages = self: _super: {
|
||||
keyboard-switch = self.callPackage ./pkgs/keyboard-switch { };
|
||||
wl-clipedit = self.callPackage ./pkgs/wl-clipedit { };
|
||||
rbw-fzf = self.callPackage ./pkgs/rbw-fzf { };
|
||||
wl-lockscreen = self.callPackage ./pkgs/wl-lockscreen { };
|
||||
wl-update-background = self.callPackage ./pkgs/wl-update-background { };
|
||||
};
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ in
|
|||
hyprpaper
|
||||
networkmanagerapplet
|
||||
playerctl
|
||||
rbw-fzf
|
||||
sirula
|
||||
# swaylock
|
||||
swww
|
||||
|
|
@ -228,7 +229,8 @@ in
|
|||
"SUPER, P, pseudo, # dwindle"
|
||||
"SUPER, J, togglesplit, # dwindle"
|
||||
"SUPER ALT, E, exec, wofi-emoji"
|
||||
"SUPER ALT, P, exec, wl-clipedit"
|
||||
"SUPER ALT, P, exec, foot wl-clipedit"
|
||||
"SUPER ALT, I, exec, foot rbw-fzf"
|
||||
"SUPER ALT, B, exec, systemctl --user reload-or-restart wl-update-background"
|
||||
",Print, exec, grimblast copy"
|
||||
"SHIFT, Print, exec, grimblast copy area"
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@
|
|||
pavucontrol
|
||||
procps
|
||||
protonvpn-gui
|
||||
rbw
|
||||
# spotify
|
||||
telegram-desktop
|
||||
wiremix
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
pavucontrol
|
||||
procps
|
||||
protonvpn-gui
|
||||
rbw
|
||||
# spotify
|
||||
telegram-desktop
|
||||
thunderbird
|
||||
|
|
|
|||
87
pkgs/rbw-fzf/default.nix
Normal file
87
pkgs/rbw-fzf/default.nix
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
{ writeShellScriptBin
|
||||
, lib
|
||||
, wl-clipboard
|
||||
, rbw
|
||||
, fzf
|
||||
, pinentry-gtk2
|
||||
}:
|
||||
writeShellScriptBin "rbw-fzf" ''
|
||||
PATH=$PATH:"${ lib.makeBinPath [ fzf rbw wl-clipboard pinentry-gtk2 ] }"
|
||||
|
||||
# Check if the selected entry exists
|
||||
get_entry () {
|
||||
NAME=$(rbw ls | fzf)
|
||||
|
||||
if [ $? -eq 1 ]; then
|
||||
printf '%s\n' "Please, select a valid entry."
|
||||
exit 1
|
||||
elif [ -z "$NAME" ]; then
|
||||
printf '%s\n' "No entry selected, quitting."
|
||||
exit 0
|
||||
else
|
||||
get_username
|
||||
fi
|
||||
}
|
||||
|
||||
get_username () {
|
||||
# If the selected entry has a username, copy it to clipboard and ask if user also wants to copy the password
|
||||
USERNAME=$(rbw get --field username "$NAME"|sed 's/Username: //')
|
||||
if [ -n "$USERNAME" ]; then
|
||||
wl-copy -n "$USERNAME"
|
||||
printf '%s\n' "\"$NAME\" username copied to clipboard, press enter if you also want the password"
|
||||
read ans
|
||||
get_password
|
||||
else
|
||||
printf '%s\n' "\"$NAME\" doesn't have a username, copying password instead"
|
||||
get_password
|
||||
fi
|
||||
}
|
||||
|
||||
get_password () {
|
||||
# Copy password to clipboard
|
||||
rbw get --clipboard "$NAME"
|
||||
printf '%s\n' "\"$NAME\" password copied to clipboard"
|
||||
|
||||
# Wait 10 seconds before clearing the clipboard, you can raise or decrease the wait time by changing the WTIME variable value
|
||||
WTIME=10
|
||||
while [ $WTIME -gt 0 ]; do
|
||||
if [ $WTIME -gt 1 ]; then
|
||||
printf '%s\n' "Clearing password from clipboard in $WTIME seconds"
|
||||
else
|
||||
printf '%s\n' "Clearing password from clipboard in $WTIME second"
|
||||
fi
|
||||
sleep 1
|
||||
WTIME=$((WTIME-1))
|
||||
done
|
||||
|
||||
# Clear password from clipboard
|
||||
wl-copy -c
|
||||
|
||||
get_notes
|
||||
}
|
||||
|
||||
get_notes () {
|
||||
NOTE=$(rbw get --field notes "$NAME")
|
||||
if [ -n "$NOTE" ]; then
|
||||
printf '%s\n\n' "\"$NAME\" notes:"
|
||||
printf '%s\n\n' "$NOTE"
|
||||
printf '%s\n' "Press enter to exit."
|
||||
read ans
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Check if fzf, rbw and wl-copy exists in $PATH
|
||||
for binary in rbw fzf wl-copy; do
|
||||
command -v $binary 2>/dev/null 1>&2 || \
|
||||
{ printf '%s\n' "$binary not found in \$PATH, make sure to install it before running this script" ; exit 1 ;}
|
||||
done
|
||||
|
||||
# Unlock the vault before running the script
|
||||
if [ ! rbw unlocked 2>/dev/null 1>&2 ]; then
|
||||
rbw unlock
|
||||
fi
|
||||
|
||||
get_entry
|
||||
''
|
||||
|
||||
|
|
@ -3,7 +3,6 @@
|
|||
, wl-clipboard
|
||||
, coreutils
|
||||
, editor ? "hx"
|
||||
, terminal-command ? "kitty -e"
|
||||
,
|
||||
}:
|
||||
# 64 │ function clipcopy() { xclip -in -selection clipboard < "${1:-/dev/stdin}"; }
|
||||
|
|
@ -17,7 +16,7 @@ writeShellScriptBin "wl-clipedit" ''
|
|||
}"
|
||||
tmp_file=$(mktemp)
|
||||
wl-paste -t 'text/plain;charset=utf-8' -n > "$tmp_file"
|
||||
${terminal-command} ''${VISUAL:-''${EDITOR:-${editor}}} "$tmp_file"
|
||||
''${VISUAL:-''${EDITOR:-${editor}}} "$tmp_file"
|
||||
wl-copy -t 'text/plain;charset=utf-8' -n < "$tmp_file"
|
||||
rm "$tmp_file"
|
||||
''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue