2017-04-29 01:57:47 -04:00
|
|
|
# Used for creating, running and analyzing applescript and bash scripts.
|
2017-04-28 18:26:00 -04:00
|
|
|
|
2017-04-28 03:46:39 -04:00
|
|
|
import os
|
2017-06-07 23:15:08 +00:00
|
|
|
import sys
|
2017-06-21 14:22:11 +01:00
|
|
|
import subprocess
|
2017-04-28 03:46:39 -04:00
|
|
|
|
2017-06-21 12:49:16 +01:00
|
|
|
from adapter import identify
|
|
|
|
|
2017-06-22 07:31:23 +02:00
|
|
|
osa_script_fmt = """tell application "System Events"
|
|
|
|
\ttell current desktop
|
|
|
|
\t\tset picture to "{}"
|
|
|
|
\tend tell
|
|
|
|
end tell"""
|
|
|
|
|
2017-04-28 03:46:39 -04:00
|
|
|
|
2017-06-21 12:49:16 +01:00
|
|
|
def clear_terminal():
|
|
|
|
adapter = identify()
|
|
|
|
adapter.clear()
|
|
|
|
|
|
|
|
|
|
|
|
def change_terminal(pokemon):
|
|
|
|
adapter = identify()
|
|
|
|
adapter.set_pokemon(pokemon)
|
2017-04-28 03:46:39 -04:00
|
|
|
|
|
|
|
|
2017-06-21 14:22:11 +01:00
|
|
|
def __run_osascript(stream):
|
|
|
|
p = subprocess.Popen(['osascript'], stdout=subprocess.PIPE, stdin=subprocess.PIPE)
|
|
|
|
p.stdin.write(stream)
|
|
|
|
p.communicate()
|
|
|
|
p.stdin.close()
|
2017-04-28 03:46:39 -04:00
|
|
|
|
|
|
|
|
|
|
|
def change_wallpaper(pokemon):
|
2017-06-08 02:30:27 +00:00
|
|
|
if sys.platform == "darwin":
|
2017-06-22 07:31:23 +02:00
|
|
|
script = osa_script_fmt.format(pokemon.get_path())
|
2017-06-21 14:22:11 +01:00
|
|
|
__run_osascript(str.encode(script))
|
2017-06-22 07:31:23 +02:00
|
|
|
elif sys.platform == "linux":
|
2017-06-11 15:30:23 -04:00
|
|
|
os.system(__linux_create_wallpaper_script(pokemon))
|
|
|
|
|
|
|
|
|
|
|
|
def __linux_create_wallpaper_script(pokemon):
|
2017-06-07 23:52:10 -03:00
|
|
|
# If its gnome... aka GDMSESSION=gnome-xorg, etc.
|
2017-06-22 07:31:23 +02:00
|
|
|
if "gnome" in os.environ.get("GDMSESSION"):
|
|
|
|
fmt = 'gsettings set org.gnome.desktop.background picture-uri "file://{}"'
|
|
|
|
return fmt.format(pokemon.get_path())
|
2017-06-08 02:30:27 +00:00
|
|
|
#elif condition of KDE...
|
|
|
|
else:
|
2017-06-07 23:52:10 -03:00
|
|
|
print("Window manager not supported ")
|
2017-06-08 02:30:27 +00:00
|
|
|
exit(1)
|