-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtest.sh
executable file
·53 lines (43 loc) · 1.33 KB
/
test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
set -e
# Save and unmap current user mappings
./keymap.py list > tmp.keymaprc
./keymap.py list | cut -d ' ' -f 1 | xargs -n1 ./keymap.py unmap
./keymap.py list | wc -l | grep 0
./keymap.py swap caps escape
./keymap.py list | grep 'caps -> escape'
./keymap.py list | grep 'escape -> caps'
./keymap.py list | wc -l | grep 2
expected_user_key_mapping=$(cat <<'EOF'
(
{
HIDKeyboardModifierMappingDst = 30064771113;
HIDKeyboardModifierMappingSrc = 30064771129;
},
{
HIDKeyboardModifierMappingDst = 30064771129;
HIDKeyboardModifierMappingSrc = 30064771113;
}
)
EOF
)
if [ "$expected_user_key_mapping" != "$(hidutil property --get UserKeyMapping)" ]; then
echo "hidutil UserKeyMapping did not match expected value"
echo "Expected: $expected_user_key_mapping"
echo "Actual: $(hidutil property --get UserKeyMapping)"
exit 1
fi
./keymap.py save
cat ~/.keymaprc | grep 'caps -> escape'
cat ~/.keymaprc | grep 'escape -> caps'
cat ~/.keymaprc | wc -l | grep 2
./keymap.py unmap caps escape
./keymap.py list | wc -l | grep 0
./keymap.py load
./keymap.py list | grep 'caps -> escape'
./keymap.py list | grep 'escape -> caps'
./keymap.py list | wc -l | grep 2
# Unmap test mappings, load stored user mappings
./keymap.py unmap caps escape
./keymap.py load tmp.keymaprc
rm tmp.keymaprc