2017-06-21 16:30:28 +00:00
|
|
|
import os
|
2017-06-21 12:46:47 +00:00
|
|
|
import subprocess
|
2017-06-21 11:49:16 +00:00
|
|
|
|
|
|
|
from adapter.base import TerminalAdapterInterface
|
|
|
|
|
2017-06-22 06:03:18 +00:00
|
|
|
# OSA script that will change the terminal background image
|
2017-06-22 05:05:53 +00:00
|
|
|
osa_script_fmt = """tell application "iTerm"
|
|
|
|
\ttell current session of current window
|
|
|
|
\t\tset background image to "{}"
|
|
|
|
\tend tell
|
|
|
|
end tell"""
|
|
|
|
|
2017-06-21 11:49:16 +00:00
|
|
|
|
|
|
|
class ITerm(TerminalAdapterInterface):
|
2017-06-21 16:30:28 +00:00
|
|
|
@staticmethod
|
|
|
|
def is_available():
|
|
|
|
return os.environ.get("ITERM_PROFILE")
|
|
|
|
|
2017-06-21 12:46:47 +00:00
|
|
|
def __run_osascript(self, stream):
|
|
|
|
p = subprocess.Popen(['osascript'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
|
|
|
|
p.stdin.write(stream)
|
|
|
|
p.communicate()
|
|
|
|
p.stdin.close()
|
2017-06-21 11:49:16 +00:00
|
|
|
|
|
|
|
def set_pokemon(self, pokemon):
|
2017-06-22 06:03:18 +00:00
|
|
|
stdin = osa_script_fmt.format(pokemon.get_path())
|
2017-06-21 12:46:47 +00:00
|
|
|
self.__run_osascript(str.encode(stdin))
|
2017-06-21 16:30:28 +00:00
|
|
|
|
|
|
|
def clear(self):
|
2017-06-24 19:35:15 +00:00
|
|
|
stdin = osa_script_fmt.format("")
|
2017-06-21 16:30:28 +00:00
|
|
|
self.__run_osascript(str.encode(stdin))
|