-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Autostart Works Partially on Raspberry Pi (#158)
* Set the service environment variable `XAUTHORITY` to the value of the outer environment variable when creating the service. (#156 (comment)) * Removed XWS configuring. (#156) * Supported more precise display manager dependencies. (#156) * Code reformatted. * Converted `leads_vec` to a user service `leads-vec`. (#156 (comment)) * Using auto restart to replace delaying. (#156) * Docs. (#156) * Docs. * Bug fixed: mkdir: no such file or directory. (#156) * Code reformatted.
- Loading branch information
Showing
8 changed files
with
43 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 1 addition & 6 deletions
7
leads_vec/_bootloader/leads_vec.service.sh → leads_vec/_bootloader/leads-vec.service.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
#!/bin/bash | ||
|
||
if [ ! -r "/usr/local/leads/config.json" ] | ||
if test ! -r "/usr/local/leads/config.json" | ||
then | ||
echo "Error: Config file does not exist" | ||
exit 1 | ||
fi | ||
while ! xhost >& /dev/null | ||
do sleep 1 | ||
done | ||
# configure xws | ||
/usr/bin/xhost +SI:localuser:"$USERNAME" | ||
# change the interpreter or adjust the arguments according to your needs | ||
python-leads -m leads_vec -c /usr/local/leads/config.json run |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,35 @@ | ||
from os import chmod as _chmod, getlogin as _get_login, mkdir as _mkdir | ||
from os import chmod as _chmod, getlogin as _get_login, makedirs as _mkdirs | ||
from os.path import abspath as _abspath, exists as _exists | ||
|
||
from leads import L as _L | ||
from leads_gui import Config as _Config | ||
from leads_gui.system import get_system_kernel as _get_system_kernel | ||
|
||
|
||
def create_service() -> None: | ||
def register_leads_vec() -> None: | ||
if _get_system_kernel() != "linux": | ||
raise SystemError("Unsupported operating system") | ||
if not _exists("/usr/local/leads/config.json"): | ||
_L.debug("Config file not found. Creating \"/usr/local/leads/config.json\"...") | ||
if not _exists("/usr/local/leads"): | ||
_mkdir("/usr/local/leads") | ||
_mkdirs("/usr/local/leads") | ||
with open("/usr/local/leads/config.json", "w") as f: | ||
f.write(str(_Config({}))) | ||
_chmod("/usr/local/leads/config.json", 0x644) | ||
_chmod(script := f"{_abspath(__file__)[:-10]}leads_vec.service.sh", 0o755) | ||
with open("/etc/systemd/system/leads_vec.service", "w") as f: | ||
_chmod(script := f"{_abspath(__file__)[:-10]}leads-vec.service.sh", 0o755) | ||
if not _exists(user_systemd := f"/home/{_get_login()}/.config/systemd/user"): | ||
_L.debug(f"User systemd not found. Creating \"{user_systemd}\"...") | ||
_mkdirs(user_systemd) | ||
with open(f"{user_systemd}/leads-vec.service", "w") as f: | ||
f.write( | ||
"[Unit]\n" | ||
"Description=LEADS VeC\n" | ||
"After=display-manager.service\n" | ||
"Requires=display-manager.service\n" | ||
"After=graphical-session.target\n" | ||
"[Service]\n" | ||
"Type=simple\n" | ||
f"User={(user := _get_login())}\n" | ||
f"Environment=\"USERNAME={user}\"\n" | ||
"Environment=\"DISPLAY=:0\"\n" | ||
f"Environment=\"XAUTHORITY=/home/{user}/.Xauthority\"\n" | ||
f"ExecStart=/bin/bash {script}\n" | ||
f"Restart=always\n" | ||
f"RestartSec=1s\n" | ||
"[Install]\n" | ||
"WantedBy=graphical.target" | ||
"WantedBy=default.target" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters