-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·100 lines (75 loc) · 1.56 KB
/
build.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
function main {
# loop args
if [[ $# -ne 0 ]] ; then
for var in "$@" ; do
eval $var
done
exit 1
fi
# menu
while true; do
read -n 1 -p "
config
===================
1) Run Release
2) Build Release
3) Build Debug
4) Run Debug
6) Input User Group
7) Install User Service
*) Any key to exit
:" ans;
reset
case $ans in
1) fn_run ;;
2) fn_build ;;
3) fn_build_debug ;;
4) fn_run_debug ;;
6) fn_user_group ;;
7) fn_service ;;
*) $SHELL ;;
esac
done
}
function fn_service {
mkdir -p $HOME/.config/systemd/user/
DIR="$( cd "$( dirname "$0" )" && pwd )"
tee $HOME/.config/systemd/user/macrokey.service > /dev/null << EOL
[Unit]
Description=macrokey
StartLimitIntervalSec=60
StartLimitBurst=4
[Service]
ExecStart=${DIR}/macrokey
Restart=on-failure
RestartSec=1
SuccessExitStatus=3 4
RestartForceExitStatus=3 4
[Install]
WantedBy=default.target
EOL
systemctl --user enable macrokey.service
systemctl --user start macrokey.service
systemctl --user status macrokey.service
}
function fn_user_group {
sudo usermod -a -G input $USER
echo "please reboot to apply"
}
function fn_run {
cp ./target/release/macrokey macrokey
./macrokey
}
function fn_build {
cargo build --release
cp ./target/release/macrokey macrokey
}
function fn_build_debug {
cargo build
}
function fn_run_debug {
./target/debug/macrokey
}
# pass all args
main "$@"