#!/usr/bin/env python3
import os
from PIL import Image
import pystray

png_file = "/usr/share/simplestream/menu/icons/simplestream.png"

# Load the image
image = Image.open(png_file)

def script1():
    os.popen("/usr/share/simplestream/data/kill & /usr/bin/simplestream")

def script2():
    os.popen("/usr/share/simplestream/menu/notify/stream_menu.py")

def script3():
    os.popen("/usr/share/simplestream/data/record")

def script4():
    os.popen("/usr/share/simplestream/data/url_list")

def script5():
    os.popen("/usr/share/simplestream/menu/notify/Simplestream")

def script6():
    os.popen("(pkill -f /usr/share/simplestream/menu/notify/SimpleStream) & /usr/share/simplestream/data/kill")

# Create a tray icon with mouse-over description
menu_items = [
    pystray.MenuItem("Menu", script1),
    pystray.MenuItem("Playing", script2),    
    pystray.MenuItem("Record", script3),
    pystray.MenuItem("Stations", script4),    
    pystray.MenuItem("About", script5),
    pystray.MenuItem("Quit", script6)    
]

icon = pystray.Icon("simplestream", image, menu=pystray.Menu(*menu_items), hover_text="SimpleStream")
icon.run()


