This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools.passmenu: add --type parameter

+39 -9
+39 -9
tools/passmenu.nix
··· 5 5 { 6 6 packages.passmenu = pkgs.writeShellApplication { 7 7 name = "passmenu"; 8 - runtimeInputs = [ 8 + runtimeInputs = with pkgs; [ 9 9 self.packages.${pkgs.system}.menu 10 + pass 11 + ] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ 12 + wtype 13 + xdotool 10 14 ]; 11 15 text = '' 12 16 set -eu 13 17 shopt -s nullglob globstar 14 18 15 - # typeit=0 16 - # if [[ $1 == "--type" ]]; then 17 - # typeit=1 18 - # shift 19 - # fi 19 + typeit=0 20 + if [[ $# -gt 0 && $1 == "--type" ]]; then 21 + typeit=1 22 + shift 23 + fi 20 24 21 25 prefix=''${PASSWORD_STORE_DIR-~/.password-store} 22 26 password_files=( "$prefix"/**/*.gpg ) ··· 27 31 28 32 filename=$(basename "$password") 29 33 if [[ "$filename" == "otp" ]]; then 30 - pass otp -c "$password" 2>/dev/null 34 + if [[ $typeit -eq 1 ]]; then 35 + # Type OTP code 36 + otp_code=$(pass otp "$password" | tr -d '\n') 37 + if [[ "$(uname)" == "Darwin" ]]; then 38 + # On macOS, use osascript to type the code 39 + osascript -e "tell application \"System Events\" to keystroke \"$otp_code\"" 2>/dev/null 40 + elif [[ -n "$WAYLAND_DISPLAY" ]]; then 41 + echo -n "$otp_code" | wtype -d 10 -s 400 - 42 + else 43 + echo -n "$otp_code" | xdotool type --clearmodifiers --file - 44 + fi 45 + else 46 + pass otp -c "$password" 2>/dev/null 47 + fi 31 48 else 32 - pass show -c "$password" 2>/dev/null 49 + if [[ $typeit -eq 1 ]]; then 50 + # Type password 51 + pw=$(pass show "$password" | head -n1 | tr -d '\n') 52 + if [[ "$(uname)" == "Darwin" ]]; then 53 + # On macOS, use osascript to type the password 54 + osascript -e "tell application \"System Events\" to keystroke \"$pw\"" 2>/dev/null 55 + elif [[ -n "$WAYLAND_DISPLAY" ]]; then 56 + echo -n "$pw" | wtype -d 10 -s 400 - 57 + else 58 + echo -n "$pw" | xdotool type --clearmodifiers --file - 59 + fi 60 + else 61 + pass show -c "$password" 2>/dev/null 62 + fi 33 63 fi 34 64 ''; 35 65 }; 36 66 }; 37 - } 67 + }