├── README.md ├── enclosed_script └── img ├── bphonehphone.jpg ├── menushort.jpg ├── multipleymlfiles-work.jpg ├── multipleymlfiles.jpg └── submenu.jpg /README.md: -------------------------------------------------------------------------------- 1 | # Espanso Triggers 2 | [Espanso](https://espanso.org/) lacks a menu with all user defined triggers. 3 | **Espanso Triggers** is a tiny companion script to list all user defined triggers in the Mac OS X menu bar. 4 | [Platypus](https://sveinbjorn.org/platypus) is used to create a menulet from the bash script. 5 | 6 | ## Features 7 | * replaces the Espanso menulet 8 | * pause and restart the Espanso service from the menu 9 | * the Espanso YAML file can be edited from the menu 10 | * triggers can be selected and started directly from the menu 11 | * supports multiple YAML trigger files 12 | * lists all user defined triggers 13 | * optional comments to a trigger 14 | * lists installed [Espanso Packages](https://hub.espanso.org/) in sub-menus 15 | * each sub-menu is labeled with a small Espanso 'e' and the package name 16 | 17 | ### Espanso Triggers Menu with one or multiple yml files 18 | ![](img/menushort.jpg) ![](img/multipleymlfiles.jpg) 19 | 20 | ### Espanso Triggers Menu with package sub menu 21 | ![](img/submenu.jpg) 22 | 23 | ## Download and install 24 | Download the latest version of EspansoTriggers.zip from [Releases](https://github.com/einstweilen/espanso-triggers/releases/). 25 | Unzip the file and place it somewhere in your Applications folder. 26 | 27 | ## How to use 28 | Double click the **Espanso Triggers** app and a small Espanso 'e' is added to the menu bar. Click on the 'e' to see a list of all of your triggers. 29 | If you want to start **Espanso Triggers** on every boot, add it to your login items (Apple menu > System Preferences > Users & Groups > Login Items) 30 | 31 | ## How to remove the now superfluous old Espanso 'e' 32 | The standard Espanso menulet is no longer needed as all functions are included in **Espanso Triggers**. 33 | If you want to hide the original menulet select "Edit triggers…" and the default YAML file is opened. 34 | Add `show_icon: false` at the top of the file and save the changes. 35 | After restarting Espanso (select the *Pause Espanso* menu item and afterwards the *Restart Espanso* menu item) only the **Espanso Triggers** 'e' will be displayed. 36 | 37 | ## Multiple trigger files 38 | When there are more than one YAML trigger file in the Espanso directory `Preferences/espanso` the triggers will be listed in groups with the filename as group name e.g `work.yml` becomes 39 | ![](img/multipleymlfiles-work.jpg) 40 | 41 | ## How to add comments to triggers 42 | To help you to memorize your different triggers a short comment can be added right after the trigger 43 | 44 | `trigger: "+hphone" # private` 45 | 46 | `trigger: "+bphone" # business` 47 | 48 | ![](img/bphonehphone.jpg) 49 | 50 | ## How to use your own text editor 51 | *Edit triggers…* opens the file ‘default.yml‘ in the standard text editor. 52 | 53 | To use your own editor change the *open -e* command in line #15 of *Espanso Triggers.app/Contents/Resources/script* to ‘open -a "YourEditor" -e $HOME/Library/Preferences/espanso/default.yml‘. 54 | 55 | e.g. if you want to use [Visual Studio Code](https://code.visualstudio.com/) 56 | `open -a "Visual Studio Code" -e $HOME/Library/Preferences/espanso/default.yml` 57 | 58 | ## History 59 | 2021-04-22 Initial Release 60 | 61 | 2021-05-05 NEW group triggers by file, FIX remove empty line from package sub menu 62 | 63 | ### Disclaimer 64 | The menulet is provided as is. It is tested under OS X 10.13 High Siera 65 | Espanso and Playtypus are open source software, you can make a donation to the developers on their websites. 66 | 67 | ### Reference 68 | [Espanso](https://espanso.org/) by Federico Terzi is an open-source cross-platform (Win/Mac/Linux) text expander 69 | 70 | [Platypus](https://sveinbjorn.org/platypus) by Sveinbjorn Thordarson creates native Mac applications from command line scripts such as shell scripts or Python, Perl, Ruby, Tcl, JavaScript and PHP programs. 71 | -------------------------------------------------------------------------------- /enclosed_script: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # https://github.com/einstweilen/espanso-triggers 4 | # 2021-05-05 5 | 6 | if [ -n "$1" ]; then 7 | case "$1" in 8 | 'Restart Espanso' ) 9 | /usr/local/bin/espanso restart 10 | ;; 11 | 'Pause Espanso' ) 12 | /usr/local/bin/espanso stop 13 | ;; 14 | 'Edit triggers…' ) 15 | open -e "$HOME/Library/Preferences/espanso/default.yml" 16 | ;; 17 | *) 18 | trigger=$(grep -o "[^# ]*" <<<"$1") 19 | osascript <<-EndOfScript 20 | tell application "System Events" to keystroke "$trigger" 21 | EndOfScript 22 | ;; 23 | esac 24 | fi 25 | 26 | # Espanso start/stop 27 | if grep -q not <<< "$(/usr/local/bin/espanso status)"; then 28 | echo "Restart Espanso" 29 | else 30 | echo "Pause Espanso" 31 | fi 32 | 33 | echo "Edit triggers…" 34 | echo "----" 35 | 36 | # list user triggers 37 | if [[ $(ls 2>/dev/null -U $HOME/Library/Preferences/espanso/*.yml | wc -l ) -gt 1 ]]; then 38 | for yfile in $HOME/Library/Preferences/espanso/*.yml; do 39 | echo "DISABLED|MENUITEMICON|AppIcon.icns|$(basename "$yfile" .yml)" 40 | grep -oh ' trigger.*' "$yfile" | sort | 41 | sed 's/trigger:[^\"]*\(.*\)/\1/g' | tr -d '\"' 42 | done 43 | else 44 | grep -oh ' trigger.*' $HOME/Library/Preferences/espanso/*.yml | sort | 45 | sed 's/trigger:[^\"]*\(.*\)/\1/g' | tr -d '\"' 46 | fi 47 | 48 | # list installed packages 49 | cd "$(/usr/local/bin/espanso path | grep -F Packages | cut -f 2- -d' ')" || exit 50 | 51 | if [ $(find . -type d | wc -l) -ne 0 ]; then 52 | echo "----" 53 | find . -name '*.yml' | sort | 54 | while read line; do 55 | trig_cnt=$(grep -c -F ' trigger' "$line") 56 | trig_menu=$(sed 's:./\([^//]*\).*:\1:' <<<"$line") 57 | trig_list="$(grep -o ' trigger.*' "$line" | 58 | sort | sed 's/trigger:[^\"]*\(.*\)/\1/g' | 59 | tr -d '\"' | tr '\n' '|')" 60 | echo "DISABLED|MENUITEMICON|AppIcon.icns|$trig_menu" 61 | echo "SUBMENU|$trig_cnt triggers in $trig_menu|${trig_list%?}" 62 | done 63 | fi 64 | -------------------------------------------------------------------------------- /img/bphonehphone.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/einstweilen/espanso-triggers/4442e9712e3ce00120b8fbd3b26df06b91f64a29/img/bphonehphone.jpg -------------------------------------------------------------------------------- /img/menushort.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/einstweilen/espanso-triggers/4442e9712e3ce00120b8fbd3b26df06b91f64a29/img/menushort.jpg -------------------------------------------------------------------------------- /img/multipleymlfiles-work.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/einstweilen/espanso-triggers/4442e9712e3ce00120b8fbd3b26df06b91f64a29/img/multipleymlfiles-work.jpg -------------------------------------------------------------------------------- /img/multipleymlfiles.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/einstweilen/espanso-triggers/4442e9712e3ce00120b8fbd3b26df06b91f64a29/img/multipleymlfiles.jpg -------------------------------------------------------------------------------- /img/submenu.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/einstweilen/espanso-triggers/4442e9712e3ce00120b8fbd3b26df06b91f64a29/img/submenu.jpg --------------------------------------------------------------------------------