Evidlo / remarkable_printer

Native printing to reMarkable.
GNU General Public License v3.0
253 stars 21 forks source link

Restart xochitl using remux and oxide API instead of restarting everything. #42

Open Eeems opened 11 months ago

Eeems commented 11 months ago

https://github.com/Evidlo/remarkable_printer/blob/c30239dc378e4245eb8d83a85bae549dac3d1a5f/main.go#L87-L99

Instead of restarting all of the currently running applications, even if xochitl isn't running, this code should be a little smarter and instead use the remux or oxide APIs to restart the xochitl application if it's running.

Remux launch API: https://github.com/rmkit-dev/rmkit/tree/master/src/remux#launch-api-020 Example:

if killall -q -0 xochitl; then
  killall -SIGCONT xochitl
  killall xochitl
  i=0
  while killall -q -0 xochitl; do
    sleep 1;
    i=$((i+1))
    if [[ "$i" -gt 5 ]]; then
      killall -9 xochitl
    fi
  done
fi
echo 'launch xochitl' > /run/remux.api

Oxide Apps API: https://oxide.eeems.codes/documentation/api/02_apps.html Oxide CLI tool for interacting with the API: https://oxide.eeems.codes/documentation/01_usage.html#examples-of-usage Example:

app=$(rot apps get runningApplications | jq -r '.xochitl' | sed 's|/codes/eeems/oxide1/||')
if [[ "${app}" != "null" ]]; then
  rot -o Application:$app apps call stop
  rot -o Application:$app apps call launch
fi
Eeems commented 11 months ago

I opened this due to https://github.com/toltec-dev/toltec/issues/515#issuecomment-1672197583