-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
66 lines (56 loc) · 3.68 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# import json
import logging
# from time import sleep
from ulauncher.api.client.Extension import Extension
from ulauncher.api.client.EventListener import EventListener
from ulauncher.api.shared.event import KeywordQueryEvent, ItemEnterEvent
from ulauncher.api.shared.item.ExtensionResultItem import ExtensionResultItem
from ulauncher.api.shared.action.RenderResultListAction import RenderResultListAction
from ulauncher.api.shared.action.CopyToClipboardAction import CopyToClipboardAction
from ulauncher.api.shared.action.DoNothingAction import DoNothingAction
logger = logging.getLogger(__name__)
#My screen can only cope with a selection of 12 items max, so keep you screen size in mind when defining lists.
mySymbols = {
'-->' : [ '↦', '⇀', '⇁', '⇉', '⇛', '⇝', '⇢', '⇥', '⇨', '➡', '⟶'],
'<--' : [ '↤', '↼', '↽', '⇇', '⇚', '⇜', '⇠', '⇤', '⇦', '⬅', '⟵' ],
'<->' : [ '⇹', '⇼', '⥎', '⥐', '⇋', '⇌', '⇄', '↹', '⬌', '⟷' ],
'UP>' : [ '↥', '↾', '↿', '⇈', '⇞', '⇡', '⇧', '⥣', '⤊', '⟰', '⬆' ],
'DN>' : [ '↧', '⇂', '⇃', '⇊', '⇟', '⇣', '⇩', '⥥', '⤋', '⟱', '⬇' ],
'O>' : [ '⮊', '⮈', '⮉', '⮋', '⭮', '⭯', '⮌', '⮎', '⮍', '⮏' ],
'CHECK' : [ '✓', '✔', '☑', '✗', '✘', '☒'],
'FRAC' : [ '½', '⅓', '⅔', '¼', '¾' , '⅛', '⅜', '⅝', '⅞', '‰', '‱'],
'HEART' : [ '💗', '💓', '💔', '💟', '💕', '💖', '💘', '💝', '💞' ],
'MATH' : [ 'π', '∞', 'Σ', '÷', '±', 'Ω', 'μ', 'λ', 'ρ' ],
'SUBNUM': [ '₀', '₁', '₂', '₃', '₄', '₅', '₆', '₇', '₈', '₉' ],
'SUPNUM': [ '⁰', '¹', '²', '³', '⁴', '⁵', '⁶', '⁷', '⁸', '⁹' ],
'SEX' : [ '♂', '♀', '⚥', '⚤', '⚣', '⚢', '☿' ],
'FLAG' : [ '🇪🇺', '🇪🇸', '🇩🇪', '🇫🇷', '🇮🇹', '🇳🇱', '🇧🇪', '🇮🇨', '🇬🇧' ],
'MEDIA' : [ '◀️', '⏪', '⏮️', '⏭️', '⏩', '▶️', '⏸️', '⏯️', '⏺️', '⏹️', '⏏️' ],
'ZODIAC': [ '♈', '♉', '♊', '♋', '♌', '♍', '♎', '♏', '♐', '♑', '♒', '♓' ],
'ROMAN' : [ 'Ⅰ', 'Ⅱ', 'Ⅲ', 'Ⅳ', 'Ⅴ', 'Ⅵ', 'Ⅶ', 'Ⅷ', 'Ⅸ', 'Ⅹ', 'Ⅺ', 'Ⅻ', 'Ⅼ', 'Ⅽ', 'Ⅾ', 'Ⅿ' ],
'TRADE' : [ '©', '®', '℗', '™', '℠', '㋏' ],
'MAC' : [ '⌘', '⌃', '⌥', '⇧', '⇪', '⌫', '⏏', '⎋', '␣', '↩'],
'EMO' : [ '🤣', '😂', '😉', '😎', '😠', '😱', '😩', '👍', '👎', '👋', '💩', '😘' ]
}
#'' : [ '', '' ],
class SymbolExtension(Extension):
def __init__(self):
super(SymbolExtension, self).__init__()
self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
class KeywordQueryEventListener(EventListener):
def on_event(self, event, extension):
tmpSymbols = []
tmpKey = event.get_argument()
if tmpKey == None:
return RenderResultListAction([ExtensionResultItem(icon='images/icon.png', name='Please specify the desired symbol set', on_enter=DoNothingAction())])
elif tmpKey.upper() in mySymbols:
for tmpMatch in mySymbols[tmpKey.upper()]:
tmpSymbols.append(
ExtensionResultItem(icon='images/icon.png',
name=tmpMatch,
description='Copy ' + tmpMatch + ' to clipboard', on_enter=CopyToClipboardAction(tmpMatch)))
return RenderResultListAction(tmpSymbols)
else:
return RenderResultListAction([ExtensionResultItem(icon='images/icon.png', name='Unknown code...', on_enter=DoNothingAction())])
if __name__ == '__main__':
SymbolExtension().run()