improve otp menu
This commit is contained in:
@@ -1,18 +1,22 @@
|
||||
{ pkgs, pkgs-unstable }:
|
||||
let
|
||||
yubikey-manager = pkgs-unstable.yubikey-manager;
|
||||
ykman = "${yubikey-manager}/bin/ykman";
|
||||
sk = "${pkgs.skim}/bin/sk";
|
||||
wl-copy = "${pkgs.wl-clipboard}/bin/wl-copy";
|
||||
in
|
||||
pkgs.writeShellScriptBin "otp" ''
|
||||
skim_command=("${sk}")
|
||||
|
||||
if [ -n "$*" ]; then
|
||||
skim_command+=(-q "$*")
|
||||
fi
|
||||
|
||||
account=$(${ykman} oath accounts list | "''${skim_command[@]}")
|
||||
[ -z "$account" ] && exit 1
|
||||
${ykman} oath accounts code -s "$account" | ${wl-copy} -n
|
||||
''
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
pkgs-unstable,
|
||||
}:
|
||||
pkgs.runCommand "otp"
|
||||
{
|
||||
code = ./otp.cr;
|
||||
env = {
|
||||
YKMAN = lib.getExe pkgs-unstable.yubikey-manager;
|
||||
SKIM = lib.getExe pkgs.skim;
|
||||
WALKER = lib.getExe pkgs-unstable.walker;
|
||||
WL_COPY = lib.getExe' pkgs.wl-clipboard "wl-copy";
|
||||
NOTIFY_SEND = lib.getExe pkgs.libnotify;
|
||||
NOTIFY_ICON = "${pkgs-unstable.yubioath-flutter}/share/pixmaps/com.yubico.yubioath.png";
|
||||
};
|
||||
nativeBuildInputs = [ pkgs.crystal ];
|
||||
}
|
||||
''
|
||||
mkdir -p $out/bin
|
||||
crystal build $code --release -o $out/bin/otp
|
||||
''
|
||||
|
||||
Reference in New Issue
Block a user