commit 0bc7e135aaf1600019c573509c3c801b9b1d6cb7
parent a26e6affc58beef0970287499a60ec8fbc5ea170
Author: Sebastiano Tronto <sebastiano.tronto@gmail.com>
Date: Sun, 23 Jan 2022 22:52:43 +0100
Added secret for password encrypting; changed default directory for sfeed-browser.
Diffstat:
3 files changed, 53 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
@@ -23,6 +23,7 @@ SCRIPTS = addressgrep \
popup-cal12 \
popup-cal3 \
popup-terminal \
+ secret \
sel \
sfeed-browser \
spawn \
@@ -40,6 +41,8 @@ SCRIPTS = addressgrep \
xprop-active-window-id \
xwallpaper-random-notify
+all: install
+
install:
for s in ${SCRIPTS}; do\
cp -f $$s ${DESTDIR}${PREFIX}/bin ; \
@@ -49,4 +52,4 @@ install:
uninstall:
for s in ${SCRIPTS}; do rm -rf ${DESTDIR}${PREFIX}/bin/$$s ; done
-.PHONY: install uninstall
+.PHONY: all install uninstall
diff --git a/secret b/secret
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# Encrypt and decrypt files using a fixed cipher and passphrase.
+# The first line of the (unencrypted) file is considered the "password", the
+# rest can be anything.
+
+# Usage: secret command file
+# Available commands:
+# clip: copy the secret to clipboard; deleted after 10 seconds
+# edit: edit or add a file
+# show: show the full encrypted file
+
+# Requires: openssl
+
+opts="aes-256-cbc -iter 1000" # options for openssl
+timeout=10 # timeout for clip, in ms
+editor=${EDITOR:-vi}
+
+if [ -z "$1" ] || [ -z "$2" ]; then
+ echo "usage: secret command file"
+else
+case "$1" in
+ clip)
+ openssl $opts -d < "$2" | head -n 1 | xargs printf "%s" | xsel -ib
+ sleep $timeout && xsel -db &
+ ;;
+ edit)
+ tempfile=$(mktemp)
+ if [ -f "$2" ]; then
+ openssl $opts -d < "$2" > "$tempfile"
+ fi
+ $editor "$tempfile"
+ read -p "Are you sure? [N/yes] " an
+ if [ "$an" = yes ] || [ "$an" = Yes ] || [ "$an" = YES ]; then
+ openssl $opts < "$tempfile" > "$2"
+ else
+ echo "Changes discarded"
+ fi
+ rm "$tempfile"
+ ;;
+ show)
+ openssl $opts -d < "$2"
+ ;;
+ *)
+ echo "$1: not a valid command"
+ ;;
+esac
+fi
diff --git a/sfeed-browser b/sfeed-browser
@@ -17,7 +17,7 @@ filepicker="dmenu-filepicker" # Try "nnn -p -"
menu=${MENU:-dmenu}
menuopts="-l 35 -i"
urlopener=open-url
-sfd="$XDG_CONFIG_HOME/sfeed"
+sfd="box/sfeed"
showlast=10
# Might add more stuff later