aboutsummaryrefslogtreecommitdiff
path: root/lib/keyringer/actions
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-12-21 10:19:25 -0200
committerSilvio Rhatto <rhatto@riseup.net>2016-12-21 10:19:25 -0200
commite597eb9acfab30157abefe6317387f6297d3e869 (patch)
tree2bc0beb9fb4d903a8f80d3cdef98af2b51443ae2 /lib/keyringer/actions
parente8b1c968d9f1ddd2b10b7a6e584b0f1329debea9 (diff)
parentea9326628e6e872798a96063fccd76d964a75583 (diff)
downloadkeyringer-e597eb9acfab30157abefe6317387f6297d3e869.tar.gz
keyringer-e597eb9acfab30157abefe6317387f6297d3e869.tar.bz2
Merge branch 'develop'
Diffstat (limited to 'lib/keyringer/actions')
-rwxr-xr-xlib/keyringer/actions/preferences2
-rwxr-xr-xlib/keyringer/actions/pwgen35
-rwxr-xr-xlib/keyringer/actions/sclip9
3 files changed, 43 insertions, 3 deletions
diff --git a/lib/keyringer/actions/preferences b/lib/keyringer/actions/preferences
index 6e36ef4..ffabc4c 100755
--- a/lib/keyringer/actions/preferences
+++ b/lib/keyringer/actions/preferences
@@ -30,7 +30,7 @@ fi
if [ "$COMMAND" == "ls" ]; then
cat "$PREFERENCES"
elif [ "$COMMAND" == "edit" ]; then
- "$EDITOR" "$PREFERENCES"
+ $EDITOR "$PREFERENCES"
elif [ "$COMMAND" == "add" ]; then
shift 2
[[ -n $* ]] && echo $* >> "$PREFERENCES"
diff --git a/lib/keyringer/actions/pwgen b/lib/keyringer/actions/pwgen
new file mode 100755
index 0000000..45d2bf9
--- /dev/null
+++ b/lib/keyringer/actions/pwgen
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+#
+# Generates passphrases.
+#
+
+# Load functions
+LIB="`dirname $0`/../functions"
+source "$LIB" || exit 1
+
+# Parameters
+SIZE="$3"
+FILE="$2"
+
+# Generates a random passphrase
+function keyringer_pwgen {
+ ENTROPY_BYTES=${1:-20} # in bytes
+ ENTROPY_SOURCE="${ENTROPY_SOURCE:-/dev/urandom}"
+
+ # Strip possible newlines if output is wrapped.
+ # Also strip trailing = signs as they add nothing to the password's entropy.
+ head -c $ENTROPY_BYTES $ENTROPY_SOURCE | base64 | tr -d '\n='
+ echo
+}
+
+# Check
+if [ -z "$FILE" ]; then
+ echo "Usage: keyringer <keyring> $BASENAME <secret> [size]"
+ exit 1
+elif [ ! -z "$SIZE" ] && ! echo $SIZE | egrep -q '^[0-9]+$'; then
+ echo "$SIZE is not a number"
+ exit 1
+fi
+
+# Encrypt and store a randomly-generated secret
+keyringer_pwgen $SIZE | keyringer_exec encrypt "$BASEDIR" "$FILE"
diff --git a/lib/keyringer/actions/sclip b/lib/keyringer/actions/sclip
index e4c88fa..6016f2b 100755
--- a/lib/keyringer/actions/sclip
+++ b/lib/keyringer/actions/sclip
@@ -11,13 +11,18 @@ source "$LIB" || exit 1
shift
keyringer $KEYRING xclip $*
+# Se window switch combo
+if [ -z "$XDOTOOL_NEXT_WINDOW" ]; then
+ XDOTOOL_NEXT_WINDOW="alt+Tab"
+fi
+
# Move to the next window
if which xdotool &> /dev/null; then
- xdotool key alt+Tab
+ xdotool key $XDOTOOL_NEXT_WINDOW
fi
# Sleep
sleep 5
# Overwrite clipboard
-cat $RANDOM | sha256sum | base64 -d | xclip
+echo $RANDOM | sha256sum | base64 | xclip