What is Inhibit() ? you may ask.
Inhibit() is the terminology used to describe what your program does if the system wants to logout or shutdown or run a screensaver, etc.
For example most media players will use Inhibit() to stop your screensaver showing while watching a movie.
also cd writing programs and such will inhibit the system changing state while writing a cd/dvd.
How I have used it...
I have actually added it to my gambas IDE and it works great.
![Smile :)](./images/smilies/icon_e_smile.gif)
I have made it create Inhibitors if a file/gui has been edited and not saved in the IDE then the inhibitors are removed when the file saves.
Also it makes an inhibitor when saving .project data.
Now if i try to shut down with edited/unsaved documents i get a dialog showing the unsaved document names and logout is inhibited.
As i save each document they disappear from the dialog until the last one is gone then logout commences. (or i just press save project)
This to me is Brilliant!
![Smile :)](./images/smilies/icon_e_smile.gif)
But here's the problem..
org.gnome.SessionManager seems to really work well and do the required job but it seems only on gnome2 based environments (MATE, Cinnamon, gnome-fallback)
On gnome3 systems (gnome shell) and kde plasma and wayland it does not work.
it does not crash or cause problems it just doesn't work :'(
I have looked into many other ways.
org.freedesktop.portal.Desktop (doesn't seem to work)
System://org.freedesktop.login1 (just gives segfault 11)
a few others.
Cannot seem to get anything to work other than gnome.SessionManager
Anyone had any success using Inhibit on other systems (even if via terminal)
Attached is my current Inhibitor.class that I have added to my gambas IDE.
Usage of the inhibitor in the test app is very simple.
Here is the FMain code...
Private $hTask As Inhibitor
Public Sub Form_Close()
If $hTask Then $hTask.Kill
End
Public Sub Button2_Click()
If Last.Value Then
$hTask = New Inhibitor(Application.Name, "Editing Doc", 15)
Else
$hTask.Kill
Endif
End
If you run the test app you can press the "Toggle Inhibitor Enabled" toggle button to enable/disable the inhibitor.
Test it by enabling it, then trying to logout or suspend/sleep the system.
on a gnome2 based system it should pop up the warning and not logout until you either close the program, disable the inhibitor or pres "logout anyway" in the system dialog.
The Inhibitor is very simple to add to your own program, just pop the Inhibitor.class in your .src folder, that's it, it will auto-load gb.dbus so no need to add the component.
Create an inhibitor to inhibit and kill it to release the inhibit.
Shimples
Really want to get this working on other systems though.
Any help appreciated
BruceS