← Back to team overview

ubuntu-phone team mailing list archive

Re: how to popup a message box on screen

 

On 9 December 2015 at 10:10, Matthias Apitz <guru@xxxxxxxxxxx> wrote:
>
> I do monitor already the battery with some crontab job. I would like to
> make a signal to the device owner (my wife) when the problem of fast
> battery drain occurs, i.e. when for example the drainage in a given
> interval is unusual high; I figured already out how to play a sound with:
>
> $ sudo cp /var/lib/lxc/android/rootfs/system/res/sound/ringtone.wav ~
> $ sudo chown phablet ringtone.wav
> $ ubuntu-app-launch mediaplayer-app file:///home/phablet/ringtone.wav
>
> This gives a 10 second continuous beep (not really a ringtone as the
> filename says, but very good for the purpose);
>
> How can I pop-up in parallel a message box on the screen with some text
> like "Battery drain! Re-boot NOW and re-charge!", if possible together
> with an OK button which fires up "sudo reboot"?

Say you wrote a little app that just had an “OK” button that did the
reboot. Say its unversioned app id was foo.bar.baz_quux. You could
then do, in your cron job, and as long as it had access to the user
session dbus daemon,

dbus call -e -d com.ubuntu.Postal -o
/com/ubuntu/Postal/foo_2ebar_2ebaz -m com.ubuntu.Postal.Post
foo.bar.baz_quux '{"notification":{"card": {"summary": "yes", "body":
"hello", "persist": true, "actions": ["..."]}}}'

That's from memory, and I haven't tried it, but something similar to
that should work. The document text needs to be JSON (and quoting it
from the shell and from gdbus itself can be tricky), but it's the same
as the “push helper output” that is documented here:
https://developer.ubuntu.com/en/start/platform/guides/push-notifications-client-guide/#helper-output-format


References