Skip to content

Commit e3c3811

Browse files
author
Leonid Pliushch
committed
make it possible to easily change prefix in binary & scripts
1 parent 1519179 commit e3c3811

46 files changed

Lines changed: 99 additions & 96 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
1-
CFLAGS += -std=c11 -Wall -Wextra -pedantic -Werror
21
PREFIX ?= /data/data/com.termux/files/usr
2+
CFLAGS += -std=c11 -Wall -Wextra -pedantic -Werror -DPREFIX=\"$(PREFIX)\"
33

44
termux-api: termux-api.c
55

66
install: termux-api
77
mkdir -p $(PREFIX)/bin/ $(PREFIX)/libexec/
88
install termux-api $(PREFIX)/libexec/
99
install termux-callback $(PREFIX)/libexec/
10-
install scripts/* $(PREFIX)/bin/
10+
for i in scripts/*; do \
11+
sed -e "s|@TERMUX_PREFIX@|$(PREFIX)|g" $i $(PREFIX)/bin/$i; \
12+
chmod 700 $(PREFIX)/bin/$i; \
13+
done
1114

1215
.PHONY: install

scripts/termux-audio-info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/sh
1+
#!@TERMUX_PREFIX@/bin/sh
22
set -e -u
33

44
SCRIPTNAME=termux-audio-info
@@ -19,4 +19,4 @@ shift $((OPTIND-1))
1919

2020
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
2121

22-
/data/data/com.termux/files/usr/libexec/termux-api AudioInfo
22+
@TERMUX_PREFIX@/libexec/termux-api AudioInfo

scripts/termux-battery-status

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/sh
1+
#!@TERMUX_PREFIX@/bin/sh
22
set -e -u
33

44
SCRIPTNAME=termux-battery-status
@@ -19,4 +19,4 @@ shift $((OPTIND-1))
1919

2020
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
2121

22-
/data/data/com.termux/files/usr/libexec/termux-api BatteryStatus
22+
@TERMUX_PREFIX@/libexec/termux-api BatteryStatus

scripts/termux-brightness

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/bash
1+
#!@TERMUX_PREFIX@/bin/bash
22
set -e -u
33

44
SCRIPTNAME=termux-brightness
@@ -23,4 +23,4 @@ else
2323
ARGS="--ei brightness $1 --ez auto false"
2424
fi
2525

26-
/data/data/com.termux/files/usr/libexec/termux-api Brightness $ARGS
26+
@TERMUX_PREFIX@/libexec/termux-api Brightness $ARGS

scripts/termux-call-log

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/bash
1+
#!@TERMUX_PREFIX@/bin/bash
22
set -u
33

44
PARAM_LIMIT=10
@@ -29,4 +29,4 @@ shift $((OPTIND-1))
2929
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
3030

3131
PARAMS="$PARAMS --ei offset $PARAM_OFFSET --ei limit $PARAM_LIMIT"
32-
/data/data/com.termux/files/usr/libexec/termux-api CallLog $PARAMS
32+
@TERMUX_PREFIX@/libexec/termux-api CallLog $PARAMS

scripts/termux-camera-info

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/sh
1+
#!@TERMUX_PREFIX@/bin/sh
22
set -e -u
33

44
SCRIPTNAME=termux-camera-info
@@ -19,4 +19,4 @@ shift $((OPTIND-1))
1919

2020
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
2121

22-
/data/data/com.termux/files/usr/libexec/termux-api CameraInfo
22+
@TERMUX_PREFIX@/libexec/termux-api CameraInfo

scripts/termux-camera-photo

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/sh
1+
#!@TERMUX_PREFIX@/bin/sh
22
set -e -u
33

44
SCRIPTNAME=termux-camera-photo
@@ -27,4 +27,4 @@ if [ $# != 1 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
2727
touch "$1"
2828
PARAMS="$PARAMS --es file `realpath $1`"
2929

30-
/data/data/com.termux/files/usr/libexec/termux-api CameraPhoto $PARAMS
30+
@TERMUX_PREFIX@/libexec/termux-api CameraPhoto $PARAMS

scripts/termux-clipboard-get

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/sh
1+
#!@TERMUX_PREFIX@/bin/sh
22
set -e -u
33

44
SCRIPTNAME=termux-clipboard-get
@@ -19,4 +19,4 @@ shift $((OPTIND-1))
1919

2020
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
2121

22-
/data/data/com.termux/files/usr/libexec/termux-api Clipboard
22+
@TERMUX_PREFIX@/libexec/termux-api Clipboard

scripts/termux-clipboard-set

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/sh
1+
#!@TERMUX_PREFIX@/bin/sh
22
set -e -u
33

44
SCRIPTNAME=termux-clipboard-set
@@ -17,7 +17,7 @@ do
1717
done
1818
shift $((OPTIND-1))
1919

20-
CMD="/data/data/com.termux/files/usr/libexec/termux-api Clipboard -e api_version 2 --ez set true"
20+
CMD="@TERMUX_PREFIX@/libexec/termux-api Clipboard -e api_version 2 --ez set true"
2121
if [ $# = 0 ]; then
2222
$CMD
2323
else

scripts/termux-contact-list

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/data/data/com.termux/files/usr/bin/sh
1+
#!@TERMUX_PREFIX@/bin/sh
22
set -e -u
33

44
SCRIPTNAME=termux-contact-list
@@ -19,4 +19,4 @@ shift $((OPTIND-1))
1919

2020
if [ $# != 0 ]; then echo "$SCRIPTNAME: too many arguments"; exit 1; fi
2121

22-
/data/data/com.termux/files/usr/libexec/termux-api ContactList
22+
@TERMUX_PREFIX@/libexec/termux-api ContactList

0 commit comments

Comments
 (0)