Skip to content

Commit

Permalink
feat: parameter icon padding
Browse files Browse the repository at this point in the history
- fix #2
  • Loading branch information
BenjaminOddou committed Sep 4, 2023
1 parent a6147ef commit caa8620
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import sys
import subprocess
from utils import api_file_path, data_folder_path, icons_folder_path, display_notification, language
from utils import api_file_path, data_folder_path, icons_folder_path, display_notification, language, padding
def get_homebrew_prefix():
try:
prefix = subprocess.check_output(['brew', '--prefix'])
Expand Down Expand Up @@ -41,7 +41,7 @@ def get_homebrew_prefix():
check_e_type = ['flag:', 'keycap:']

def convert_emoji_to_png(emoji, name):
image_size = (128, 128)
image_size = (64+padding, 64+padding) # set image size
image = Image.new("RGBA", image_size, (0, 0, 0, 0)) # Set transparent background
font_size = 64 # Adjusted font size
font_path = "/System/Library/Fonts/Apple Color Emoji.ttc"
Expand All @@ -55,7 +55,7 @@ def convert_emoji_to_png(emoji, name):
api_url = 'https://unicode.org/Public/emoji/latest/emoji-test.txt'
api_response = request.urlopen(api_url).read().decode('utf-8')
lines = [line.strip() for line in api_response.split('\n') if ('; fully-qualified' in line) or ('; component' in line)]

lang_url_1 = f'https://raw.githubusercontent.com/unicode-org/cldr/main/common/annotations/{language}.xml'
lang_url_2 = f'https://raw.githubusercontent.com/unicode-org/cldr/main/common/annotationsDerived/{language}.xml'
lang_response_1 = request.urlopen(lang_url_1).read().decode('utf-8')
Expand Down
23 changes: 22 additions & 1 deletion src/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,27 @@ note: not all emojis are available in all languages.</string>
<key>variable</key>
<string>language</string>
</dict>
<dict>
<key>config</key>
<dict>
<key>default</key>
<string>10</string>
<key>placeholder</key>
<string></string>
<key>required</key>
<true/>
<key>trim</key>
<true/>
</dict>
<key>description</key>
<string>Add transparent margins to icons (in pixels).</string>
<key>label</key>
<string>✂️ Padding</string>
<key>type</key>
<string>textfield</string>
<key>variable</key>
<string>padding</string>
</dict>
<dict>
<key>config</key>
<dict>
Expand Down Expand Up @@ -1189,7 +1210,7 @@ note: not all emojis are available in all languages.</string>
</dict>
</array>
<key>version</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>webaddress</key>
<string>https://github.com/BenjaminOddou/alfred-emoji-wine</string>
</dict>
Expand Down
4 changes: 4 additions & 0 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

sound = os.environ['sound']
language = os.environ['language']
try:
padding = int(os.environ['padding'])
except:
padding = 10
cache_folder_path = os.environ['alfred_workflow_cache'] # ~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.benjamino.emoji_wine
data_folder_path = os.environ['alfred_workflow_data'] # ~/Library/Application Support/Alfred/Workflow Data/com.benjamino.emoji_wine
api_file_path = f'{cache_folder_path}/api.json'
Expand Down

0 comments on commit caa8620

Please sign in to comment.