aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Étienne Deparis 2020-08-17 15:58:01 +0200
committerGravatar Étienne Deparis 2020-08-17 15:59:29 +0200
commit553982b85a528b86a413269ffb4b821fd24fdaea (patch)
tree34f07188ad6ed167abdbabe09a5240cf483a4ccf
parent27de43ce0c95fed3b0b5fd16610d9ae545cfcd4c (diff)
downloadshell_utils-553982b85a528b86a413269ffb4b821fd24fdaea.tar.gz
shell_utils-553982b85a528b86a413269ffb4b821fd24fdaea.tar.xz
shell_utils-553982b85a528b86a413269ffb4b821fd24fdaea.zip
feat(emojis_music.py): List all known emojis
-rw-r--r--.gitignore1
-rw-r--r--emojis_list.rb84
-rwxr-xr-xemojis_music.py47
3 files changed, 108 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index 22d0d82..1c77ad4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
vendor
+emojis_cache.txt
diff --git a/emojis_list.rb b/emojis_list.rb
new file mode 100644
index 0000000..10ef0d1
--- /dev/null
+++ b/emojis_list.rb
@@ -0,0 +1,84 @@
+# frozen_string_literal: true
+
+require 'uri'
+require 'net/http'
+
+data = Net::HTTP.get(
+ URI('https://unicode.org/Public/emoji/13.0/emoji-test.txt')
+)
+emojis_list = []
+data.force_encoding('UTF-8').split("\n").each do |line|
+ line.strip!
+ next if line == '' || line[0] == '#'
+ ldata = line.split(';').map(&:strip)
+ emoji_points = ldata[0].split
+ emoji = emoji_points.map { |c| [c.hex].pack('U') }.join('')
+ matches = /\A(component|(?:fully-|minimally-|un)qualified)\s+# \S+ E[0-9.]+ (.*)\Z/.match(ldata[1])
+ next unless matches
+ next unless matches[1] == 'fully-qualified'
+ label = matches[2]
+ if emoji_points[0] == '2714'
+ label = 'heavy check mark ok yes'
+ elsif emoji_points[0] == '274C'
+ label += ' no x'
+ elsif emoji_points[0] == '2764'
+ label += ' <3'
+ elsif emoji_points[0] == '1F389'
+ label += ' yeah party'
+ elsif emoji_points[0] == '1F44C'
+ label.downcase!
+ elsif emoji_points[0] == '1F44D'
+ label += ' top +1'
+ elsif emoji_points[0] == '1F44E'
+ label += ' -1'
+ elsif emoji_points[0] == '1F4A1'
+ label += ' idea'
+ elsif emoji_points[0] == '1F4A4'
+ label += ' zzz ZZZ'
+ elsif emoji_points[0] == '1F4A9'
+ label += ' poop'
+ elsif emoji_points[0] == '1F602'
+ label += ' lol'
+ elsif emoji_points[0] == '1F603'
+ label += ' :D'
+ elsif emoji_points[0] == '1F604'
+ label += ' ^^'
+ elsif emoji_points[0] == '1F606'
+ label += ' xD XD'
+ elsif emoji_points[0] == '1F609'
+ label += ' ;)'
+ elsif emoji_points[0] == '1F613'
+ label += ' fuu'
+ elsif emoji_points[0] == '1F615'
+ label += ' :s :/'
+ elsif emoji_points[0] == '1F61B'
+ label += ' :p'
+ elsif emoji_points[0] == '1F62D'
+ label += ' :\'( :’('
+ elsif emoji_points[0] == '1F62E'
+ label += ' :O :o'
+ elsif emoji_points[0] == '1F631'
+ label += ' omg'
+ elsif emoji_points[0] == '1F633'
+ label += ' :$'
+ elsif emoji_points[0] == '1F634'
+ label += ' zzz ZZZ'
+ elsif emoji_points[0] == '1F641'
+ label += ' :('
+ elsif emoji_points[0] == '1F642'
+ label += ' :)'
+ elsif ['1F612', '1F644'].include? emoji_points[0]
+ label += ' meh'
+ end
+ emojis_list << "[#{emoji}] #{label}"
+end
+
+emojis_list << "[✓] check mark yes"
+emojis_list << "[✗] ballot x no"
+
+emojis_list += [
+ "[¯\\_(ツ)_/¯]", "[(╯°□°)╯︵ ┻━┻]", "[(•_•) ( •_•)>⌐■-■ (⌐■_■)]",
+ "[ʕ •ᴥ•ʔ]", "[~=[,,_,,]:3]"
+]
+
+IO.write('emojis_cache.txt', emojis_list.join("\n"))
diff --git a/emojis_music.py b/emojis_music.py
index 05f3f9b..625468d 100755
--- a/emojis_music.py
+++ b/emojis_music.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python3
+import os
+import re
import sys
import argparse
import subprocess
@@ -7,17 +9,6 @@ import subprocess
default_rofi_command = "rofi -dmenu -p '' -location 6 " \
"-no-case-sensitive -lines 5 -width 100"
-EMOJIS_LIST = ["🙂 :)", "😉 ;)", "🙁 :(", "😃 :D", "😮 :O :o", "😛 :p",
- "😕 :s :/", "😳 :$", "😭 :'(", "🤔 :? thinking", "😆 xD XD",
- "😄 ^^", "🤦 facepalm fp", "😱 scream cri omg OMG",
- "😂 lol LOL", "😒 -_- meh", "😓 -_−'", "🙄 meh rolling eyes",
- "♥ <3", "✓ yes", "✗ no x", "💡 idea", "🍻 beer",
- "🎉 yeah party", "🎵 music", "💤 zzz ZZZ", "💩 poop",
- "😺 cat chat", "🦄 unicorn", "🐧 penguin pinguin", "👌 ok",
- "👍 top +1", "👎 bof -1",
- "¯\\_(ツ)_/¯", "(╯°□°)╯︵ ┻━┻", "(•_•) ( •_•)>⌐■-■ (⌐■_■)",
- "ʕ •ᴥ•ʔ", "~=[,,_,,]:3"]
-
class StatusGui:
def __init__(self):
@@ -89,18 +80,37 @@ class StatusGui:
# line 1 contains remote page in case of remote wallpaper
# line 2 contains wallpaper type/origin
# line 3 contains wallpaper local path
- if wi[2] == 'local':
+ if wi[2] == "local":
wall_line = ["🖼 {}".format(wi[1])]
else:
wall_line = ["🖼 {} - {}".format(wi[0], wi[2])]
except subprocess.CalledProcessError:
wall_line = ["🖼 Chwall Daemon not running"]
+ emojis_list = []
+ emojis_cache_file = os.path.join(
+ os.path.dirname(__file__),
+ "emojis_cache.txt"
+ )
+ if os.path.exists(emojis_cache_file):
+ with open(emojis_cache_file, "r") as f:
+ emojis_list += f.read().split("\n")
+
user_choice = self.run_rofi(
- [" ".join(audio_line)] + wall_line + EMOJIS_LIST)
+ [" ".join(audio_line)] + wall_line + emojis_list
+ )
+
+ check_emoji = re.match("\\[([^]]+)\\].*", user_choice)
if user_choice == "":
sys.exit(0)
+ elif check_emoji:
+ # That was an emoji
+ emoji = check_emoji[1]
+ cmd = subprocess.Popen(["xclip", "-selection",
+ self.clipboard_selection],
+ stdin=subprocess.PIPE)
+ cmd.communicate(emoji.encode())
elif user_choice[0] == "♪" and musicapp:
if musicapp == "spotify":
sys.exit(subprocess.run(
@@ -110,17 +120,6 @@ class StatusGui:
subprocess.Popen(["st", "-e", "ncmpcpp"])
elif user_choice[0] == "🖼":
subprocess.Popen(["chwall", "info", "open"])
- else:
- emoji = user_choice[0]
- if user_choice in ["¯\\_(ツ)_/¯", "(╯°□°)╯︵ ┻━┻",
- "(•_•) ( •_•)>⌐■-■ (⌐■_■)",
- "ʕ •ᴥ•ʔ", "~=[,,_,,]:3"]:
- emoji = user_choice
- # That was an emoji
- cmd = subprocess.Popen(["xclip", "-selection",
- self.clipboard_selection],
- stdin=subprocess.PIPE)
- cmd.communicate(emoji.encode())
if __name__ == "__main__":