Skip to content

Commit

Permalink
add macos support
Browse files Browse the repository at this point in the history
  • Loading branch information
Yunus Emre Geldegul committed Jun 22, 2022
1 parent 1ae826e commit 15b6ef0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions tfc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ def main():
parser.add_argument("--src", help="source language", default="auto")
options = parser.parse_args()

print('TFC listens To Your Clipboard For Translation.')
print('='*50)
print("TFC listens To Your Clipboard For Translation.")
print("="*50)

translation = Translation(options.dest, options.src)
translation.start()


if __name__ == '__main__':
if __name__ == "__main__":
main()
10 changes: 5 additions & 5 deletions tfc/notify.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

class Notify():
def send(self, recent_value, text):
if system() == 'Linux':
Popen(['notify-send', 'TFC Result', '{0}: {1}'.format(recent_value, text)])
elif system() == 'Darwin':
Popen(['osascript', '-e', """'display notification "{0}: {1}" with title "TFC Result"'""".format(recent_value, text)])
if system() == "Linux":
Popen(["notify-send", "TFC Result", "{0}: {1}".format(recent_value, text)])
elif system() == "Darwin":
Popen(["osascript", "-e", f"display notification \"{recent_value}: {text}\" with title \"TFC Result\""])
else:
pass

print(recent_value + " : " + text)
print('=' * 50)
print("=" * 50)

return None
9 changes: 5 additions & 4 deletions tfc/tfc.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from time import sleep

from .notify import Notify
from googletrans import Translator

from time import sleep
from googletrans import Translator
from xerox import paste


Expand All @@ -13,7 +14,7 @@ def __init__(self, dest, src):
self.src = src

def start(self):
temp_value = ''
temp_value = ""

while True:
recent_value = paste()
Expand All @@ -22,7 +23,7 @@ def start(self):
result = self.translate.translate(recent_value, dest=self.dest, src=self.src)
self.notify.send(recent_value, result.text)
except Exception as e:
self.notify.send('A Problem Occurred', str(e))
self.notify.send("A Problem Occurred", str(e))

temp_value = recent_value
sleep(2)

0 comments on commit 15b6ef0

Please sign in to comment.