Browse Source

Show modified emoji when asking for skin tone

Instead of just showing the skin tones in the second selection step, why
not show the complete emoji with modifiers? This is a lot friendlier
than just showing the modification all alone.
tags/2.0.0
Fabian Winter 1 year ago
parent
commit
96dcd6be99
1 changed files with 15 additions and 9 deletions
  1. 15
    9
      rofimoji.py

+ 15
- 9
rofimoji.py View File

@@ -1661,16 +1661,22 @@ skin_tone_selectable_emojis = {'🏄', '👼', '💂', '✌', '👃', '🧙', '
'🦵', '👇', '🕺', '🦹', '🧗', '👩', '🕵', '💆', '🦶', '🤰', '🤘',
'🤦', '🤷', '👉', '👳', '🎅', '🤙'}

fitzpatrick_modifiers = """ neutral
🏻 light skin
🏼 medium-light skin
🏽 moderate skin
🏾 dark brown skin
🏿 black skin
"""
fitzpatrick_modifiers = {
'': 'neutral',
'🏻': 'light skin',
'🏼': 'medium-light skin',
'🏽': 'moderate skin',
'🏾': 'dark brown skin',
'🏿': 'black skin'
}


def select_skin_tone(selected_emoji: chr):
modified_emojis = '\n'.join(map(
lambda modifier: selected_emoji + modifier + " " + fitzpatrick_modifiers[modifier],
fitzpatrick_modifiers.keys()
))

rofi_skin = Popen(
args=[
'rofi',
@@ -1686,7 +1692,7 @@ def select_skin_tone(selected_emoji: chr):
stdout=PIPE
)

(stdout_skin, _) = rofi_skin.communicate(input=fitzpatrick_modifiers.encode('utf-8'))
(stdout_skin, _) = rofi_skin.communicate(input=modified_emojis.encode('utf-8'))

if rofi_skin.returncode == 1:
return ''
@@ -1717,7 +1723,7 @@ else:
emoji = line.split()[0].decode('utf-8')

if emoji in skin_tone_selectable_emojis:
emoji = emoji + select_skin_tone(emoji)
emoji = select_skin_tone(emoji)

if rofi.returncode == 0:
time.sleep(0.1)

Loading…
Cancel
Save