Score:0

How To Reboot a PC inside snap app (created with Flutter) on Ubuntu 22.04?

sd flag

I have an Ubuntu 22.04 on my PC, and also i have a snapped Linux app that created with Flutter. I have also a button for rebooting the OS in my Flutter app.

I tried two different methods:

method 1:

await Process.run("reboot", []);

message:

flutter: Running in chroot, ignoring request.

method 2:

await Process.run('sudo', ['reboot']);

message:

flutter: >>> /etc/sudoers: syntax error near line 54 <<<
sudo: parse error in /etc/sudoers near line 54
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

Also this is my 'snapcarft.yaml' file content:

name: panel-gyro-compass
version: 1.0.0
summary: panel gyro compass
description: panel gyro compass

confinement: strict
base: core18
grade: stable


slots:
  dbus-panel-gyro-compass: # adjust accordingly to your app name
    interface: dbus
    bus: session
    name: org.bar.panel_gyro_compass # adjust accordingly to your app name and


    
apps:
  panel-gyro-compass:
    command: panel_gyro_compass
    extensions: [flutter-master] # Where "master" defines which Flutter channel to use for the build
    plugs: [network, serial-port]
    slots: [dbus-panel-gyro-compass]

parts:
  panel-gyro-compass:
    source: .
    plugin: flutter
    flutter-target: lib/main.dart # The main entry-point file of the application

please show me how to run a command in Flutter for Rebooting the PC.

in flag
Snaps are containerised to prevent them from having too much access to the computer. You would need to be running the Snap as a traditional application to do this, which sort of defeats the purpose of wrapping the program in a Snap
user535733 avatar
cn flag
It requires access to systemd via dbus. See https://forum.snapcraft.io/t/system-reboot-from-within-a-strictly-confined-snap/10080, where reboot from within a snap is explained by the developers.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.