Merge branch 'master' of gitlab.com:chriscochrun/dotfiles

This commit is contained in:
Chris Cochrun 2021-07-05 13:22:41 -05:00
commit 5935064a00
14 changed files with 117 additions and 127 deletions

9
scripts/mem Executable file
View file

@ -0,0 +1,9 @@
#!/bin/sh
# Get the percentage of used memory and print it
read used total <<< $(free -m | awk '/Mem/{printf $2" "$3}')
percent=$(bc -l <<< "100 * $total / $used")
mem=$(awk -v u=$used -v t=$total -v p=$percent 'BEGIN {printf "%sMi/%sMi %.1f% ", t, u, p}')
echo $mem

62
scripts/rofipass Executable file
View file

@ -0,0 +1,62 @@
#!/usr/bin/env bash
# Very basic interface for pass using wofi
# Get all password files and create an array
root=~/.password-store
CACHE=~/.local/tmp/pass_wofi
seat=seat0
list_passwords() {
shopt -s nullglob globstar
cd "${root}" || exit
pw_list=(**/*.gpg)
printf '%s\n' "${pw_list[@]%.gpg}" | sort -n
}
prompt='search for passwords...'
SECRET=$(list_passwords | rofi -i -prompt="${prompt}" -dmenu)
# Ask whether pass, user or both are required
options=("Password" \
"User" \
"User and password" \
"QR-Code" \
"OTP")
option=$(printf '%s\n' "${options[@]%}" | rofi -i -dmenu -width 400 -lines 4 -prompt="...")
echo $option
case ${option} in
Password )
echo "Test"
wtype $(pass ${SECRET} | head -n 1)
;;
User )
wtype $(pass ${SECRET} | rg user: | awk '{$1 = ""; print $0}')
;;
"User and password" )
wtype $(pass ${SECRET} | rg user: | awk '{$1 = ""; print $0}')
wtype -k TAB
wtype $(pass ${SECRET} | head -n 1)
;;
"QR-Code" )
if [[ $SECRET =~ wifi$ ]]; then
# Produce a valid wifi QR-code
WIFISSID=$(pass get_user ${SECRET})
WIFIPASS=$(pass get_pass ${SECRET})
WIFIQR="WIFI:T:WPA;S:${WIFISSID};P:${WIFIPASS};;"
qrencode -s 8 -o - $WIFIQR | feh --title "pass: QR-WIFI" -
else
# Only password
pass show -q1 ${SECRET}
fi
;;
"OTP" )
wtype $(pass otp ${SECRET})
;;
esac
# wl-copy -o -s ${seat} ${PASSWD_PASS}