diff options
author | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-30 08:23:45 +0200 |
---|---|---|
committer | Raymaekers Luca <raymaekers.luca@gmail.com> | 2023-08-30 08:23:45 +0200 |
commit | 3f8594ee04d2a3d9b40a259daf3b564a53b510fa (patch) | |
tree | 66ed50643cdc81af813b5771a99732d0f78bb618 /bin/guiscripts | |
parent | 45d39ae0c67bb086f4df0c366b251e06c888408d (diff) | |
parent | 333aaf38c66a1e4ba41d3acea38b21613c0075b2 (diff) |
Merge branch 'main' of db:dotfiles
Diffstat (limited to 'bin/guiscripts')
-rwxr-xr-x | bin/guiscripts/keyadd | 45 | ||||
-rwxr-xr-x | bin/guiscripts/startw | 1 |
2 files changed, 32 insertions, 14 deletions
diff --git a/bin/guiscripts/keyadd b/bin/guiscripts/keyadd index 96d6d03..cb81efe 100755 --- a/bin/guiscripts/keyadd +++ b/bin/guiscripts/keyadd @@ -22,9 +22,24 @@ die () echo "$1" >&2 } +notify () +{ + notify-send -t 1000 "keyadd" "$1" + die "$1" +} + + SSHFOLDER="$HOME/.ssh" -if test -z "${key:=$1}" +# Test if can connect to ssh-agent +ssh-add -l > /dev/null 2>&1 +if [ $? -gt 1 ] # ignore if there are no identities +then + notify "Could not connect to agent." + exit 1 +fi + +if [ -z "${key:=$1}" ] then key="$(find "$SSHFOLDER" -iname "*.pub" | sed "s,$SSHFOLDER/,," | # Clean @@ -35,24 +50,26 @@ else fi die "key: $key" -test ! -f "$SSHFOLDER/$key" && exit 1 +[ ! -f "$SSHFOLDER/$key" ] && exit 1 -HOST=$(hostnamectl hostname | sed 's/forlure/fl/;s/montecristo/mc/') -die "HOST: $HOST" +HOST=$(hostnamectl hostname) +die "host: $HOST" if [ "$1" = "-d" ] then - ssh-add -d - < "$SSHFOLDER"/$key.pub && - notify-send "$0" "deleted <b>$key</b>" || - notify-send "$0" "could not delete." -elif ! ssh-add -l | grep -q "$(ssh-keygen -lf "$SSHFOLDER"/$key)" + if ssh-add -q -d - < "$SSHFOLDER"/"$key".pub 2> /dev/null + then + notify "Deleted <b>$key</b>" + else + notify "Could not delete." + fi +# check if key is already added +elif ssh-add -l | grep -q "$(ssh-keygen -lf "$SSHFOLDER"/"$key")" then - die "adding: $key" + notify "Key already added." +else export PASSWORD="keys/$HOST/ssh/$key" export SSH_ASKPASS="$0" - ssh-add - < "$SSHFOLDER"/$key && - notify-send "$0" "added <b>$key</b>" -else - die "key already added." - notify-send "$0" "key already added." + ssh-add -q - < "$SSHFOLDER"/"$key" && + notify "Added <b>$key</b>." fi diff --git a/bin/guiscripts/startw b/bin/guiscripts/startw index 768f401..9b35556 100755 --- a/bin/guiscripts/startw +++ b/bin/guiscripts/startw @@ -1,5 +1,6 @@ #!/bin/sh eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg,ssh)" +eval "$(keychain --dir "$XDG_CONFIG_HOME/keychain" --eval --quiet --agents gpg 3A626DD20A32EB2E5DD9CE71CFD9ABC97158CD5D 2> /dev/null)" Hyprland |