From 79f05b8ca5f31d7de81b37db3fecaf599b2edb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20M=C3=B6ller?= <4162215+Croissong@users.noreply.github.com> Date: Wed, 14 Jun 2023 17:36:34 +0000 Subject: [PATCH] feat: add config option to disable notifications --- config | 3 +++ man/tessen.5.scd | 5 +++++ tessen | 7 +++++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/config b/config index 24b54fd..7279c24 100644 --- a/config +++ b/config @@ -45,3 +45,6 @@ # want to use it # if this key is set, xdg-open will not be used even if it's installed # web_browser="" + +# whether to send notifications about copied data via notify-send +# notify="true" diff --git a/man/tessen.5.scd b/man/tessen.5.scd index cf83910..dae9335 100644 --- a/man/tessen.5.scd +++ b/man/tessen.5.scd @@ -127,6 +127,11 @@ The following options are understood by the configuration file for *tessen*(1): The default web browser that should be used for opening URLs. If this is specified, *xdg-open*(1) will not be used even if it's installed. + *notify* + + Whether to send notifications about copied data via *notify-send*(1). + Either *true* or *false* (default is *true*). + # SEE ALSO *tessen*(5), *pass*(1), *gopass*(1) *pass-otp*(1), *fuzzel*(1), *tofi*(1), diff --git a/tessen b/tessen index f447bb7..81a7d8b 100755 --- a/tessen +++ b/tessen @@ -14,7 +14,7 @@ set +x declare _PASS_BACKEND _DMENU_BACKEND _TSN_ACTION _TSN_CONFIG declare -a _DMENU_BACKEND_OPTS _TMP_TOFI_OPTS _TMP_ROFI_OPTS _TMP_WOFI_OPTS declare -a _TMP_FUZZEL_OPTS _TMP_YOFI_OPTS -declare _TSN_USERKEY _TSN_URLKEY _TSN_AUTOKEY _TSN_WEB_BROWSER _TSN_OTP +declare _TSN_USERKEY _TSN_URLKEY _TSN_AUTOKEY _TSN_WEB_BROWSER _TSN_OTP _TSN_NOTIFY declare -i _TSN_DELAY # show both actions, 'autotype' and 'copy', to choose from by default _TSN_ACTION="default" @@ -23,6 +23,7 @@ _TSN_USERKEY="user" _TSN_URLKEY="url" _TSN_AUTOKEY="autotype" _TSN_DELAY=100 +_TSN_NOTIFY=true if [[ -f "${XDG_CONFIG_HOME:-$HOME/.config}"/tessen/config ]]; then _TSN_CONFIG="${XDG_CONFIG_HOME:-$HOME/.config}"/tessen/config elif [[ -f "${XDG_CONFIG_DIRS:-/etc/xdg}"/tessen/config ]]; then @@ -408,7 +409,7 @@ wld_copy() { # feature # https://github.com/bugaevc/wl-clipboard/issues/107 printf "%s" "$1" | wl-copy - if is_installed notify-send; then + if [[ $_TSN_NOTIFY == true ]] && is_installed notify-send; then notify-send -t $((tsn_cliptime * 1000)) \ "data has been copied and will be cleared from the clipboard after $tsn_cliptime seconds" fi @@ -673,6 +674,8 @@ parse_config() { _TSN_DELAY="$val" elif [[ $key == "web_browser" ]] && is_installed "$val"; then _TSN_WEB_BROWSER="$val" + elif [[ $key == "notify" ]]; then + _TSN_NOTIFY="$val" fi done fi