40 lines
1.2 KiB
Nix
40 lines
1.2 KiB
Nix
{ pkgs, config, ... }:
|
|
|
|
let
|
|
passbemenu = pkgs.writeScriptBin "passbemenu" ''
|
|
#!${pkgs.stdenv.shell}
|
|
shopt -s nullglob globstar
|
|
|
|
typeit=0
|
|
if [[ $1 == "--type" ]]; then
|
|
typeit=1
|
|
shift
|
|
fi
|
|
|
|
export BEMENU_BACKEND=wayland
|
|
|
|
prefix=''${PASSWORD_STORE_DIR-~/.password-store}
|
|
password_files=( $(find -L "$prefix" -type f -name '*.gpg') )
|
|
password_files=( "''${password_files[@]#"$prefix"/}" )
|
|
password_files=( "''${password_files[@]%.gpg}" )
|
|
|
|
password=$(printf '%s\n' "''${password_files[@]}" | \
|
|
${pkgs.bemenu}/bin/bemenu --list 20 --ignorecase --prompt 'Pass: ' "$@")
|
|
|
|
[[ -n $password ]] || exit
|
|
|
|
${pkgs.pass-wayland}/bin/pass show -c "$password" 2>/dev/null
|
|
'';
|
|
wsudo = with pkgs.xorg;
|
|
pkgs.writeScriptBin "wsudo" ''
|
|
#!/usr/bin/env bash
|
|
#small script to enable root access to x-windows system
|
|
${xhost}/bin/xhost +SI:localuser:root
|
|
sudo $1
|
|
#disable root access after application terminates
|
|
${xhost}/bin/xhost -SI:localuser:root
|
|
#print access status to allow verification that root access was remov
|
|
ed
|
|
${xhost}/bin/xhost
|
|
'';
|
|
in { home.packages = [ passbemenu wsudo ]; }
|