summaryrefslogtreecommitdiff
path: root/bin/guiscripts
diff options
context:
space:
mode:
authorRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-14 11:50:41 +0200
committerRaymaekers Luca <raymaekers.luca@gmail.com>2023-08-14 11:50:41 +0200
commit67a2df82d25f52ea0937f4eed355546deae7b4b5 (patch)
tree40bc358a6d2a6b119e04229b48fd05dd74a5b81d /bin/guiscripts
parent4fbb921cd8a9da0135e0ddf54da898e080cc8c7e (diff)
parentb0ef0738b3f0cebde9ed6b1d40ca0f7cbb1385a3 (diff)
Merge branch 'main' of /var/git/dotfiles
Diffstat (limited to 'bin/guiscripts')
-rwxr-xr-xbin/guiscripts/keyadd45
-rwxr-xr-xbin/guiscripts/startw1
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