2021-11-01 09:20:42 +01:00
|
|
|
{ lib
|
|
|
|
, symlinkJoin
|
|
|
|
, rofi
|
|
|
|
, gnused
|
2022-06-14 22:56:58 +02:00
|
|
|
, pass
|
2021-11-01 09:20:42 +01:00
|
|
|
, writeTextFile
|
|
|
|
, writeShellScriptBin
|
|
|
|
, xdotool
|
|
|
|
}:
|
2019-10-24 02:20:38 +02:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
name = "otpmenu";
|
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
desktopFile = writeTextFile {
|
|
|
|
name = "${name}.desktop";
|
|
|
|
destination = "/share/applications/${name}.desktop";
|
|
|
|
text = ''
|
|
|
|
[Desktop Entry]
|
|
|
|
Categories=Application;Utility;
|
|
|
|
Comment=Enter MFA number with password otp plugins otp
|
|
|
|
Encoding=UTF-8
|
|
|
|
Exec=${bin}/bin/${name}
|
|
|
|
Icon=gnome-lockscreen
|
|
|
|
Name=${name}
|
|
|
|
Terminal=false
|
|
|
|
Type=Application
|
2019-10-24 02:20:38 +02:00
|
|
|
'';
|
2019-12-20 05:54:26 +01:00
|
|
|
};
|
2019-10-24 02:20:38 +02:00
|
|
|
|
2019-12-20 05:54:26 +01:00
|
|
|
bin = writeShellScriptBin name # sh
|
|
|
|
''
|
|
|
|
set -efu
|
|
|
|
|
|
|
|
x=$(
|
2022-06-14 22:56:58 +02:00
|
|
|
${pass.withExtensions (ext: [ext.pass-otp])}/bin/pass git ls-files '*/otp.gpg' \
|
2019-12-20 05:54:26 +01:00
|
|
|
| ${gnused}/bin/sed 's:/otp\.gpg$::' \
|
|
|
|
| ${rofi}/bin/rofi -dmenu -f -p OTP
|
|
|
|
)
|
|
|
|
|
2022-06-14 22:56:58 +02:00
|
|
|
otp=$(${pass.withExtensions (ext: [ext.pass-otp])}/bin/pass otp code "$x/otp")
|
2019-12-20 05:54:26 +01:00
|
|
|
|
|
|
|
printf %s "$otp" | ${xdotool}/bin/xdotool type -f -
|
|
|
|
'';
|
|
|
|
|
2021-11-01 09:20:42 +01:00
|
|
|
in
|
|
|
|
symlinkJoin rec {
|
2019-12-20 05:54:26 +01:00
|
|
|
version = "1.0.0";
|
|
|
|
name = "otpMenu-${version}";
|
|
|
|
paths = [ bin desktopFile ];
|
2021-09-11 20:05:27 +02:00
|
|
|
meta = with lib; {
|
2019-12-20 05:54:26 +01:00
|
|
|
description = "similar to passmenu shows and prints otp";
|
|
|
|
homepage = "https://your.mama";
|
|
|
|
license = licenses.gpl3;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ mrVanDalo ];
|
|
|
|
};
|
|
|
|
}
|
2019-10-24 02:20:38 +02:00
|
|
|
|