removed mkbackup script, refactored all script files to use pkgs.writeShellApplication rather than pkgs.writeShellScriptBin

This commit is contained in:
pagedmov
2024-11-06 18:17:29 -05:00
parent ad22e5a0b1
commit a53bae9870
18 changed files with 497 additions and 416 deletions

View File

@@ -1,35 +1,42 @@
{
self,
pkgs,
...
pkgs
}:
pkgs.writeShellScriptBin "keyring" ''
#!/run/current-system/sw/bin/bash
pkgs.writeShellApplication {
name = "keyring";
runtimeInputs = with pkgs; [
pass
findutils
ripgrep
fzf
wl-clipboard
coreutils
];
text = ''
#!/run/current-system/sw/bin/bash
# prevent multiple instances, conditional check happens in the hyprland bind
touch /tmp/keyringfile
trap "[ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile" EXIT SIGHUP SIGINT
# prevent multiple instances, conditional check happens in the hyprland bind
touch /tmp/keyringfile
trap "[ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile" EXIT SIGHUP SIGINT
# get passwords from password store, remove .password store/ prefix and .gpg suffix, exlude .gpg-id file, open results in fzf
pass_string=$(find $HOME/.password-store -type f | sed 's|.*/.password-store/||; s|\.gpg$||' | sed 's|^\([^/]*\)|\x1b[32m\1\x1b[0m|' | rg -v "\.git|.gpg-id" | sort -r | fzf --border --border-label="$(whoami)'s keyring" --ansi --layout=reverse)
# get passwords from password store, remove .password store/ prefix and .gpg suffix, exlude .gpg-id file, open results in fzf
pass_string=$(find "$HOME"/.password-store -type f | sed 's|.*/.password-store/||; s|\.gpg$||' | sed 's|^\([^/]*\)|\x1b[32m\1\x1b[0m|' | rg -v "\.git|.gpg-id" | sort -r | fzf --border --border-label="$(whoami)'s keyring" --ansi --layout=reverse)
[ $? = 0 ] || { [ -f /tmp/keyringfile ] && /run/current-system/sw/bin/rm /tmp/keyringfile; exit 1; }
# prevents cliphist from writing passwords to the clipboard history
pkill -STOP wl-paste
# prevents cliphist from writing passwords to the clipboard history
pkill -STOP wl-paste
# copy password
pass -c "$pass_string" > /dev/null
echo "Password copied. Clearing clipboard in 10 seconds."
# copy password
pass -c "$pass_string" > /dev/null
echo "Password copied. Clearing clipboard in 10 seconds."
# start a timer for 10 seconds, clear clipboard, resume cliphist tracking
nohup bash <<-EOF > /dev/null &
sleep 10
wl-copy -c
pkill -CONT wl-paste
EOF
# start a timer for 10 seconds, clear clipboard, resume cliphist tracking
nohup bash <<-EOF > /dev/null &
sleep 10
wl-copy -c
pkill -CONT wl-paste
EOF
/run/current-system/sw/bin/rm /tmp/keyringfile
sleep 0.5
exit 0
''
/run/current-system/sw/bin/rm /tmp/keyringfile
sleep 0.5
exit 0
'';
}