cem-utils

Random utilities
git clone git://git.ckyln.com/~cem/cem-utils.git
Log | Files | Refs | README

commit 222083dcfa1b322e73607f1f589e907d76fa2239
parent d3c364dd36dafce44f3e1fff7a00ed3af154ccf4
Author: Cem Keylan <cem@ckyln.com>
Date:   Wed,  4 Mar 2020 10:35:52 +0300

pm: add contrib

Diffstat:
Apm/contrib/Makefile | 10++++++++++
Apm/contrib/README | 5+++++
Apm/contrib/pm-add-dmenu | 11+++++++++++
Apm/contrib/pm-ask | 13+++++++++++++
Apm/contrib/pm-copy | 4++++
Apm/contrib/pm-copy-dmenu | 10++++++++++
6 files changed, 53 insertions(+), 0 deletions(-)

diff --git a/pm/contrib/Makefile b/pm/contrib/Makefile @@ -0,0 +1,10 @@ +PREFIX = /usr/local +BINDIR = ${PREFIX}/bin +contrib = pm-add-dmenu pm-ask pm-copy pm-copy-dmenu + +install: + install -Dm755 -t ${DESTDIR}${BINDIR} ${contrib} + +uninstall: + for bin in ${contrib} ; do \ + rm -f ${DESTDIR}${BINDIR}/$$bin ; done diff --git a/pm/contrib/README b/pm/contrib/README @@ -0,0 +1,5 @@ +contrib scripts +=============== + +These are some example ways you can adapt +pm into your own scripts. diff --git a/pm/contrib/pm-add-dmenu b/pm/contrib/pm-add-dmenu @@ -0,0 +1,11 @@ +#!/bin/sh + +name=$(dmenu -p "Give a name to your password" <&-) +pass=" " + +while ! [ "$pass" = "$pass2" ] ; do + pass=$(dmenu -nb black -nf black -p "Enter your password" <&-) + pass2=$(dmenu -nb black -nf black -p "Enter your password again" <&-) +done + +printf '%s' "$pass" | pm a "$name" diff --git a/pm/contrib/pm-ask b/pm/contrib/pm-ask @@ -0,0 +1,13 @@ +#!/bin/sh +[ "$1" ] || exit 1 +stty -echo +printf 'Enter your password: ' +read pass +printf '\nEnter your password again: ' +read pass2 +printf '\n' +stty echo +[ "$pass" = "$pass2" ] && { printf '%s' "$pass" | pm a "$1" ;} || { + printf "Passwords don't match\n" + exit 1 +} diff --git a/pm/contrib/pm-copy b/pm/contrib/pm-copy @@ -0,0 +1,4 @@ +#!/bin/sh + +[ "$1" ] || exit 1 +pm s "$1" | xclip -sel c diff --git a/pm/contrib/pm-copy-dmenu b/pm/contrib/pm-copy-dmenu @@ -0,0 +1,10 @@ +#!/bin/sh + +getpass() { + pm l | while read -r file ; do + basename "$file" | cut -d . -f 1 + done +} + +choice=$(getpass | dmenu -p "Choose the password that you would like to copy" -l 10) +[ "$choice" ] && pm s "$choice" | xclip -sel c