[Gambas-user] DBus oddity with startup application.

Bruce Steers bsteers4 at gmail.com
Mon Aug 9 20:24:53 CEST 2021


On Mon, 9 Aug 2021 at 18:41, Bruce Steers <bsteers4 at gmail.com> wrote:

>
> Hi all,
> I am using the following command to shutdown the computer...
>
> Try DBus["system://org.freedesktop.login1"]["/org/freedesktop/login1",
> "org.freedesktop.login1.Manager"].PowerOff(True)
>
> the function exists in an application i have running in my "Startup
> Applications" (with a 5 second delay)
>
> the odd thing is ,  At ANY time i try the function from the application
> run at startup it fails.
> It says Unknown Interface but the DBus.System.Applications lists as
> existing
>
> If i close the application and re-launch it the function works as expected
> !?
>
> any clues as to why being run as a "Startup Application" fails to find the
> interface?
>
> PS. the shutdown function is not run at runtime. I have to press some
> buttons so the DBus login1 thing should be well awake by then.
>
> Can i Reset/refresh the DBus.class?
> or does anyone know of the reason and know of a fix?
>

I've fixed the problem with this in my FMain.class ...


*Static Public Sub _init()*





* If Not Exist("/tmp/dish_opened") Then    Wait 2
File.Save("/tmp/dish_opened", "true")  EndifEnd*
that gives a couple of seconds and then the
org.freedesktop.login1.Manager.PowerOff() function works
if app is closed and relaunched it finds the file in /tmp/ and does not
wait and dbus is still okay.


Seems any call to Dbus like DBus.System.Applications.Exist() in _init()
initialises dbus too early, it finds the login1 DBus.System.Applications
but the Interfaces do not work.

So the fix above is all i can think of.

#IffyWorkaroundsAreUs ;)

BruceS
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gambas-basic.org/pipermail/user/attachments/20210809/755c263f/attachment-0001.htm>


More information about the User mailing list