~alienagain/neotrellis_music_player

a8dc978be52d4307abbf19238fa393c5dcc93bda — alien 2 months ago 651c87e master
adding other controls
2 files changed, 165 insertions(+), 0 deletions(-)

A src/python/commands_and_things.py
A src/python/launch_it.py
A src/python/commands_and_things.py => src/python/commands_and_things.py +70 -0
@@ 0,0 1,70 @@
import time
import serial
import sys
import os
import subprocess

device='/dev/ttyACM0'
arduino = serial.Serial(device, 9600,timeout=1)

#def delete_duplicate(code, line):
#    if code in line:
#        return code

salir = 0

while not (salir == 1):
     valor = arduino.readline()
     valor = valor.decode('utf-8')
     if "A" in valor:
        print("A")
        subprocess.run(["firefox", "https://merveilles.town"])

     #This is an experiment I'm conducting on using a function instead, don't quite like it yet
     #myid = delete_duplicate("B", valor)
     #print(myid)
     elif "B" in valor:
         print("B")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/b.wav"])
     elif "C" in valor:
         print("C")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/c.wav"])
     elif "D" in valor:
         print("D")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/d.wav"])
     #new line
     elif "E" in valor:
         print("E")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/e.wav"])
     elif "F" in valor:
         print("F")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/f.wav"])
     elif "G" in valor:
         print("G")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/g.wav"])
     elif "H" in valor:
         print("H")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/h.wav"])
    # New line
     elif "I" in valor:
         print("I")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/i.wav"])
     elif "J" in valor:
         print("J")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/j.wav"])
     elif "K" in valor:
         print("K")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/k.wav"])
     elif "L" in valor:
         print("L")
         subprocess.run(["mplayer", "/home/alien/Documents/repos/mine/neotrellis_music_player/music/l.wav"])
    #New line
     elif "M" in valor:
         print("M")
         salir = 1
     elif "N" in valor:
         print("N")
     elif "O" in valor:
         print("O")
     elif "P" in valor:
         print("P")

A src/python/launch_it.py => src/python/launch_it.py +95 -0
@@ 0,0 1,95 @@
import time
import serial
import sys
import os
import subprocess
import webbrowser
import time

def open_mastodon():
    url = 'mastodon.green'
    url2 = 'merveilles.town'
    url3 = "todon.nl"
    browser = 'firefox'

    webbrowser.get(browser)
   #You can do webbrowser.open(url, 0) if you want to open in the same window, 1 is a new window, 2 is a new tab. Default behaviour opens them in a new tab anyway.
   #See https://docs.python.org/2/library/webbrowser.html
    webbrowser.open(url) 
   #time.sleep(2) -- Commented this out as I didn't find it neccessary.
    webbrowser.open(url2)
    webbrowser.open(url3)

def open_bandcamp():
    fav = 'https://menitrust.bandcamp.com/album/forever-live-sessions'
    mainweb = 'https://bandcamp.com/'
    browser = 'firefox'

    webbrowser.get(browser)
    webbrowser.open(fav) 
    webbrowser.open(mainweb)

def open_uoc():
    campus = "https://www.uoc.edu/portal/es/index.html"
    subprocess.run(["google-chrome",campus])

device='/dev/ttyACM0'
arduino = serial.Serial(device, 9600,timeout=1)

#def delete_duplicate(code, line):
#    if code in line:
#        return code

salir = 0

while not (salir == 1):
     valor = arduino.readline()
     valor = valor.decode('utf-8')
     if "A" in valor:
        print("Opening mastodon stuff")
        open_mastodon() 
     elif "B" in valor:
        print("Opening a new terminal")
        subprocess.run(["io.elementary.terminal", "-n"])
     elif "C" in valor:
        print("Opening bandcamp")
        open_bandcamp()
     elif "D" in valor:
        print("Opening the campus")
        open_uoc()
     #new line
     elif "E" in valor:
         print("Opening amfora")
         subprocess.run(["amfora"])
     elif "F" in valor:
         print("Opening permacomputing...")
         subprocess.run(["amfora", "gemini://geminispace.info/search?permacomputing"])
     elif "G" in valor:
         print("Opening recipes...")
         subprocess.run(["amfora", "gemini://geminispace.info/search?recipes"])
     elif "H" in valor:
         print("Opening news...")
         subprocess.run(["amfora", "gemini://geminispace.info/search?news"])
    # New line
     elif "I" in valor:
         print("Seeing last toot notifications in merveilles")
         subprocess.run(["check_mastodon", "alien@merveilles.town"])
     elif "J" in valor:
         print("Seeing last toot notification in mastodon.green")
         subprocess.run(["check_mastodon", "alien@mastodon.green"])
     elif "K" in valor:
         print("Seeing last toot notification in Post Nau")
         subprocess.run(["check_mastodon", "PostApocalipsisNau@todon.nl"])
     elif "L" in valor:
         print("L")
         subprocess.run(["weather_report", "Granada"])
    #New line
     elif "M" in valor:
         print("M")
         salir = 1
     elif "N" in valor:
         print("N")
     elif "O" in valor:
         print("O")
     elif "P" in valor:
         print("P")