Use wofi.

This commit is contained in:
Gabriel Ebner 2020-07-14 16:33:07 +02:00
parent ff58229b23
commit 49e6f81a04
3 changed files with 63 additions and 5 deletions

View File

@ -22,9 +22,9 @@ bindsym $mod+Return exec alacritty
bindsym $mod+Shift+q kill
bindsym $mod+d exec rofi -show run
bindsym $mod+Tab exec rofi -show window
bindsym $mod+p exec rofi-pass
bindsym $mod+d exec wofi --show run -i
bindsym $mod+Tab exec ~/etc/wofi-windows
bindsym $mod+p exec ~/etc/wofi-pass
define([dir_bind], [
bindsym $mod+$2 focus $1
@ -125,7 +125,7 @@ client.urgent base02 base08 base07 base08
# finds out, if available)
bar {
status_command i3status
font pango:DejaVu Sans, Noto Sans CJK JP 8
font pango:DejaVu Sans, Noto Sans CJK JP 9
icon_theme Adwaita
tray_output *

58
wofi-pass Executable file
View File

@ -0,0 +1,58 @@
#!/usr/bin/env bash
set -eo pipefail
root="$HOME/.password-store"
list_accounts() {
(cd "$root" && find -L . -name "*.gpg" | sed 's,^\./,,;s/\.gpg$//' | sort -n)
}
list_accounts_beginning_with_blank_page() {
yes '' | head -n50
list_accounts
}
do_type() {
echo -n "$1" | ydotool type --file=-
}
get_passwd() {
pass "$1" | head -n1
}
get_otp() {
pass otp "$1"
}
get_field() {
pass "$1" | grep "^$2: " | sed "s/$2: //"
}
account="$(list_accounts_beginning_with_blank_page | wofi -dip 'wofi-pass')"
test -n "$account" || exit
choices='password
username
url
otp'
choice="$(echo -n "$choices" | wofi -dp "$account")"
case "$choice" in
password)
passwd="$(get_passwd "$account")"
do_type "$passwd"
;;
username)
username="$(get_field "$account" username)"
do_type "$username"
;;
url)
url="$(get_field "$account" url)"
do_type "$url"
;;
otp)
otp="$(get_otp "$account")"
do_type "$otp"
;;
esac

View File

@ -4,7 +4,7 @@
windows=$(swaymsg -t get_tree | jq -r 'recurse(.nodes[]?)|recurse(.floating_nodes[]?)|select(.type=="con"),select(.type=="floating_con")|(.id|tostring)+" "+.app_id+": "+.name')
# Select window with rofi
selected=$(echo "$windows" | wofi --show dmenu -i | awk '{print $1}')
selected=$(echo "$windows" | wofi --show dmenu -i -p 'go to window' | awk '{print $1}')
# Tell sway to focus said window
swaymsg "[con_id=$selected]" focus