relative path logic
This commit is contained in:
parent
7643af19a8
commit
2eb9311887
11
buttons.py
11
buttons.py
@ -1,10 +1,11 @@
|
|||||||
|
|
||||||
from gpiozero import Button
|
from gpiozero import Button
|
||||||
from signal import pause
|
from signal import pause
|
||||||
import time
|
import time
|
||||||
import subprocess
|
import subprocess
|
||||||
import pathlib
|
import pathlib
|
||||||
|
|
||||||
|
venv_path = f"{pathlib.Path(__file__).parent.resolve()}/venv/bin/python3"
|
||||||
|
player_path = f"{pathlib.Path(__file__).parent.resolve()}/player.py"
|
||||||
|
|
||||||
Button.was_held = False
|
Button.was_held = False
|
||||||
|
|
||||||
@ -62,28 +63,28 @@ def pressed(btn):
|
|||||||
if btn._pin.number == up_pin:
|
if btn._pin.number == up_pin:
|
||||||
print("next")
|
print("next")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[f"{pathlib.Path().resolve()}/venv/bin/python3 ./player.py next"],
|
[f"{venv_path} {player_path} next"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True,
|
shell=True,
|
||||||
).stdout.decode("utf-8")
|
).stdout.decode("utf-8")
|
||||||
elif btn._pin.number == down_pin:
|
elif btn._pin.number == down_pin:
|
||||||
print("back")
|
print("back")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[f"{pathlib.Path().resolve()}/venv/bin/python3 ./player.py previous"],
|
[f"{venv_path} {player_path} previous"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True,
|
shell=True,
|
||||||
).stdout.decode("utf-8")
|
).stdout.decode("utf-8")
|
||||||
elif btn._pin.number == playpause_pin:
|
elif btn._pin.number == playpause_pin:
|
||||||
print("playpause")
|
print("playpause")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[f"{pathlib.Path().resolve()}/venv/bin/python3 ./player.py playpause"],
|
[f"{venv_path} {player_path} playpause"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True,
|
shell=True,
|
||||||
).stdout.decode("utf-8")
|
).stdout.decode("utf-8")
|
||||||
elif btn._pin.number == shuffle_pin:
|
elif btn._pin.number == shuffle_pin:
|
||||||
print("shuffle")
|
print("shuffle")
|
||||||
result = subprocess.run(
|
result = subprocess.run(
|
||||||
[f"{pathlib.Path().resolve()}/venv/bin/python3 ./player.py shuffle"],
|
[f"{venv_path} {player_path} shuffle"],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
shell=True,
|
shell=True,
|
||||||
).stdout.decode("utf-8")
|
).stdout.decode("utf-8")
|
||||||
|
@ -8,7 +8,7 @@ parser.add_argument("URI_string", help="Mopdiy URI to Album/Playlist.")
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
inputURI = args.URI_string
|
inputURI = args.URI_string
|
||||||
|
|
||||||
disk_file = f"{pathlib.Path().resolve()}/last_disk.txt"
|
disk_file = f"{pathlib.Path(__file__).parent.resolve()}/last_disk.txt"
|
||||||
|
|
||||||
mopidy = MopidyClient()
|
mopidy = MopidyClient()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user