File tree 3 files changed +62
-47
lines changed
3 files changed +62
-47
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ install_subdir(
5
5
)
6
6
7
7
install_data (
8
- ' iptsd-find-hidraw' ,
8
+ ' scripts/ iptsd-find-hidraw' ,
9
9
install_dir : bindir,
10
10
install_mode : ' rwxr-xr-x' ,
11
11
)
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ # SPDX-License-Identifier: GPL-2.0-or-later
3
+
4
+ script_dir=" $( dirname " $( realpath " ${0} " ) " ) "
5
+
6
+ function spdlog() {
7
+ level=" ${1} "
8
+ messages=(" ${@: 2} " )
9
+
10
+ case " ${level} " in
11
+ info)
12
+ level=" $( printf " %s%s%s" " \033[32m" " info" " \e[0m" ) "
13
+ ;;
14
+ warn)
15
+ level=" $( printf " %s%s%s" " \033[33m\033[1m" " warning" " \e[0m" ) "
16
+ ;;
17
+ error)
18
+ level=" $( printf " %s%s%s" " \033[31m\033[1m" " error" " \e[0m" ) "
19
+ ;;
20
+ esac
21
+
22
+ echo -e " [$( date ' +%H:%M:%S.%3N' ) ] [${level} ]" " ${messages[@]} " >&2
23
+ }
24
+
25
+ spdlog " warn" " iptsd-find-hidraw is deprecated, please use iptsd-foreach"
26
+
27
+ function check_and_print_path() {
28
+ script=" ${1} "
29
+
30
+ if [ -x " ${script} " ]; then
31
+ echo " ${script} "
32
+ return 0
33
+ fi
34
+
35
+ return 1
36
+ }
37
+
38
+ function find_iptsd_foreach() {
39
+ # iptsd-foreach should always be right next to us
40
+ if check_and_print_path " ${script_dir} /iptsd-foreach" ; then
41
+ return 0
42
+ fi
43
+
44
+ # Fall back to looking in PATH
45
+ if check_and_print_path " $( command -v " iptsd-foreach" || true) " ; then
46
+ spdlog " warn" " Using iptsd-foreach from PATH"
47
+ spdlog " warn" " This script shouldn't have to use PATH, something might be wrong"
48
+ return 0
49
+ fi
50
+
51
+ return 1
52
+ }
53
+
54
+ iptsd_foreach=" $( find_iptsd_foreach) "
55
+
56
+ if [ -z " ${iptsd_foreach} " ]; then
57
+ spdlog " error" " Could not locate iptsd-foreach"
58
+ exit 1
59
+ fi
60
+
61
+ exec " ${iptsd_foreach} " -t touchscreen -i 0 -- echo {}
You can’t perform that action at this time.
0 commit comments