sites

public wiki contents of suckless.org
git clone git://git.suckless.org/sites
Log | Files | Refs

commit 23459a677d7cc0ac3569a2be0c38a5e0f44850b1
parent 18386e4394a91bbf7f54aa4b5276dcf17f43bbb3
Author: Thomas Preissler <thomas@preissler.co.uk>
Date:   Tue,  6 Oct 2015 21:32:10 +0100

Add passmenu2 entry for dmenu

Diffstat:
Mtools.suckless.org/dmenu/scripts/index.md | 1+
Atools.suckless.org/dmenu/scripts/passmenu2 | 60++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/tools.suckless.org/dmenu/scripts/index.md b/tools.suckless.org/dmenu/scripts/index.md @@ -8,6 +8,7 @@ Download * [passmenu](http://git.zx2c4.com/password-store/tree/contrib/dmenu) : get password from pass. +* [passmenu2](passmenu2): "pass" browser, vertical display and recursive "pass" folder support * [run-recent](run-recent) : List recent commands first. End a command with ";" to run it in e terminal. [source](https://bbs.archlinux.org/viewtopic.php?id=56646&p=12) diff --git a/tools.suckless.org/dmenu/scripts/passmenu2 b/tools.suckless.org/dmenu/scripts/passmenu2 @@ -0,0 +1,60 @@ +#!/usr/bin/env bash + +shopt -s nullglob globstar + +typeit=0 +if [[ $1 == "--type" ]]; then + typeit=1 + shift +fi + + +STARTDIR=${PASSWORD_STORE_DIR-~/.password-store} +BASEDIR=$STARTDIR +DONE=0 +LEVEL=0 +PREVSELECTION="" +SELECTION="" + +while [ "$DONE" -eq 0 ] ; do + password_files=( "$STARTDIR"/* ) + password_files=( "${password_files[@]#"$STARTDIR"/}" ) + password_files=( "${password_files[@]%.gpg}" ) + + if [ "$LEVEL" -ne 0 ] ; then + password_files=(".." "${password_files[@]}") + fi + entry=$(printf '%s\n' "${password_files[@]}" | dmenu "$@" -fn "-*-terminus-*-*-*-24-*-*-*-*-*-*-*" -nb "#00ff00" -nf "#000000" -l 15) + + echo "entry: $entry" + if [ -z $entry ] ; then + DONE=1 + exit + fi + + if [ "$entry" != ".." ] ; then + PREVSELECTION=$SELECTION + SELECTION="$SELECTION/$entry" + + # check if another dir + if [ -d "$STARTDIR/$entry" ] ; then + STARTDIR="$STARTDIR/$entry" + LEVEL=$((LEVEL+1)) + else + # not a directory so it must be a real password entry + + if [[ $typeit -eq 0 ]]; then + pass show -c "$SELECTION" 2>/dev/null + else + xdotool - <<<"type --clearmodifiers -- $(pass show "$SELECTION" | head -n 1)" + fi + DONE=1 + fi + + else + LEVEL=$((LEVEL-1)) + SELECTION=$PREVSELECTION + STARTDIR="$BASEDIR/$SELECTION" + fi +done +