2022-06-29 06:34:05 +00:00
# bemoji ❤️ - Quickly ⛏️ your 🌟
2021-12-01 14:51:37 +00:00
2022-08-06 11:06:08 +00:00
[![status-badge ](https://ci.martyoeh.me/api/badges/Marty/bemoji/status.svg )](https://ci.martyoeh.me/Marty/bemoji)
2021-12-01 14:57:12 +00:00
![bemoji picker interface on bemenu ](assets/bemenu.png )
2021-12-01 14:51:37 +00:00
Emoji picker with support for bemenu/wofi/rofi/dmenu and wayland/X11.
Will remember your favorite emojis and give you quick access.
## 📁 Installation
2022-06-29 06:34:05 +00:00
### Dependencies
2023-11-28 09:53:31 +00:00
* One of `bemenu` , `wofi` , `rofi` , `dmenu` , `ilia` , `fuzzel` or supplying your own picker.
2022-06-29 06:34:05 +00:00
* One of `wl-copy` , `xclip` , `xsel` or supplying your own clipboard tool.
* One of `wtype` , `xdotool` or supplying your own typing tool.
* `sed` , `grep` , `cut` , `sort` , `uniq` , `tr` , `curl` if using the download functionality.
To see how to substitute the default choices with your own tools,
see Options below.
2021-12-01 14:57:12 +00:00
![rofi picker interface ](assets/rofi.png )
2022-06-29 06:34:05 +00:00
### Manual
2021-12-01 14:51:37 +00:00
Option 1. Clone the repository and put the executable somewhere in your path:
```bash
git clone < INSERT-REPOSITORY >
chmod +x bemoji/bemoji
mv bemoji/bemoji /usr/local/bin/bemoji
rm -r bemoji
```
Option 2. Clone the repository and link the executable to your path:
```bash
git clone < INSERT-REPOSITORY >
chmod +x bemoji/bemoji
ln -s bemoji/bemoji /usr/local/bin/bemoji
```
2022-06-29 06:34:05 +00:00
### Arch Linux
2021-12-01 14:51:37 +00:00
2023-04-11 21:17:52 +00:00
On Arch Linux, bemoji has been packaged for the [AUR ](https://aur.archlinux.org/packages?K=bemoji ) so it can be installed manually from here or easily with your preferred AUR helper, e.g.:
2021-12-01 14:51:37 +00:00
2022-06-29 06:34:05 +00:00
```bash
2023-08-25 18:55:25 +00:00
paru -S bemoji # or bemoji-git
2022-06-29 06:34:05 +00:00
```
2021-12-01 14:51:37 +00:00
## 💿 Usage
2021-12-01 14:57:12 +00:00
![wofi picker interface ](assets/wofi.png )
2021-12-01 14:51:37 +00:00
Simply execute `bemoji` without any options to set up the default emoji database and let you quickly pick an emoji.
It will be copied to your clipboard for you to paste anywhere.
If you execute `bemoji -t` it will directly type your emoji directly into whatever application is in focus.
When the emoji list is open you can always press `Alt+1` to send the selected emoji to clipboard and `Alt+2` to type the selected emoji,
2021-12-01 14:57:12 +00:00
regardless of what the default action is set to.
(Currently works in bemenu and rofi.)
2021-12-01 14:51:37 +00:00
2022-06-29 06:34:05 +00:00
You can also map the picker to a key combination for quick access, e.g.
2021-12-01 14:51:37 +00:00
In `swaywm` , put the following in `~/.config/sway/config` :
```
bindsym Mod4+Shift+e exec bemoji -t
```
For `i3` , put the same into `~/.config/i3/config` :
```
bindsym Mod4+Shift+e exec bemoji -t
```
For `riverwm` , put the following in `~/.config/river/init` :
```
2023-04-11 21:25:41 +00:00
riverctl map normal Mod4+Shift E spawn "bemoji -t"
2021-12-01 14:51:37 +00:00
```
In `sxhkd` , put the following into `~/.config/sxhkd/sxhkdrc` :
```
super + Shift + e
bemoji -t
```
And you can easily type any emoji with the help of `Super+Shift+E` .
## 🧰 Options
2021-12-01 14:57:12 +00:00
![bemoji help window ](assets/help.png )
2021-12-01 14:51:37 +00:00
bemoji comes with a couple of options to specify actions, emoji libraries and directories being used.
### Adding your own emoji
Simply put your own emoji list into the bemoji data directory.
2022-06-29 06:34:05 +00:00
By default, the directory will be at your `$XDG_DATA_HOME/bemoji` location -
2021-12-01 14:51:37 +00:00
most likely this is `~/.local/share/bemoji` .
Add any number of `.txt` files containing additional emoji to this directory:
```
🫦 Biting lip
🫶 Heart Hands
```
The lists *need* to have the format `🙂 description of emoji` with a whitespace separating the emoji and its description.
The description can have as many words and whitespaces as you want.
### Ignoring the most recent emoji
By default, bemoji will sort the list it displays by your most frequently and most recently used emoji.
To disable this behavior, execute bemoji like the following:
```bash
2023-08-26 12:37:44 +00:00
bemoji --hist-limit 0
2021-12-01 14:51:37 +00:00
```
2023-04-30 16:16:26 +00:00
This will stop bemoji from adding recently used emoji before displaying the list.
2021-12-01 14:51:37 +00:00
You can also stop bemoji from adding any emoji to your history in the first place:
```bash
2023-08-26 12:37:44 +00:00
bemoji --private
2021-12-01 14:51:37 +00:00
```
2022-06-29 06:34:05 +00:00
This will not add any of the emoji you pick to your recent emojis.
2023-08-26 12:37:44 +00:00
Put both together to completely ignore the recent emoji feature of the program
(these are the equivalent short versions of the options above):
2021-12-01 14:51:37 +00:00
```bash
2023-04-30 16:16:26 +00:00
bemoji -p -P0
2021-12-01 14:51:37 +00:00
```
Like this, you'll be hiding any recent personal emoji and no one will know that you always type 👄🍆💦.
2023-04-30 16:16:26 +00:00
To limit the number of your recently used emoji that are shown without hiding them completely simply increase the number to however many you wish to display.
For example, to display only the top 4 recently used emoji:
```bash
2023-08-26 12:37:44 +00:00
bemoji --hist-limit 4
2023-04-30 16:16:26 +00:00
```
2021-12-01 14:51:37 +00:00
The recent list will also contain emoji that are *not* usually on your lists,
2022-06-29 06:34:05 +00:00
so kept in single-use lists for example.
2021-12-01 14:51:37 +00:00
If you don't wish those to show up, make use of these options.
2023-04-30 16:16:26 +00:00
### Setting custom directories and editing history
2021-12-01 14:51:37 +00:00
2022-11-03 14:35:06 +00:00
By default bemoji stores your recent history in `$XDG_STATE_HOME/bemoji-history.txt` ,
so most often in `~/.local/state/bemoji-history.txt`
2021-12-01 14:51:37 +00:00
2023-04-30 16:16:26 +00:00
You can edit this file in any text editor to change your recent history,
removing, adding or changing the emoji appearing there.
2021-12-01 14:51:37 +00:00
You can overwrite the directories bemoji uses for its emoji lists and history files with the following two environment variables:
```
BEMOJI_DB_LOCATION=/path/to/my/emoji/directory
2022-11-03 14:35:06 +00:00
BEMOJI_HISTORY_LOCATION=/path/to/my/state/directory
2021-12-01 14:51:37 +00:00
```
There are no equivalent commandline arguments to overwrite these two settings.
### Display one custom emoji list
A custom emoji list can be supplied as commandline argument `-f` or `BEMOJI_CUSTOM_LIST` environment variable.
```bash
2023-08-26 12:37:44 +00:00
bemoji --file path/to/my/list.txt
2021-12-01 14:51:37 +00:00
```
2022-06-29 06:34:05 +00:00
The list will override the normally presented emoji,
so that only the custom list and recent emoji will be displayed.
2021-12-01 14:51:37 +00:00
To display *only* the emoji list passed in, pass an extra `-P` flag to bemoji.
The path can also be a weblink which bemoji will download and use:
2022-09-27 19:01:44 +00:00
```bash
2021-12-01 14:51:37 +00:00
bemoji -f "https://raw.githubusercontent.com/jchook/emoji-menu/master/data/emojis.txt"
```
2023-05-01 13:53:19 +00:00
### Download additional emoji sets
2021-12-01 14:51:37 +00:00
2022-11-04 16:22:47 +00:00
bemoji automatically downloads an emoji list for you to use on first invocation.
2023-05-01 13:53:19 +00:00
By default, it only downloads emoji, though you can have it download math symbols and nerdfont icons as well.
2022-11-04 16:22:47 +00:00
To download additional sets, execute bemoji like the following:
2021-12-01 14:51:37 +00:00
```bash
2023-08-26 12:37:44 +00:00
bemoji --download all
2021-12-01 14:51:37 +00:00
```
2023-05-01 13:53:19 +00:00
This will download *all* default sets bemoji knows - which is currently the default emoji list, nerd font icons, and a long list of math symbols.
Other valid options for this setting are `emoji` , `math` , `nerd` , `none` .
2021-12-01 14:51:37 +00:00
2022-11-04 16:22:47 +00:00
```bash
2023-05-01 13:53:19 +00:00
bemoji -D "math emoji nerd"
2022-11-04 16:22:47 +00:00
```
2023-08-26 12:37:44 +00:00
The above command is equivalent to the previous `all` as you can mention multiple sets you want downloaded.
2022-11-04 16:22:47 +00:00
2022-06-29 06:34:05 +00:00
If set to `none` and no files are in the emoji directory,
2022-11-04 16:22:47 +00:00
bemoji will complain and not show anything.
2021-12-01 14:51:37 +00:00
2022-09-27 19:01:44 +00:00
### Do not skip to new line after output
By default, bemoji will craft the final output using a typical `echo` call for anything it prints directly.
That means, it will also contain a final newline character.
So, for example it would technically output `🦊\n` for the `fox` emoji,
which skips to a new line in most circumstances.
If you wish to prevent this character in the final output, use:
```bash
bemoji -n
```
Using this option will suppress the newline character and *only* print `🦊` as its output.
2021-12-01 14:51:37 +00:00
### Using a custom tool for picking, clipping, typing
If you want to replace one of the default supported tools with your own you can do this through environment variables:
```bash
BEMOJI_PICKER_CMD="path/to/your/picker-tool"
BEMOJI_CLIP_CMD="path/to/your/clipboard/tool"
BEMOJI_TYPE_CMD="path/to/your/xdotool"
```
2023-04-11 20:55:23 +00:00
The candidate list (in the case of picker tool) or the picked selection are passed to the tools through stdin.
2021-12-01 14:51:37 +00:00
This is pretty experimental and you'll have to see how well it works for you.
The setting can not be changed through the commandline alone.
### Execute a custom command with my emoji
You can execute bemoji with the `-e` flag with which you tell it not to do anything but echo out the chosen emoji.
This can be very useful for creating your own little script with it:
```bash
2023-08-26 12:37:44 +00:00
bemoji --echo | cat < (echo -n "https://emojipedia.org/") - | xargs xdg-open
2021-12-01 14:51:37 +00:00
```
This snippet will open a wiki page for the picked emoji in your browser.
2022-06-29 06:34:05 +00:00
Of course, there are many more possibilities.
2021-12-01 14:51:37 +00:00
This is just an example to show how the echo mode works.
### A list of all environment variables
2022-06-29 06:34:05 +00:00
What follows is a list of all environment variables bemoji understands,
2021-12-01 14:51:37 +00:00
with their default settings
```bash
2023-04-30 16:16:26 +00:00
BEMOJI_DB_LOCATION="$XDG_DATA_HOME/bemoji" # where the emoji lists reside
BEMOJI_HISTORY_LOCATION="$XDG_STATE_HOME" # where the state file resides
2021-12-01 14:51:37 +00:00
BEMOJI_CUSTOM_LIST="" # the custom emoji list to display
BEMOJI_DOWNLOAD_LIST="" # the default emoji lists to download to database
2023-04-30 16:16:26 +00:00
BEMOJI_DEFAULT_COMMAND="" # which command to invoke by default
BEMOJI_PICKER_CMD="bemenu" # which picker tool to use
BEMOJI_CLIP_CMD="wl-copy" # which clipboard tool to use
BEMOJI_TYPE_CMD="wtype" # which typing tool to use (ydotool will NOT work)
2021-12-01 14:51:37 +00:00
BEMOJI_PRIVATE_MODE=false # whether to save new entries
2023-04-30 16:16:26 +00:00
BEMOJI_LIMIT_RECENT="" # whether to display recent entries
2022-09-27 19:01:44 +00:00
BEMOJI_ECHO_NEWLINE=true # whether to end the output with a newline character
2021-12-01 14:51:37 +00:00
```
2021-12-01 14:57:12 +00:00
## 🤗 Issues
2021-12-01 14:51:37 +00:00
Thanks for checking this program out! ❤
If there are any problems, don't hesitate to open an issue.
2021-12-01 14:57:12 +00:00
2021-12-01 14:51:37 +00:00
If you have an idea or improvement, don't hesitate to open a merge request!
2022-06-29 10:44:03 +00:00
### Running tests
This project makes use of [bash-bats ](https://github.com/bats-core/bats-core ) (community fork) to test some of its functionality.
2023-09-14 15:14:39 +00:00
To run the tests locally:
```
git submodule init
git submodule update
./test/bats/bin/bats test
```
2022-06-29 10:44:03 +00:00
I would suggest running the test suite in docker instead, just to minimize the possibility of something going awry and borking up your local file system.
2023-09-14 15:14:39 +00:00
To run the tests in a docker suite, execute `docker run --rm -it -v "$PWD:/code" bats/bats:latest /code/test` after initializing the git submodules as listed above.