From 126d1c5ce5dba2ece925630547cf4a933bef4b2c Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Mon, 9 Mar 2026 20:53:24 +0100 Subject: [PATCH 1/2] Add `termux-setting` --- scripts/termux-setting.in | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 scripts/termux-setting.in diff --git a/scripts/termux-setting.in b/scripts/termux-setting.in new file mode 100644 index 0000000..3928955 --- /dev/null +++ b/scripts/termux-setting.in @@ -0,0 +1,17 @@ +#!@TERMUX_PREFIX@/bin/bash +set -e -u + +SCRIPTNAME=termux-setting +show_usage() { + echo "Usage: $SCRIPTNAME get namespace key" + echo 'namespace: global, system or secure' + echo 'key: see https://developer.android.com/reference/android/provider/Settings.NAMESPACE#constants' + exit 0 +} + +USAGE_REGEX='^get (global|secure|system) [\._0-9a-z]+$' +if ! [[ $@ =~ $USAGE_REGEX ]]; then + show_usage +fi + +@TERMUX_PREFIX@/libexec/termux-api Setting --es namespace $2 --es key $3 From 8ac43291b470b3e608396c8aa21dccb4f33f6e06 Mon Sep 17 00:00:00 2001 From: Benjamin Loison Date: Fri, 13 Mar 2026 04:27:26 +0100 Subject: [PATCH 2/2] Add `termux-setting put` --- scripts/termux-setting.in | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/termux-setting.in b/scripts/termux-setting.in index 3928955..f15ec34 100644 --- a/scripts/termux-setting.in +++ b/scripts/termux-setting.in @@ -3,15 +3,24 @@ set -e -u SCRIPTNAME=termux-setting show_usage() { - echo "Usage: $SCRIPTNAME get namespace key" + echo "Usage: $SCRIPTNAME action namespace key [value]" + echo 'action: get or put' echo 'namespace: global, system or secure' echo 'key: see https://developer.android.com/reference/android/provider/Settings.NAMESPACE#constants' + echo 'value: value put for the given key' exit 0 } -USAGE_REGEX='^get (global|secure|system) [\._0-9a-z]+$' -if ! [[ $@ =~ $USAGE_REGEX ]]; then - show_usage +GET_USAGE_REGEX='^get (global|secure|system) [\._0-9a-z]+$' +if [[ $@ =~ $GET_USAGE_REGEX ]]; then + @TERMUX_PREFIX@/libexec/termux-api Setting --es action get --es namespace $2 --es key $3 + exit 0 +fi + +PUT_USAGE_REGEX='^put (system) [\._0-9a-z]+ (.+)$' +if [[ $@ =~ $PUT_USAGE_REGEX ]]; then + @TERMUX_PREFIX@/libexec/termux-api Setting --es action put --es namespace $2 --es key $3 --es value $4 + exit 0 fi -@TERMUX_PREFIX@/libexec/termux-api Setting --es namespace $2 --es key $3 +show_usage