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 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 -