commit cb2af9f326ffea67b52a37db900aaea3b9b61d31
parent dad052e6b3e45910dff5bc1ac0a53ecbb1456538
Author: awy <awy@awy.one>
Date: Wed, 7 Jan 2026 17:43:53 +0300
center mew and cleanup
Diffstat:
6 files changed, 267 insertions(+), 338 deletions(-)
diff --git a/README.md b/README.md
@@ -9,10 +9,7 @@ files. A wayland native dmenu is required to use tessen and the following dmenu
recognized
- [fuzzel][4]
-- [tofi][15]
- [mew][5]
-- [yofi][32]
-- [wofi][6]
- [rofi][3]
As of version 2.2.0 of tessen, fuzzel is the default dmenu backend.
@@ -55,8 +52,7 @@ If you want to add another Wayland native dmenu not mentioned above, please see
- at least one pass backend is needed - either [password-store][1] or [gopass][2]
-- at least one Wayland native dmenu backend, preferably [fuzzel][4], or [tofi][15], [mew][5],
- [yofi][32], [wofi][6], [rofi][3]
+- at least one Wayland native dmenu backend, preferably [fuzzel][4], or [mew][5], [rofi][3]
- at least one (or both if needed) action backend - [wtype][17] or [wl-clipboard][18]
@@ -74,8 +70,8 @@ If you want to add another Wayland native dmenu not mentioned above, please see
| Operating System |
|------------------------|
| [Arch Linux (AUR)][23] |
-| [Alpine Linux][34] |
-| [NixOS][35] |
+| [Alpine Linux][33] |
+| [NixOS][34] |
| [GuixSD][24] |
### Git Release
@@ -87,7 +83,7 @@ sudo make install
```
You can also do `doas make install` if you're using [doas][25] on Linux, [which you probably
-should][33].
+should][32].
### Stable Release
@@ -198,7 +194,6 @@ Please see the [CONTRIBUTING.md file.][7]
[3]: https://github.com/lbonn/rofi
[4]: https://codeberg.org/dnkl/fuzzel
[5]: https://github.com/Cloudef/mew
-[6]: https://hg.sr.ht/~scoopta/wofi
[7]: https://git.sr.ht/~ayushnix/tessen/tree/master/item/CONTRIBUTING.md
[8]: https://swaywm.org/
[9]: https://github.com/junegunn/fzf
@@ -207,7 +202,6 @@ Please see the [CONTRIBUTING.md file.][7]
[12]: https://cmpxchg8b.com/passmgrs.html
[13]: https://github.com/koalaman/shellcheck
[14]: https://github.com/mvdan/sh
-[15]: https://github.com/philj56/tofi
[16]: https://www.gnu.org/software/bash/
[17]: https://github.com/atx/wtype
[18]: https://github.com/bugaevc/wl-clipboard
@@ -224,7 +218,6 @@ Please see the [CONTRIBUTING.md file.][7]
[29]: https://github.com/swaywm/sway/releases/tag/1.7
[30]: https://github.com/ReimuNotMoe/ydotool
[31]: https://en.wikipedia.org/wiki/Japanese_war_fan
-[32]: https://github.com/l4l/yofi
-[33]: https://social.treehouse.systems/@psykose/109967460650885493
-[34]: https://pkgs.alpinelinux.org/packages?name=tessen
-[35]: https://search.nixos.org/packages?query=tessen
+[32]: https://social.treehouse.systems/@psykose/109967460650885493
+[33]: https://pkgs.alpinelinux.org/packages?name=tessen
+[34]: https://search.nixos.org/packages?query=tessen
diff --git a/completion/tessen.fish-completion b/completion/tessen.fish-completion
@@ -1,6 +1,6 @@
complete -f -c tessen
complete -x -c tessen -s p -l pass -k -a "pass gopass" -d "use pass or gopass"
-complete -x -c tessen -s d -l dmenu -k -a "fuzzel mew tofi yofi wofi rofi dmenu" -d "use either fuzzel,mew, tofi, yofi, wofi, rofi, or dmenu"
+complete -x -c tessen -s d -l dmenu -k -a "fuzzel mew rofi dmenu" -d "use either fuzzel, mew, rofi, or dmenu"
complete -x -c tessen -s a -l action -k -a "autotype copy both" -d "either 'autotype' data, 'copy' it, or do 'both'"
complete -x -c tessen -s h -l help -d "show the help menu"
complete -x -c tessen -s v -l version -d "show the version"
diff --git a/config b/config
@@ -19,12 +19,7 @@
# alternatively, use the command line arguments to specify the dmenu backend
# while running tessen
# fuzzel_config_file=""
-# tofi_config_file=""
# rofi_config_file="$XDG_CONFIG_HOME/rofi/test.rasi"
-# wofi_config_file=""
-# wofi_style_file=""
-# wofi_color_file=""
-# yofi_config_file=""
# the name of the key which will be used to decide the username
# this can also be a simple regex such as (user|login)
diff --git a/man/tessen.1.scd b/man/tessen.1.scd
@@ -25,7 +25,7 @@ The options understood by tessen are:
*-d*, *--dmenu*, *--dmenu=*[dmenu backend]
specify a dmenu backend - the list of recognized backends are *fuzzel*,
- *tofi*, *mew*, *yofi*, *wofi*, *rofi*, and *dmenu*
+ *mew*, *rofi*, and *dmenu*
*-a*, *--action*, *--action=*[action]
specify either *autotype*, *copy*, or *both*
@@ -58,7 +58,7 @@ considered case-insensitive. Note that tessen does NOT support parsing YAML
files when using *gopass*(1).
If a dmenu backend is not specified, tessen tries to find either one of
-*fuzzel*(1), *tofi*(1), *mew*(1), *yofi*, *wofi*(1), *rofi*(1) or *dmenu* in
+*fuzzel*(1), *mew*(1), *rofi*(1) or *dmenu* in
the order mentioned here. If *rofi* is used, it is expected that the wayland
native fork of rofi (https://github.com/lbonn/rofi) is being used. The original
rofi (https://github.com/davatorium/rofi) implementation made for X.Org is NOT
@@ -93,8 +93,8 @@ set in the config file.
tessen depends on
- *bash*(1)
-- at least one wayland native dmenu backend - *fuzzel*(1), *tofi*(1),
- *mew*(1), *wofi*(1), *rofi*(1), *dmenu*
+- at least one wayland native dmenu backend - *fuzzel*(1), *mew*(1),
+ *rofi*(1), *dmenu*
- at least one pass backend - either *pass*(1) or *gopass*(1)
- *wtype*(1) (if you want to autotype data)
- *wl-clipboard*(1) (if you want to copy and paste data)
@@ -191,8 +191,8 @@ _$XDG_CONFIG_DIRS/tessen/config_, _/etc/xdg/tessen/config_
# SEE ALSO
-*tessen*(5), *pass*(1), *gopass*(1) *pass-otp*(1), *fuzzel*(1), *tofi*(1),
-*mew*(1), *wofi*(1), *rofi*(1), *wl-clipboard*(1), *wtype*(1),
+*tessen*(5), *pass*(1), *gopass*(1) *pass-otp*(1), *fuzzel*(1), *mew*(1),
+*rofi*(1), *wl-clipboard*(1), *wtype*(1),
*notify-send*(1)
# AUTHORS
diff --git a/man/tessen.5.scd b/man/tessen.5.scd
@@ -39,8 +39,8 @@ The following options are understood by the configuration file for *tessen*(1):
*dmenu_backend*
- The default dmenu backend to use - either *fuzzel*(1), *tofi*(1),
- *mew*(1), *wofi*(1), *rofi*(1), or *dmenu*
+ The default dmenu backend to use - either *fuzzel*(1), *mew*(1),
+ *rofi*(1), or *dmenu*
*action*
@@ -53,32 +53,11 @@ The following options are understood by the configuration file for *tessen*(1):
The path to the configuration file of *fuzzel*(1). The location of the
file specified here is passed to fuzzel using its *-config=* option.
- *tofi_config_file*
-
- The path to the configuration file of *tofi*(1). The location of the
- file specified here is passed to tofi using its *-c* option.
-
- *yofi_config_file*
-
- The path to the configuration file of yofi. The location of the file
- specified here is passed to fuzzel using its *-config-file* option.
-
*rofi_config_file*
The path to the configuration file of *rofi*(1). The location of the
file specified here is passed to rofi using its *-config* option.
- *wofi_config_file*
-
- *wofi_style_file*
-
- *wofi_color_file*
-
- The path to the configuration files of *wofi*(1). The location of the
- files specified using these variables are passed to wofi using its *-c*,
- *-s*, *-C* options, respectively. Note that *-k* is unsupported and is
- explicitly set to */dev/null* to prevent leaking sensitive information.
-
*userkey*
The name of the key which will be used to decide the username. A simple
@@ -134,8 +113,8 @@ The following options are understood by the configuration file for *tessen*(1):
# SEE ALSO
-*tessen*(5), *pass*(1), *gopass*(1) *pass-otp*(1), *fuzzel*(1), *tofi*(1),
-*mew*(1), *wofi*(1), *rofi*(1), *wl-clipboard*(1), *wtype*(1),
+*tessen*(5), *pass*(1), *gopass*(1) *pass-otp*(1), *fuzzel*(1), *mew*(1),
+*rofi*(1), *wl-clipboard*(1), *wtype*(1),
*notify-send*(1)
# AUTHORS
diff --git a/tessen b/tessen
@@ -50,8 +50,8 @@ get_pass_files() {
tmp_pass_files=("${tmp_pass_files[@]%.gpg}")
shopt -u nullglob globstar
- _TSN_PASSFILE="$(printf "%s\n" "${tmp_pass_files[@]}" \
- | "$_DMENU_BACKEND" "${_DMENU_BACKEND_OPTS[@]}")"
+ _TSN_PASSFILE="$(printf "%s\n" "${tmp_pass_files[@]}" |
+ "$_DMENU_BACKEND" "${_DMENU_BACKEND_OPTS[@]}")"
_EXIT_STATUS="$?"
# instead of searching through the tmp_pass_files array for valid selection,
@@ -70,8 +70,8 @@ get_gopass_files() {
local -a tmp_gopass_files
mapfile -t tmp_gopass_files < <(gopass ls -f)
- _TSN_PASSFILE="$(printf "%s\n" "${tmp_gopass_files[@]}" \
- | "$_DMENU_BACKEND" "${_DMENU_BACKEND_OPTS[@]}")"
+ _TSN_PASSFILE="$(printf "%s\n" "${tmp_gopass_files[@]}" |
+ "$_DMENU_BACKEND" "${_DMENU_BACKEND_OPTS[@]}")"
_EXIT_STATUS="$?"
if [[ -z $_TSN_PASSFILE ]]; then
@@ -98,7 +98,7 @@ get_pass_data() {
local keyval_regex otp_regex idx key val
if [[ $_PASS_BACKEND == "pass" ]]; then
- mapfile -t passdata < <(pass show "$_TSN_PASSFILE" 2> /dev/null)
+ mapfile -t passdata < <(pass show "$_TSN_PASSFILE" 2>/dev/null)
if [[ ${#passdata[@]} -eq 0 ]]; then
_die "the selected file is empty"
fi
@@ -106,7 +106,7 @@ get_pass_data() {
# the output from gopass show -n -f that prints the first line and the
# newline before EOF doesn't use file descriptors but is printed only when
# the output is detected to be a terminal ... weird
- mapfile -t passdata < <(gopass show -n -f "$_TSN_PASSFILE" 2> /dev/null)
+ mapfile -t passdata < <(gopass show -n -f "$_TSN_PASSFILE" 2>/dev/null)
if [[ ${#passdata[@]} -eq 0 ]]; then
_die "the selected file is empty"
fi
@@ -160,16 +160,16 @@ get_pass_data() {
# map custom actions to specific dmenu exit codes
custom_keyb_action() {
case "$_EXIT_STATUS" in
- 10) auto_type_def ;;
- 11) auto_type "$_TSN_USERNAME" ;;
- 12) auto_type "$_TSN_PASSWORD" ;;
- 13) key_open_url ;;
- 14) wld_copy "$_TSN_USERNAME" ;;
- 15) wld_copy "$_TSN_PASSWORD" ;;
- 16) wld_copy "$_TSN_URL" ;;
- 17) key_otp autotype ;;
- 18) key_otp copy ;;
- *) _die "unmapped exit code detected" ;;
+ 10) auto_type_def ;;
+ 11) auto_type "$_TSN_USERNAME" ;;
+ 12) auto_type "$_TSN_PASSWORD" ;;
+ 13) key_open_url ;;
+ 14) wld_copy "$_TSN_USERNAME" ;;
+ 15) wld_copy "$_TSN_PASSWORD" ;;
+ 16) wld_copy "$_TSN_URL" ;;
+ 17) key_otp autotype ;;
+ 18) key_otp copy ;;
+ *) _die "unmapped exit code detected" ;;
esac
}
@@ -184,40 +184,40 @@ get_key() {
# and the autotype key will be present in these cases
# when _TSN_ACTION is set to copy, the autotype key shouldn't be shown in the 2nd menu
case "$_TSN_ACTION" in
- autotype | both | default)
- if [[ $1 == "key_list" ]]; then
- if [[ $_TSN_OTP == "false" ]] && [[ -z $_TSN_URL ]]; then
- key_arr=("$_TSN_AUTOKEY" "$_TSN_USERKEY" "password" "${!_TSN_PASSDATA[@]}")
- elif [[ $_TSN_OTP == "false" ]] && [[ -n $_TSN_URL ]]; then
- key_arr=("$_TSN_AUTOKEY" "$_TSN_USERKEY" "password" "$_TSN_URLKEY" "${!_TSN_PASSDATA[@]}")
- elif [[ $_TSN_OTP == "true" ]] && [[ -z $_TSN_URL ]]; then
- key_arr=("$_TSN_AUTOKEY" "$_TSN_USERKEY" "password" "otp" "${!_TSN_PASSDATA[@]}")
- elif [[ $_TSN_OTP == "true" ]] && [[ -n $_TSN_URL ]]; then
- key_arr=("$_TSN_AUTOKEY" "$_TSN_USERKEY" "password" "otp" "$_TSN_URLKEY" "${!_TSN_PASSDATA[@]}")
- fi
- fi
- # the (optional) third menu, its appearance depends on _TSN_ACTION being default
- if [[ $_TSN_ACTION == "default" ]] && [[ $1 == "option" ]]; then
- key_arr=("$_TSN_AUTOKEY" "copy")
- # the (optional) third menu if _TSN_URLKEY is chosen, it depends on
- # _TSN_ACTION being default
- elif [[ $_TSN_ACTION == "default" ]] && [[ $1 == "$_TSN_URLKEY" ]]; then
- key_arr=("open" "copy")
+ autotype | both | default)
+ if [[ $1 == "key_list" ]]; then
+ if [[ $_TSN_OTP == "false" ]] && [[ -z $_TSN_URL ]]; then
+ key_arr=("$_TSN_AUTOKEY" "$_TSN_USERKEY" "password" "${!_TSN_PASSDATA[@]}")
+ elif [[ $_TSN_OTP == "false" ]] && [[ -n $_TSN_URL ]]; then
+ key_arr=("$_TSN_AUTOKEY" "$_TSN_USERKEY" "password" "$_TSN_URLKEY" "${!_TSN_PASSDATA[@]}")
+ elif [[ $_TSN_OTP == "true" ]] && [[ -z $_TSN_URL ]]; then
+ key_arr=("$_TSN_AUTOKEY" "$_TSN_USERKEY" "password" "otp" "${!_TSN_PASSDATA[@]}")
+ elif [[ $_TSN_OTP == "true" ]] && [[ -n $_TSN_URL ]]; then
+ key_arr=("$_TSN_AUTOKEY" "$_TSN_USERKEY" "password" "otp" "$_TSN_URLKEY" "${!_TSN_PASSDATA[@]}")
fi
- ;;
- copy)
- if [[ $1 == "key_list" ]]; then
- if [[ $_TSN_OTP == "false" ]] && [[ -z $_TSN_URL ]]; then
- key_arr=("$_TSN_USERKEY" "password" "${!_TSN_PASSDATA[@]}")
- elif [[ $_TSN_OTP == "false" ]] && [[ -n $_TSN_URL ]]; then
- key_arr=("$_TSN_USERKEY" "password" "$_TSN_URLKEY" "${!_TSN_PASSDATA[@]}")
- elif [[ $_TSN_OTP == "true" ]] && [[ -z $_TSN_URL ]]; then
- key_arr=("$_TSN_USERKEY" "password" "otp" "${!_TSN_PASSDATA[@]}")
- elif [[ $_TSN_OTP == "true" ]] && [[ -n $_TSN_URL ]]; then
- key_arr=("$_TSN_USERKEY" "password" "otp" "$_TSN_URLKEY" "${!_TSN_PASSDATA[@]}")
- fi
+ fi
+ # the (optional) third menu, its appearance depends on _TSN_ACTION being default
+ if [[ $_TSN_ACTION == "default" ]] && [[ $1 == "option" ]]; then
+ key_arr=("$_TSN_AUTOKEY" "copy")
+ # the (optional) third menu if _TSN_URLKEY is chosen, it depends on
+ # _TSN_ACTION being default
+ elif [[ $_TSN_ACTION == "default" ]] && [[ $1 == "$_TSN_URLKEY" ]]; then
+ key_arr=("open" "copy")
+ fi
+ ;;
+ copy)
+ if [[ $1 == "key_list" ]]; then
+ if [[ $_TSN_OTP == "false" ]] && [[ -z $_TSN_URL ]]; then
+ key_arr=("$_TSN_USERKEY" "password" "${!_TSN_PASSDATA[@]}")
+ elif [[ $_TSN_OTP == "false" ]] && [[ -n $_TSN_URL ]]; then
+ key_arr=("$_TSN_USERKEY" "password" "$_TSN_URLKEY" "${!_TSN_PASSDATA[@]}")
+ elif [[ $_TSN_OTP == "true" ]] && [[ -z $_TSN_URL ]]; then
+ key_arr=("$_TSN_USERKEY" "password" "otp" "${!_TSN_PASSDATA[@]}")
+ elif [[ $_TSN_OTP == "true" ]] && [[ -n $_TSN_URL ]]; then
+ key_arr=("$_TSN_USERKEY" "password" "otp" "$_TSN_URLKEY" "${!_TSN_PASSDATA[@]}")
fi
- ;;
+ fi
+ ;;
esac
# a global variable to hold the selected key for key_menu
@@ -242,12 +242,12 @@ key_menu() {
get_key key_list
case "$_CHOSEN_KEY" in
- "$_TSN_AUTOKEY") auto_type_def ;;
- "$_TSN_USERKEY") key_action "$_TSN_USERNAME" ;;
- password) key_action "$_TSN_PASSWORD" ;;
- otp) key_otp ;;
- "$_TSN_URLKEY") key_action "$_TSN_URLKEY" ;;
- *) key_action "${_TSN_PASSDATA["$_CHOSEN_KEY"]}" ;;
+ "$_TSN_AUTOKEY") auto_type_def ;;
+ "$_TSN_USERKEY") key_action "$_TSN_USERNAME" ;;
+ password) key_action "$_TSN_PASSWORD" ;;
+ otp) key_otp ;;
+ "$_TSN_URLKEY") key_action "$_TSN_URLKEY" ;;
+ *) key_action "${_TSN_PASSDATA["$_CHOSEN_KEY"]}" ;;
esac
}
@@ -259,47 +259,47 @@ key_action() {
local arg="$1"
case "$_TSN_ACTION" in
- autotype)
- if [[ $arg == "$_TSN_URLKEY" ]]; then
- key_open_url || _die
- return 0
- fi
+ autotype)
+ if [[ $arg == "$_TSN_URLKEY" ]]; then
+ key_open_url || _die
+ return 0
+ fi
+ auto_type "$arg"
+ ;;
+ copy)
+ if [[ $arg == "$_TSN_URLKEY" ]]; then
+ wld_copy "$_TSN_URL" || _die
+ return 0
+ fi
+ wld_copy "$arg"
+ ;;
+ both)
+ if [[ $arg == "$_TSN_URLKEY" ]]; then
+ key_open_url
+ wld_copy "$_TSN_URL"
+ else
auto_type "$arg"
- ;;
- copy)
- if [[ $arg == "$_TSN_URLKEY" ]]; then
- wld_copy "$_TSN_URL" || _die
- return 0
- fi
wld_copy "$arg"
- ;;
- both)
- if [[ $arg == "$_TSN_URLKEY" ]]; then
- key_open_url
- wld_copy "$_TSN_URL"
+ fi
+ ;;
+ default)
+ if [[ $arg == "$_TSN_URLKEY" ]]; then
+ get_key "$_TSN_URLKEY"
+ if [[ $_CHOSEN_KEY == "open" ]]; then
+ key_open_url || _die
+ return 0
else
- auto_type "$arg"
- wld_copy "$arg"
+ wld_copy "$_TSN_URL"
fi
- ;;
- default)
- if [[ $arg == "$_TSN_URLKEY" ]]; then
- get_key "$_TSN_URLKEY"
- if [[ $_CHOSEN_KEY == "open" ]]; then
- key_open_url || _die
- return 0
- else
- wld_copy "$_TSN_URL"
- fi
+ else
+ get_key option
+ if [[ $_CHOSEN_KEY == "$_TSN_AUTOKEY" ]]; then
+ auto_type "$arg"
else
- get_key option
- if [[ $_CHOSEN_KEY == "$_TSN_AUTOKEY" ]]; then
- auto_type "$arg"
- else
- wld_copy "$arg"
- fi
+ wld_copy "$arg"
fi
- ;;
+ fi
+ ;;
esac
unset -v arg
@@ -310,7 +310,7 @@ key_action() {
key_otp() {
local tmp_otp
- if [[ $_PASS_BACKEND == "pass" ]] && ! pass otp -h > /dev/null 2>&1; then
+ if [[ $_PASS_BACKEND == "pass" ]] && ! pass otp -h >/dev/null 2>&1; then
_die "pass-otp is not installed"
fi
@@ -337,12 +337,12 @@ key_otp() {
key_open_url() {
if [[ -n $_TSN_WEB_BROWSER ]]; then
- "$_TSN_WEB_BROWSER" "$_TSN_URL" > /dev/null 2>&1 || {
+ "$_TSN_WEB_BROWSER" "$_TSN_URL" >/dev/null 2>&1 || {
printf "%s\n" "$_TSN_WEB_BROWSER was unable to open '$_TSN_URL'" >&2
return 1
}
elif is_installed xdg-open; then
- xdg-open "$_TSN_URL" 2> /dev/null || {
+ xdg-open "$_TSN_URL" 2>/dev/null || {
printf "%s\n" "xdg-open was unable to open '$_TSN_URL'" >&2
return 1
}
@@ -363,21 +363,21 @@ auto_type_def() {
else
for word in $_TSN_AUTOTYPE; do
case "$word" in
- ":delay") sleep 1 ;;
- ":tab") wtype -s "$_TSN_DELAY" -k Tab -- ;;
- ":space") wtype -s "$_TSN_DELAY" -k space -- ;;
- ":enter") wtype -s "$_TSN_DELAY" -k Return -- ;;
- ":otp") key_otp ;;
- path | basename | filename) auto_type "${_TSN_PASSFILE##*/}" ;;
- "$_TSN_USERKEY") auto_type "$_TSN_USERNAME" ;;
- pass | password) auto_type "$_TSN_PASSWORD" ;;
- *)
- if [[ -n ${_TSN_PASSDATA["$word"]} ]]; then
- auto_type "${_TSN_PASSDATA["$word"]}"
- else
- wtype -s "$_TSN_DELAY" -k space --
- fi
- ;;
+ ":delay") sleep 1 ;;
+ ":tab") wtype -s "$_TSN_DELAY" -k Tab -- ;;
+ ":space") wtype -s "$_TSN_DELAY" -k space -- ;;
+ ":enter") wtype -s "$_TSN_DELAY" -k Return -- ;;
+ ":otp") key_otp ;;
+ path | basename | filename) auto_type "${_TSN_PASSFILE##*/}" ;;
+ "$_TSN_USERKEY") auto_type "$_TSN_USERNAME" ;;
+ pass | password) auto_type "$_TSN_PASSWORD" ;;
+ *)
+ if [[ -n ${_TSN_PASSDATA["$word"]} ]]; then
+ auto_type "${_TSN_PASSDATA["$word"]}"
+ else
+ wtype -s "$_TSN_DELAY" -k space --
+ fi
+ ;;
esac
done
fi
@@ -416,7 +416,7 @@ wld_copy() {
{
sleep "$tsn_cliptime" || kill 0
wl-copy --clear
- } > /dev/null 2>&1 &
+ } >/dev/null 2>&1 &
unset -v tsn_cliptime
unset -v _TSN_PASSFILE _TSN_PASSDATA _TSN_USERNAME _TSN_PASSWORD _CHOSEN_KEY
@@ -443,87 +443,68 @@ validate_pass_backend() {
validate_dmenu_backend() {
if ! is_installed "$1"; then
- _die "please install a valid dmenu backend: fuzzel | tofi | mew | yofi | wofi | rofi | dmenu"
+ _die "please install a valid dmenu backend: fuzzel | mew | rofi | dmenu"
fi
- local -a mew_opts
case "$1" in
- fuzzel)
- _DMENU_BACKEND="fuzzel"
- _DMENU_BACKEND_OPTS=('-d' '--log-level=warning')
- ;;
- mew)
- _DMENU_BACKEND="mew"
- _DMENU_BACKEND_OPTS=()
- mew_opts=('-l' '10' '-n')
- if [[ -z ${BEMENU_OPTS[*]} ]]; then
- export BEMENU_OPTS="${mew_opts[*]}"
- fi
- ;;
- tofi)
- _DMENU_BACKEND="tofi"
- _DMENU_BACKEND_OPTS=()
- ;;
- yofi)
- _DMENU_BACKEND="yofi"
- # yofi needs the 'dialog' option after the '--config-file' argument
- _DMENU_BACKEND_OPTS=('dialog')
- ;;
- wofi)
- _DMENU_BACKEND="wofi"
- _DMENU_BACKEND_OPTS=('-d' '-k' '/dev/null')
- ;;
- rofi)
- _DMENU_BACKEND="rofi"
- _DMENU_BACKEND_OPTS=('-dmenu')
- ;;
- dmenu)
- _DMENU_BACKEND="dmenu"
- _DMENU_BACKEND_OPTS=()
- ;;
- *)
- _die "please install a valid dmenu backend: fuzzel | tofi | mew | yofi | wofi | rofi | dmenu"
- ;;
+ fuzzel)
+ _DMENU_BACKEND="fuzzel"
+ _DMENU_BACKEND_OPTS=('-d' '--log-level=warning')
+ ;;
+ mew)
+ _DMENU_BACKEND="mew"
+ _DMENU_BACKEND_OPTS=('-c' '-l' '10')
+ ;;
+ rofi)
+ _DMENU_BACKEND="rofi"
+ _DMENU_BACKEND_OPTS=('-dmenu')
+ ;;
+ dmenu)
+ _DMENU_BACKEND="dmenu"
+ _DMENU_BACKEND_OPTS=()
+ ;;
+ *)
+ _die "please install a valid dmenu backend: fuzzel | mew | rofi | dmenu"
+ ;;
esac
- unset -v mew_opts
}
validate_action() {
case "$1" in
- autotype)
- if ! is_installed "wtype"; then
- _die "wtype is not installed, unable to autotype pass data"
- fi
+ autotype)
+ if ! is_installed "wtype"; then
+ _die "wtype is not installed, unable to autotype pass data"
+ fi
+ _TSN_ACTION="autotype"
+ ;;
+ copy)
+ if ! is_installed "wl-copy"; then
+ _die "wl-clipboard is not installed, unable to copy-paste pass data"
+ fi
+ _TSN_ACTION="copy"
+ ;;
+ both)
+ if ! is_installed "wtype"; then
+ _die "wtype is not installed, unable to autotype pass data"
+ elif ! is_installed "wl-copy"; then
+ _die "wl-clipboard is not installed, unable to copy-paste pass data"
+ fi
+ _TSN_ACTION="both"
+ ;;
+ default)
+ if is_installed "wtype" && is_installed "wl-copy"; then
+ _TSN_ACTION="default"
+ elif is_installed "wtype" && ! is_installed "wl-copy"; then
+ printf "%s\n" "wl-clipboard is not installed, unable to copy-paste pass data" >&2
_TSN_ACTION="autotype"
- ;;
- copy)
- if ! is_installed "wl-copy"; then
- _die "wl-clipboard is not installed, unable to copy-paste pass data"
- fi
+ elif ! is_installed "wtype" && is_installed "wl-copy"; then
+ printf "%s\n" "wtype is not installed, unable to autotype pass data" >&2
_TSN_ACTION="copy"
- ;;
- both)
- if ! is_installed "wtype"; then
- _die "wtype is not installed, unable to autotype pass data"
- elif ! is_installed "wl-copy"; then
- _die "wl-clipboard is not installed, unable to copy-paste pass data"
- fi
- _TSN_ACTION="both"
- ;;
- default)
- if is_installed "wtype" && is_installed "wl-copy"; then
- _TSN_ACTION="default"
- elif is_installed "wtype" && ! is_installed "wl-copy"; then
- printf "%s\n" "wl-clipboard is not installed, unable to copy-paste pass data" >&2
- _TSN_ACTION="autotype"
- elif ! is_installed "wtype" && is_installed "wl-copy"; then
- printf "%s\n" "wtype is not installed, unable to autotype pass data" >&2
- _TSN_ACTION="copy"
- elif ! is_installed "wtype" && ! is_installed "wl-copy"; then
- _die "please install at least one the following backends to use tessen: wtype | wl-clipboard "
- fi
- ;;
- *) _die "please specify a valid action: autotype | copy | both" ;;
+ elif ! is_installed "wtype" && ! is_installed "wl-copy"; then
+ _die "please install at least one the following backends to use tessen: wtype | wl-clipboard "
+ fi
+ ;;
+ *) _die "please specify a valid action: autotype | copy | both" ;;
esac
}
@@ -545,7 +526,7 @@ find_pass_backend() {
}
find_dmenu_backend() {
- local -a tmp_dmenu_arr=('fuzzel' 'tofi' 'mew' 'yofi' 'wofi' 'rofi' 'dmenu')
+ local -a tmp_dmenu_arr=('fuzzel' 'mew' 'rofi' 'dmenu')
local idx
for idx in "${tmp_dmenu_arr[@]}"; do
@@ -555,13 +536,13 @@ find_dmenu_backend() {
fi
done
if [[ -z $_DMENU_BACKEND ]]; then
- _die "please install a valid dmenu backend: fuzzel | tofi | mew | yofi | wofi | rofi | dmenu"
+ _die "please install a valid dmenu backend: fuzzel | mew | rofi | dmenu"
fi
unset -v idx tmp_dmenu_arr
}
is_installed() {
- if command -v "$1" > /dev/null 2>&1; then
+ if command -v "$1" >/dev/null 2>&1; then
return 0
else
return 1
@@ -599,8 +580,8 @@ usage: $prog [options]
$prog -c \$HOME/tsncfg specify a custom location for the $prog config file
-p, --pass, --pass= choose either 'pass' or 'gopass'
- -d, --dmenu, --dmenu= specify a dmenu backend - 'fuzzel', 'tofi',
- 'mew', 'yofi', 'wofi', 'rofi', and 'dmenu' are supported
+ -d, --dmenu, --dmenu= specify a dmenu backend - 'fuzzel', 'mew',
+ 'rofi', and 'dmenu' are supported
-a, --action, --action= choose either 'autotype', 'copy', or 'both'
omit this option to use the default behavior
-c, --config, --config= use a config file on a custom path
@@ -633,7 +614,7 @@ parse_config() {
elif [[ $line =~ $config_regex ]]; then
config_arr+=("$line")
fi
- done < "$_TSN_CONFIG"
+ done <"$_TSN_CONFIG"
for idx in "${config_arr[@]}"; do
key="${idx%=*}"
val="${idx#*\"}"
@@ -647,23 +628,13 @@ parse_config() {
elif [[ $key == "dmenu_backend" ]] && [[ -z $_DMENU_BACKEND ]]; then
validate_dmenu_backend "$val"
readonly _DMENU_BACKEND
- elif [[ $key == "action" ]] && unset -v _TSN_ACTION 2> /dev/null; then
+ elif [[ $key == "action" ]] && unset -v _TSN_ACTION 2>/dev/null; then
validate_action "$val"
readonly _TSN_ACTION
elif [[ $key == "fuzzel_config_file" ]] && [[ -f ${val@P} ]]; then
_TMP_FUZZEL_OPTS+=("--config=${val@P}")
- elif [[ $key == "tofi_config_file" ]] && [[ -f ${val@P} ]]; then
- _TMP_TOFI_OPTS+=("-c" "${val@P}")
elif [[ $key == "rofi_config_file" ]] && [[ -f ${val@P} ]]; then
_TMP_ROFI_OPTS+=("-config" "${val@P}")
- elif [[ $key == "wofi_config_file" ]] && [[ -f ${val@P} ]]; then
- _TMP_WOFI_OPTS+=("-c" "${val@P}")
- elif [[ $key == "wofi_style_file" ]] && [[ -f ${val@P} ]]; then
- _TMP_WOFI_OPTS+=("-s" "${val@P}")
- elif [[ $key == "wofi_color_file" ]] && [[ -f ${val@P} ]]; then
- _TMP_WOFI_OPTS+=("-C" "${val@P}")
- elif [[ $key == "yofi_config_file" ]] && [[ -f ${val@P} ]]; then
- _TMP_YOFI_OPTS+=("--config-file" "${val@P}")
elif [[ $key == "userkey" ]]; then
_TSN_USERKEY="$val"
elif [[ $key == "urlkey" ]]; then
@@ -691,87 +662,87 @@ main() {
while [[ $# -gt 0 ]]; do
_opt="$1"
case "$_opt" in
- -p | --pass)
- if [[ $# -lt 2 ]]; then
- _die "please specify a valid password store backend: pass | gopass"
- fi
- validate_pass_backend "$2"
- readonly _PASS_BACKEND
- shift
- ;;
- --pass=*)
- if [[ -z ${_opt##--pass=} ]]; then
- _die "please specify a valid password store backend: pass | gopass"
- fi
- validate_pass_backend "${_opt##--pass=}"
- readonly _PASS_BACKEND
- ;;
- -d | --dmenu)
- if [[ $# -lt 2 ]]; then
- _die "please install a valid dmenu backend: fuzzel | tofi | mew | yofi | wofi | rofi | dmenu"
- fi
- validate_dmenu_backend "$2"
- readonly _DMENU_BACKEND
- # since there's a possibility that a user may mention config files for
- # dmenu backends, we will make _DMENU_BACKEND_OPTS readonly only if
- # _DMENU_BACKEND is mew, the only dmenu program which don't support
- # configuration files
- if [[ $_DMENU_BACKEND == "mew" ]] || [[ $_DMENU_BACKEND == "dmenu" ]]; then
- readonly _DMENU_BACKEND_OPTS
- fi
- shift
- ;;
- --dmenu=*)
- if [[ -z ${_opt##--dmenu=} ]]; then
- _die "please install a valid dmenu backend: fuzzel | tofi | mew | yofi | wofi | rofi | dmenu"
- fi
- validate_dmenu_backend "${_opt##--dmenu=}"
- readonly _DMENU_BACKEND
- if [[ $_DMENU_BACKEND == "mew" ]] || [[ $_DMENU_BACKEND == "dmenu" ]]; then
- readonly _DMENU_BACKEND_OPTS
- fi
- ;;
- -a | --action)
- if [[ $# -lt 2 ]]; then
- _die "please specify a valid action: autotype | copy | both"
- fi
- validate_action "$2"
- readonly _TSN_ACTION
- shift
- ;;
- --action=*)
- if [[ -z ${_opt##--action=} ]]; then
- _die "please specify a valid action: autotype | copy | both"
- fi
- validate_action "${_opt##--action=}"
- readonly _TSN_ACTION
- ;;
- -c | --config)
- if [[ $# -lt 2 ]] || ! [[ -f $2 ]]; then
- _die "please specify a valid path for the configuration file of tessen"
- fi
- _TSN_CONFIG="$2"
- shift
- ;;
- --config=*)
- if ! [[ -f ${_opt##--config=} ]]; then
- _die "please specify a valid path for the configuration file of tessen"
- fi
- _TSN_CONFIG="${_opt##--config=}"
- ;;
- -h | --help)
- print_help
- exit 0
- ;;
- -v | --version)
- printf "%s\n" "$tsn_version"
- exit 0
- ;;
- --)
- shift
- break
- ;;
- *) _die "invalid argument detected" ;;
+ -p | --pass)
+ if [[ $# -lt 2 ]]; then
+ _die "please specify a valid password store backend: pass | gopass"
+ fi
+ validate_pass_backend "$2"
+ readonly _PASS_BACKEND
+ shift
+ ;;
+ --pass=*)
+ if [[ -z ${_opt##--pass=} ]]; then
+ _die "please specify a valid password store backend: pass | gopass"
+ fi
+ validate_pass_backend "${_opt##--pass=}"
+ readonly _PASS_BACKEND
+ ;;
+ -d | --dmenu)
+ if [[ $# -lt 2 ]]; then
+ _die "please install a valid dmenu backend: fuzzel | mew | rofi | dmenu"
+ fi
+ validate_dmenu_backend "$2"
+ readonly _DMENU_BACKEND
+ # since there's a possibility that a user may mention config files for
+ # dmenu backends, we will make _DMENU_BACKEND_OPTS readonly only if
+ # _DMENU_BACKEND is mew, the only dmenu program which don't support
+ # configuration files
+ if [[ $_DMENU_BACKEND == "mew" ]] || [[ $_DMENU_BACKEND == "dmenu" ]]; then
+ readonly _DMENU_BACKEND_OPTS
+ fi
+ shift
+ ;;
+ --dmenu=*)
+ if [[ -z ${_opt##--dmenu=} ]]; then
+ _die "please install a valid dmenu backend: fuzzel | mew | rofi | dmenu"
+ fi
+ validate_dmenu_backend "${_opt##--dmenu=}"
+ readonly _DMENU_BACKEND
+ if [[ $_DMENU_BACKEND == "mew" ]] || [[ $_DMENU_BACKEND == "dmenu" ]]; then
+ readonly _DMENU_BACKEND_OPTS
+ fi
+ ;;
+ -a | --action)
+ if [[ $# -lt 2 ]]; then
+ _die "please specify a valid action: autotype | copy | both"
+ fi
+ validate_action "$2"
+ readonly _TSN_ACTION
+ shift
+ ;;
+ --action=*)
+ if [[ -z ${_opt##--action=} ]]; then
+ _die "please specify a valid action: autotype | copy | both"
+ fi
+ validate_action "${_opt##--action=}"
+ readonly _TSN_ACTION
+ ;;
+ -c | --config)
+ if [[ $# -lt 2 ]] || ! [[ -f $2 ]]; then
+ _die "please specify a valid path for the configuration file of tessen"
+ fi
+ _TSN_CONFIG="$2"
+ shift
+ ;;
+ --config=*)
+ if ! [[ -f ${_opt##--config=} ]]; then
+ _die "please specify a valid path for the configuration file of tessen"
+ fi
+ _TSN_CONFIG="${_opt##--config=}"
+ ;;
+ -h | --help)
+ print_help
+ exit 0
+ ;;
+ -v | --version)
+ printf "%s\n" "$tsn_version"
+ exit 0
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *) _die "invalid argument detected" ;;
esac
shift
done
@@ -785,18 +756,9 @@ main() {
parse_config
if [[ $_DMENU_BACKEND == "fuzzel" ]]; then
_DMENU_BACKEND_OPTS+=("${_TMP_FUZZEL_OPTS[@]}")
- elif [[ $_DMENU_BACKEND == "tofi" ]]; then
- _DMENU_BACKEND_OPTS+=("${_TMP_TOFI_OPTS[@]}")
- readonly _DMENU_BACKEND_OPTS
elif [[ $_DMENU_BACKEND == "rofi" ]]; then
_DMENU_BACKEND_OPTS+=("${_TMP_ROFI_OPTS[@]}")
readonly _DMENU_BACKEND_OPTS
- elif [[ $_DMENU_BACKEND == "wofi" ]]; then
- _DMENU_BACKEND_OPTS+=("${_TMP_WOFI_OPTS[@]}")
- readonly _DMENU_BACKEND_OPTS
- elif [[ $_DMENU_BACKEND == "yofi" ]]; then
- _DMENU_BACKEND_OPTS=("${_TMP_YOFI_OPTS[@]}" "$_DMENU_BACKEND_OPTS")
- readonly _DMENU_BACKEND_OPTS
fi
# initialize basic options for users who expect sane defaults and don't use
@@ -810,7 +772,7 @@ main() {
validate_dmenu_backend "$_DMENU_BACKEND"
readonly _DMENU_BACKEND
fi
- if unset -v _TSN_ACTION 2> /dev/null; then
+ if unset -v _TSN_ACTION 2>/dev/null; then
validate_action "default"
readonly _TSN_ACTION
fi