Skip to content

Commit

Permalink
feat: add config option to disable notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
croissong committed Jun 14, 2023
1 parent 3128569 commit 79f05b8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 5 additions & 0 deletions man/tessen.5.scd
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
7 changes: 5 additions & 2 deletions tessen
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 79f05b8

Please sign in to comment.