Skip to content

Display pokemon's name in terminal title bar #148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pokemonterminal/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def slideshow(filtered, delay, changer_func):
random.shuffle(filtered)
queque = iter(filtered)
continue
changer_func(next_pkmn.get_path())
changer_func(next_pkmn.get_path(), title=next_pkmn.get_name().title(), background_process=True)
p.join(delay * 60)


Expand Down Expand Up @@ -132,7 +132,7 @@ def main(argv):
if options.wallpaper:
scripter.change_wallpaper(target.get_path())
else:
scripter.change_terminal(target.get_path())
scripter.change_terminal(target.get_path(), title=target.get_name().title(), background_process=False)


if __name__ == "__main__":
Expand Down
14 changes: 12 additions & 2 deletions pokemonterminal/scripter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Used for creating, running and analyzing applescript and bash scripts.
import subprocess
import sys

from .terminal import get_current_terminal_adapters
Expand Down Expand Up @@ -69,19 +70,28 @@ def __init_wallpaper_provider():


def clear_terminal():
# clear any updates to the terminal window's title bar
sys.stdout.write("\033]2;\007")
__init_terminal_provider()
TERMINAL_PROVIDER.clear()


def change_terminal(image_file_path):
def change_terminal(image_file_path, title, background_process):
if not isinstance(image_file_path, str):
print("A image path must be passed to the change terminal function.")
return
# Update the terminal window's title
# Shelling out is required when running the slideshow due to it being a detached process without access
# to the terminal title bar via sys.stdout until after the join
if background_process:
subprocess.run(['echo','-n', '\033]2;{}\007'.format(title)])
else:
sys.stdout.write("\033]2;{}\007".format(title))
__init_terminal_provider()
TERMINAL_PROVIDER.change_terminal(image_file_path)


def change_wallpaper(image_file_path):
def change_wallpaper(image_file_path, title=None, background_process=False):
if not isinstance(image_file_path, str):
print("A image path must be passed to the change wallpapper function.")
return
Expand Down