relative path logic

This commit is contained in:
Karl 2021-11-18 13:04:07 +00:00
parent 7643af19a8
commit 2eb9311887
2 changed files with 7 additions and 6 deletions

View File

@ -1,10 +1,11 @@
from gpiozero import Button
from signal import pause
import time
import subprocess
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
@ -62,28 +63,28 @@ def pressed(btn):
if btn._pin.number == up_pin:
print("next")
result = subprocess.run(
[f"{pathlib.Path().resolve()}/venv/bin/python3 ./player.py next"],
[f"{venv_path} {player_path} next"],
stdout=subprocess.PIPE,
shell=True,
).stdout.decode("utf-8")
elif btn._pin.number == down_pin:
print("back")
result = subprocess.run(
[f"{pathlib.Path().resolve()}/venv/bin/python3 ./player.py previous"],
[f"{venv_path} {player_path} previous"],
stdout=subprocess.PIPE,
shell=True,
).stdout.decode("utf-8")
elif btn._pin.number == playpause_pin:
print("playpause")
result = subprocess.run(
[f"{pathlib.Path().resolve()}/venv/bin/python3 ./player.py playpause"],
[f"{venv_path} {player_path} playpause"],
stdout=subprocess.PIPE,
shell=True,
).stdout.decode("utf-8")
elif btn._pin.number == shuffle_pin:
print("shuffle")
result = subprocess.run(
[f"{pathlib.Path().resolve()}/venv/bin/python3 ./player.py shuffle"],
[f"{venv_path} {player_path} shuffle"],
stdout=subprocess.PIPE,
shell=True,
).stdout.decode("utf-8")

View File

@ -8,7 +8,7 @@ parser.add_argument("URI_string", help="Mopdiy URI to Album/Playlist.")
args = parser.parse_args()
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()