Pokemon-Terminal/adapter/implementations/ITerm.py
LazoCoder 1a9c69c637 Upgraded compression
Replaced pngquant compression with imageoptim compression.

Quality is better and size is smaller. Backgrounds went from ~30mb -> ~17mb and Samples went from ~7mb to ~4mb.

Also fixed bug with clear | off | disable.
2017-06-24 15:35:15 -04:00

31 lines
876 B
Python

import os
import subprocess
from adapter.base import TerminalAdapterInterface
# OSA script that will change the terminal background image
osa_script_fmt = """tell application "iTerm"
\ttell current session of current window
\t\tset background image to "{}"
\tend tell
end tell"""
class ITerm(TerminalAdapterInterface):
@staticmethod
def is_available():
return os.environ.get("ITERM_PROFILE")
def __run_osascript(self, stream):
p = subprocess.Popen(['osascript'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
p.stdin.write(stream)
p.communicate()
p.stdin.close()
def set_pokemon(self, pokemon):
stdin = osa_script_fmt.format(pokemon.get_path())
self.__run_osascript(str.encode(stdin))
def clear(self):
stdin = osa_script_fmt.format("")
self.__run_osascript(str.encode(stdin))