Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve power permissions issues #35

Closed
wants to merge 2 commits into from
Closed
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: 12 additions & 2 deletions ovos_PHAL_plugin_system/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ def use_external_factory_reset(self):
return True
return external_requested or False

@property
def use_sudo_for_power(self) -> bool:
return self.config.get("use_sudo_for_power", True)

def handle_reset_register(self, message):
if not message.data.get("skill_id"):
LOG.warning(f"Got registration request without a `skill_id`: "
Expand Down Expand Up @@ -230,7 +234,10 @@ def handle_reboot_request(self, message):
if script and os.path.isfile(script):
subprocess.call(script, shell=True)
else:
subprocess.call("systemctl reboot -i", shell=True)
command = "systemctl reboot -i"
if self.use_sudo_for_power:
command = f"sudo {command}"
subprocess.call(command, shell=True)

def handle_shutdown_request(self, message):
"""
Expand All @@ -245,7 +252,10 @@ def handle_shutdown_request(self, message):
if script and os.path.isfile(script):
subprocess.call(script, shell=True)
else:
subprocess.call("systemctl poweroff -i", shell=True)
command = "systemctl poweroff -i"
if self.use_sudo_for_power:
command = f"sudo {command}"
subprocess.call(command, shell=True)

def handle_configure_language_request(self, message):
language_code = message.data.get('language_code', "en_US")
Expand Down
Loading