Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ You can simply run "[setup.sh](scripts/setup.sh)" and it will install everything
dependencies of LEADS for you.

```shell
/bin/sh "setup.sh$(wget -O setup.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/setup.sh)" && rm setup.sh || rm setup.sh
bash "setup.sh$(wget -O setup.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/setup.sh)" && rm setup.sh || rm setup.sh
```

This will create a shortcut to save you from typing `python-leads -m leads_vec ...`, instead, you will just need to call
Expand All @@ -263,7 +263,7 @@ This will create a shortcut to save you from typing `python-leads -m leads_vec .
[python-install.sh](scripts/python-install.sh) will only install Python 3.12 and Tcl/Tk.

```shell
/bin/sh "python-install.sh$(wget -O python-install.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/python-install.sh)" && rm python-install.sh || rm python-install.sh
bash "python-install.sh$(wget -O python-install.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/python-install.sh)" && rm python-install.sh || rm python-install.sh
```

### frp
Expand All @@ -272,19 +272,19 @@ We use frp for reverse proxy. This is optional if you do not need public connect
"[frp-install.sh](scripts/frp-install.sh)".

```shell
/bin/sh "frp-install.sh$(wget -O frp-install.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/frp-install.sh)" && rm frp-install.sh || rm frp-install.sh
bash "frp-install.sh$(wget -O frp-install.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/frp-install.sh)" && rm frp-install.sh || rm frp-install.sh
```

To configure frp, use "[frp-config.sh](scripts/frp-config.sh)".

```shell
/bin/sh "frp-config.sh$(wget -O frp-config.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/frp-config.sh)" && rm frp-config.sh || rm frp-config.sh
bash "frp-config.sh$(wget -O frp-config.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/frp-config.sh)" && rm frp-config.sh || rm frp-config.sh
```

There are 4 arguments for this script, of which the first 2 are required.

```shell
/bin/sh "frp-config.sh$(...)" {frp_server_ip} {frp_token} {frp_port} {comm_port} && rm frp-config.sh || rm frp-config.sh
bash "frp-config.sh$(...)" {frp_server_ip} {frp_token} {frp_port} {comm_port} && rm frp-config.sh || rm frp-config.sh
```

### OBS Studio
Expand All @@ -293,7 +293,7 @@ We also use OBS Studio for streaming, but it is not required. If you want to ins
run "[obs-install.sh](scripts/obs-install.sh)".

```shell
/bin/sh "obs-install.sh$(wget -O obs-install.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/obs-install.sh)" && rm obs-install.sh || rm obs-install.sh
bash "obs-install.sh$(wget -O obs-install.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/obs-install.sh)" && rm obs-install.sh || rm obs-install.sh
```

Do not run the OBS Studio directly, instead, use "[obs-run.sh](scripts/obs-run.sh)".
Expand All @@ -307,7 +307,7 @@ wget -O obs-run.sh https://raw.githubusercontent.com/ProjectNeura/LEADS/master/s
Run the script as shown.

```shell
/bin/sh obs-run.sh
bash obs-run.sh
```

If you want the identical layout configuration, see the following.
Expand Down
17 changes: 16 additions & 1 deletion leads_audio/prototype.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from atexit import register as _register
from threading import Thread as _Thread
from time import sleep as _sleep

from sdl2 import AUDIO_S16 as _AUDIO_S16
from sdl2.sdlmixer import Mix_Init as _init, Mix_OpenAudioDevice as _open_audio_device, MIX_INIT_MP3 as _MIX_INIT_MP3, \
Mix_LoadMUS as _load_music, Mix_PlayMusic as _play_music, Mix_Music as _Music, \
Mix_GetError as _get_error, Mix_FreeMusic as _free_music, Mix_CloseAudio as _close_audio

from leads import L as _L
from leads_audio.system import _ASSETS_PATH


Expand All @@ -14,7 +17,19 @@ def _ensure(flag: int) -> None:


_init(_MIX_INIT_MP3)
_ensure(_open_audio_device(44100, _AUDIO_S16, 2, 2048, None, 1))


def _try_open_audio_device() -> None:
flag = -1
while flag < 0:
try:
_ensure(flag := _open_audio_device(44100, _AUDIO_S16, 2, 2048, None, 1))
except RuntimeError as e:
_L.error(repr(e))
_sleep(10)


_Thread(name="sdl initializer", target=_try_open_audio_device, daemon=True).start()


@_register
Expand Down
6 changes: 5 additions & 1 deletion leads_vec/_bootloader/leads_vec.service.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
#!/bin/bash

if [ ! -x "/usr/local/leads/config.json" ];
then
echo "Error: Config file does not exist"
exit 1
fi

while ! xhost >& /dev/null;
do sleep 1
done
# change the interpreter or adjust the arguments according to your needs
# do not remove `--xws`
python-leads -m leads_vec -c /usr/local/leads/config.json --xws run
2 changes: 1 addition & 1 deletion leads_vec/_bootloader/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def create_service() -> None:
f"User={(user := _get_login())}\n"
"Environment=\"DISPLAY=:0\"\n"
f"Environment=\"XAUTHORITY=/home/{user}/.Xauthority\"\n"
f"ExecStart=/bin/sh {script}\n"
f"ExecStart=/bin/bash {script}\n"
"[Install]\n"
"WantedBy=graphical.target"
)
2 changes: 1 addition & 1 deletion scripts/frp-config.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

abort() {
printf "%s\n" "$@" >&2
Expand Down
2 changes: 1 addition & 1 deletion scripts/frp-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

abort() {
printf "%s\n" "$@" >&2
Expand Down
2 changes: 1 addition & 1 deletion scripts/obs-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

abort() {
printf "%s\n" "$@" >&2
Expand Down
2 changes: 1 addition & 1 deletion scripts/obs-run.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

abort() {
printf "%s\n" "$@" >&2
Expand Down
4 changes: 2 additions & 2 deletions scripts/python-install.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

abort() {
printf "%s\n" "$@" >&2
Expand Down Expand Up @@ -29,7 +29,7 @@ execute_root "apt" "install" "-y" "python3.12-tk"
echo "Creating Virtual Environment..."
execute_root "python3.12" "-m" "venv" "/usr/local/leads/venv"
echo "Creating Soft Links..."
echo "#!/bin/sh" > "/bin/python-leads"
echo "#!/bin/bash" > "/bin/python-leads"
echo '/usr/local/leads/venv/bin/python "$@"' >> "/bin/python-leads"
execute_root "chmod" "+x" "/bin/python-leads"
execute_root "ln" "-s" "/usr/local/leads/venv/bin/pip" "/bin/pip-leads"
6 changes: 3 additions & 3 deletions scripts/setup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

abort() {
printf "%s\n" "$@" >&2
Expand All @@ -21,13 +21,13 @@ execute_root() {

echo "Installing Python..."
execute_root "wget" "-O" "python-install.sh" "https://raw.githubusercontent.com/ProjectNeura/LEADS/master/scripts/python-install.sh"
execute_root "/bin/sh" "python-install.sh"
execute_root "/bin/bash" "python-install.sh"
echo "Cleaning up..."
execute_root "rm" "python-install.sh"
echo "Installing dependencies..."
execute "pip-leads" "install" "Pillow" "PySDL2" "customtkinter" "gpiozero" "lgpio" "pynmea2" "pynput" "pysdl2-dll" "pyserial" "leads"
echo "Creating Shortcut..."
echo "#!/bin/sh" > "/bin/leads-vec"
echo "#!/bin/bash" > "/bin/leads-vec"
echo 'python-leads -m leads_vec "$@"' >> "/bin/leads-vec"
execute_root "chmod" "+x" "/bin/leads-vec"
echo "Verifying..."
Expand Down