mirror of
https://github.com/LazoCoder/Pokemon-Terminal
synced 2025-02-17 05:18:31 +00:00
Updated some comments and added global execution support
This commit is contained in:
parent
3612e0a143
commit
759d59a1c3
8 changed files with 22 additions and 16 deletions
|
@ -2,8 +2,8 @@ to do:
|
|||
- support changing text colour
|
||||
- support changing blender
|
||||
- support changing transparency
|
||||
- find out how to put in $path
|
||||
- find out how to use it as $pokemon instead of $python3.5 Main.py etc…
|
||||
- add Alternative images + playboy pikachu
|
||||
- how to save theme?
|
||||
- allow to change wallpaper as well
|
||||
- allow to change wallpaper as well
|
||||
- support deleting regions so it takes up less space
|
||||
- support adding in one's own images
|
|
@ -1,5 +1,5 @@
|
|||
tell application "iTerm"
|
||||
tell current session of current window
|
||||
set background image to "/Users/Laki/GitHub/Pokemon-Terminal-Themes/Images/Generation I - Kanto/003.png"
|
||||
set background image to "/Users/Laki/GitHub/Pokemon-Terminal-Themes/Images/Generation I - Kanto/130.png"
|
||||
end tell
|
||||
end tell
|
|
@ -19,6 +19,7 @@ def to_number(pokemon_name):
|
|||
|
||||
|
||||
# Find Pokemon who's name starts with a word.
|
||||
# Example: If user_input is "pika", the result will be Pikachu.
|
||||
def guess_by_startswith(user_input):
|
||||
guessed_pokemon = extractor.pokemon_starting_with(user_input)
|
||||
if len(guessed_pokemon) == 0:
|
||||
|
@ -33,6 +34,7 @@ def guess_by_startswith(user_input):
|
|||
|
||||
|
||||
# Find Pokemon who's name contains a word.
|
||||
# Example: If user input is "chu", the result will be Pikachu, Raichu, Pichu and Smoochum.
|
||||
def guess_by_contains(user_input):
|
||||
guessed_pokemon = extractor.pokemon_containing(user_input)
|
||||
if len(guessed_pokemon) == 0:
|
||||
|
@ -47,8 +49,6 @@ def guess_by_contains(user_input):
|
|||
|
||||
|
||||
# If no Pokemon is found by the user input then try to guess what Pokemon they meant.
|
||||
# This method checks to see if the user input is the first part of a Pokemon name.
|
||||
# Example: if user input is "pika" then change the background to Pikachu.
|
||||
# Return false if it failed to make any guesses.
|
||||
def guess(user_input):
|
||||
if len(user_input) < 3:
|
||||
|
@ -89,4 +89,4 @@ def change_background(user_input):
|
|||
else:
|
||||
other_handler(user_input)
|
||||
filegen.create_bash_run()
|
||||
os.system('Scripts/run.sh')
|
||||
os.system(os.get_exec_path()[0] + "/Scripts/run.sh")
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
# The logic for loading the Pokemon names and numbers from Data/pokemon.txt.
|
||||
|
||||
import printer
|
||||
import os
|
||||
|
||||
|
||||
# Load all the Pokemon and their corresponding numbers into a list.
|
||||
def load_names():
|
||||
names_file = open("Data/pokemon.txt", "r+")
|
||||
names_file = open(os.get_exec_path()[0] + "/Data/pokemon.txt", "r+")
|
||||
content = names_file.readlines()
|
||||
return content
|
||||
|
||||
|
|
10
filegen.py
10
filegen.py
|
@ -39,7 +39,7 @@ def get_filename(pokemon_number):
|
|||
def create_applescript_content(region, filename):
|
||||
content = "tell application \"iTerm\"\n"
|
||||
content += "\ttell current session of current window\n"
|
||||
content += "\t\tset background image to \"" + os.getcwd() + "/Images/" + region + "/" + filename + "\"\n"
|
||||
content += "\t\tset background image to \"" + os.get_exec_path()[0] + "/Images/" + region + "/" + filename + "\"\n"
|
||||
content += "\tend tell\n"
|
||||
content += "end tell"
|
||||
return content
|
||||
|
@ -50,16 +50,16 @@ def create_applescript(pokemon_number):
|
|||
region = get_region(pokemon_number)
|
||||
filename = get_filename(pokemon_number)
|
||||
content = create_applescript_content(region, filename)
|
||||
file = open("Scripts/background.scpt", "wb")
|
||||
file = open(os.get_exec_path()[0] + "/Scripts/background.scpt", "wb")
|
||||
file.write(bytes(content, 'UTF-8'))
|
||||
file.close()
|
||||
|
||||
|
||||
# Create and save the run.sh that will execute the AppleScript if the correct run.sh doesn't already exist.
|
||||
def create_bash_run():
|
||||
content = "#!/bin/bash\n" + "osascript " + os.getcwd() + "/Scripts/background.scpt"
|
||||
if open("Scripts/run.sh", 'r').read() == content:
|
||||
content = "#!/bin/bash\n" + "osascript " + os.get_exec_path()[0] + "/Scripts/background.scpt"
|
||||
if open(os.get_exec_path()[0] + "/Scripts/run.sh", 'r').read() == content:
|
||||
return
|
||||
file = open("Scripts/run.sh", 'wb')
|
||||
file = open(os.get_exec_path()[0] + "/Scripts/run.sh", 'wb')
|
||||
file.write(bytes(content, 'UTF-8'))
|
||||
file.close()
|
||||
|
|
8
main.py
Normal file → Executable file
8
main.py
Normal file → Executable file
|
@ -1,3 +1,5 @@
|
|||
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5
|
||||
|
||||
# The main module that brings everything together.
|
||||
|
||||
from sys import argv
|
||||
|
@ -20,7 +22,9 @@ def debug():
|
|||
|
||||
# Entrance to the program.
|
||||
if __name__ == "__main__":
|
||||
if len(argv) == 2:
|
||||
if len(argv) == 1:
|
||||
print("No command line arguments specified. Try typing in a Pokemon name or number.")
|
||||
elif len(argv) == 2:
|
||||
arg = argv[1].lower()
|
||||
if len(arg) == 1 and not arg.isdigit():
|
||||
printer.print_pokemon_starting_with(arg)
|
||||
|
@ -43,4 +47,4 @@ if __name__ == "__main__":
|
|||
else:
|
||||
backchanger.change_background(arg)
|
||||
else:
|
||||
printer.print_usage()
|
||||
print("Only one command line argument is supported.")
|
||||
|
|
1
pokemon
Symbolic link
1
pokemon
Symbolic link
|
@ -0,0 +1 @@
|
|||
main.py
|
|
@ -33,7 +33,7 @@ def print_list(list_of_items):
|
|||
print(item)
|
||||
|
||||
|
||||
# Add zeros to the front so that it begins 3 digits.
|
||||
# Add zeros to the front so that it begins with 3 digits.
|
||||
# Example: "2 Ivysaur" -> "002 Ivysaur"
|
||||
def add_zeroes(pokemon):
|
||||
zeroes = ""
|
||||
|
|
Loading…
Add table
Reference in a new issue