Browse Source

Support alternative emoji lists

Now that we have cli args, you can actually configure rofimoji easily.
This is quite nice :)
tags/3.0.0
Fabian Winter 4 months ago
parent
commit
a7319d95c7
3 changed files with 28 additions and 5 deletions
  1. 2
    0
      CHANGELOG.md
  2. 2
    0
      README.md
  3. 24
    5
      rofimoji.py

+ 2
- 0
CHANGELOG.md View File

@@ -1,8 +1,10 @@
# [3.0.0]
## Added
- You can choose a new input method: `rofimoji` can copy your emojis, paste them into the application and restore the previous contents
- There are now more keywords included so you can find the appropriate emoji more easily
- You can select a skin tone by default using cli args
- You can pass arguments to rofi using `--rofi-args`
- And you can use alternative emoji lists when you provide the `--emoji-file` parameter

# [2.1.0]
## Changed

+ 2
- 0
README.md View File

@@ -27,6 +27,8 @@ You can choose a skin tone with the `--skin-tone` (or `-s`) parameter. The avail

If you have any arguments for rofi, you can make `rofimoji` pass them through like this: `rofimoji --rofi-args="-columns 3"`.

You can also define your own set of emojis (or whatever) and use `rofimoji` to pick them by providing the `--emoji-file` (`-f`) parameter. This could be helpful if you want them ordered in some way, only use a subset or if you want non-English descriptions.

## Installation

### Arch

+ 24
- 5
rofimoji.py View File

@@ -3,7 +3,7 @@
import argparse
import sys
from subprocess import Popen, PIPE
from typing import List, Tuple
from typing import List, Tuple, Union

emoji_list = """😀 grinning face <small>(face, grin, grinning face)</small>
😃 grinning face with big eyes <small>(face, grinning face with big eyes, mouth, open, smile)</small>
@@ -1755,7 +1755,7 @@ def main() -> None:
args = parse_arguments()
active_window = get_active_window()

returncode, stdout = open_main_rofi_window(args)
returncode, stdout = open_main_rofi_window(args.rofi_args, load_emojis(args.file))

if returncode == 1:
sys.exit()
@@ -1792,6 +1792,14 @@ def parse_arguments() -> argparse.Namespace:
help='Decide on a skin-tone for all supported emojis. If not set (or set to "ask"), '
'you will be asked for each one '
)
parser.add_argument(
'--emoji-file',
'-f',
dest='file',
action='store',
default=None,
help='Read emojis from this file instead, one entry per line'
)
parser.add_argument(
'--rofi-args',
dest='rofi_args',
@@ -1810,7 +1818,18 @@ def get_active_window() -> str:
return xdotool.communicate()[0].decode("utf-8")[:-1]


def open_main_rofi_window(args) -> Tuple[int, bytes]:
def load_emojis(file_name: Union[str, None]):
if file_name is not None:
try:
with open(file_name, "r") as file:
return file.read()
except IOError:
return emoji_list
else:
return emoji_list


def open_main_rofi_window(args: List[str], emojis: str) -> Tuple[int, bytes]:
rofi = Popen(
[
'rofi',
@@ -1826,12 +1845,12 @@ def open_main_rofi_window(args) -> Tuple[int, bytes]:
'Alt+t',
'-kb-custom-3',
'Alt+p',
*args.rofi_args
*args
],
stdin=PIPE,
stdout=PIPE
)
(stdout, _) = rofi.communicate(input=emoji_list.encode('utf-8'))
(stdout, _) = rofi.communicate(input=emojis.encode('UTF-8'))
return rofi.returncode, stdout



Loading…
Cancel
Save