alpha
Login
or
Join now
hermes.pds.lassul.us
/
superconfig
forked from
lass.pds.lassul.us/superconfig
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
This repository has no description
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
tools.passmenu: add --type parameter
author
lassulus
date
1 year ago
(Jun 7, 2025, 5:03 PM CEST)
commit
8eb621f6
8eb621f6d92dad733d0c192af48dec36936cf1e4
parent
5400ded9
5400ded9932c57f6a11bcc068c884c5218f76acd
+39
-9
1 changed file
Expand all
Collapse all
Unified
Split
tools
passmenu.nix
+39
-9
tools/passmenu.nix
View file
Reviewed
···
5
5
{
6
6
packages.passmenu = pkgs.writeShellApplication {
7
7
name = "passmenu";
8
8
-
runtimeInputs = [
8
8
+
runtimeInputs = with pkgs; [
9
9
self.packages.${pkgs.system}.menu
10
10
+
pass
11
11
+
] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [
12
12
+
wtype
13
13
+
xdotool
10
14
];
11
15
text = ''
12
16
set -eu
13
17
shopt -s nullglob globstar
14
18
15
15
-
# typeit=0
16
16
-
# if [[ $1 == "--type" ]]; then
17
17
-
# typeit=1
18
18
-
# shift
19
19
-
# fi
19
19
+
typeit=0
20
20
+
if [[ $# -gt 0 && $1 == "--type" ]]; then
21
21
+
typeit=1
22
22
+
shift
23
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
30
-
pass otp -c "$password" 2>/dev/null
34
34
+
if [[ $typeit -eq 1 ]]; then
35
35
+
# Type OTP code
36
36
+
otp_code=$(pass otp "$password" | tr -d '\n')
37
37
+
if [[ "$(uname)" == "Darwin" ]]; then
38
38
+
# On macOS, use osascript to type the code
39
39
+
osascript -e "tell application \"System Events\" to keystroke \"$otp_code\"" 2>/dev/null
40
40
+
elif [[ -n "$WAYLAND_DISPLAY" ]]; then
41
41
+
echo -n "$otp_code" | wtype -d 10 -s 400 -
42
42
+
else
43
43
+
echo -n "$otp_code" | xdotool type --clearmodifiers --file -
44
44
+
fi
45
45
+
else
46
46
+
pass otp -c "$password" 2>/dev/null
47
47
+
fi
31
48
else
32
32
-
pass show -c "$password" 2>/dev/null
49
49
+
if [[ $typeit -eq 1 ]]; then
50
50
+
# Type password
51
51
+
pw=$(pass show "$password" | head -n1 | tr -d '\n')
52
52
+
if [[ "$(uname)" == "Darwin" ]]; then
53
53
+
# On macOS, use osascript to type the password
54
54
+
osascript -e "tell application \"System Events\" to keystroke \"$pw\"" 2>/dev/null
55
55
+
elif [[ -n "$WAYLAND_DISPLAY" ]]; then
56
56
+
echo -n "$pw" | wtype -d 10 -s 400 -
57
57
+
else
58
58
+
echo -n "$pw" | xdotool type --clearmodifiers --file -
59
59
+
fi
60
60
+
else
61
61
+
pass show -c "$password" 2>/dev/null
62
62
+
fi
33
63
fi
34
64
'';
35
65
};
36
66
};
37
37
-
}
67
67
+
}