From f7cadab2510b4fc279403553d2bcd9ad802da700 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Thu, 3 Apr 2025 19:06:45 +0530 Subject: [PATCH 1/2] chore: setup editorconfig --- .editorconfig | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..7e342fd --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +[*] +trim_trailing_whitespace = true +insert_final_newline = true + +[*.{c,h}] +indent_style = space +indent_size = 4 + +# There is no consistency between tab and spaces, some files are using tabs +# whereas others are using spaces, but use tabs as we use it in our other +# repositories +[*.in] +indent_style = tab +indent_size = 4 + +[CMakeLists.txt] +indent_style = space +indent_size = 2 From f9aab4c47a67db733448a80fba22cd4fd22bd058 Mon Sep 17 00:00:00 2001 From: Yaksh Bariya Date: Fri, 4 Apr 2025 01:57:36 +0530 Subject: [PATCH 2/2] Update termux-clipboard-set to support setting sensitive text This may break existing scripts passing the clipboard data as argument to the script instead of via stdin, as now we are parsing the arguments --- CMakeLists.txt | 2 +- scripts/termux-clipboard-set.in | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8b1f9e..17a3e0a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0.0) +cmake_minimum_required(VERSION 3.25) project(termux-api) include(GNUInstallDirs) diff --git a/scripts/termux-clipboard-set.in b/scripts/termux-clipboard-set.in index c401a7f..96fd7db 100644 --- a/scripts/termux-clipboard-set.in +++ b/scripts/termux-clipboard-set.in @@ -1,26 +1,32 @@ -#!@TERMUX_PREFIX@/bin/sh +#!@TERMUX_PREFIX@/bin/bash set -e -u SCRIPTNAME=termux-clipboard-set show_usage () { echo "Usage: $SCRIPTNAME [text]" echo "Set the system clipboard text. The text to set is either supplied as arguments or read from stdin if no arguments are given." + echo " -s/--sensitive Mark the written data as sensitive" exit 0 } -while getopts :h option -do - case "$option" in - h) show_usage;; - ?) echo "$SCRIPTNAME: illegal option -$OPTARG"; exit 1; - esac +OPT_SENSITIVE=false + +eval set -- "$(getopt -o hs -l sensitive,help -- "$@")" + +while true; do + case "$1" in + -s | --sensitive) OPT_SENSITIVE=true; shift 1;; + -h | --help) show_usage;; + --) shift; break;; + esac done -shift $((OPTIND-1)) CMD="@TERMUX_PREFIX@/libexec/termux-api Clipboard -e api_version 2 --ez set true" +if [ "$OPT_SENSITIVE" = true ]; then + CMD+=" --ez sensitive true" +fi if [ $# = 0 ]; then $CMD else echo -n "$@" | $CMD fi -