Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using C libraries from a Gnome-Shell extension

I want to write a Gnome-Shell extension that can tell how long a session has not received any user input. I know that calling XScreenSaverQueryInfo will give me that information, but I can't find a way to call it from my gjs extension. What do I need to do to get this to work?

like image 580
Dan Avatar asked Oct 23 '22 20:10

Dan


1 Answers

Probably the easiest way to do this is to use D-Bus to call the org.gnome.Mutter.IdleMonitor.GetIdletime method on the /org/gnome/Mutter/IdleMonitor/Core path of org.gnome.Shell. That will give you the time in milliseconds that the shell has not seen any user input for.

You can test this on the command line using:

while true; do
  gdbus call --session --dest org.gnome.Shell \
    --object-path /org/gnome/Mutter/IdleMonitor/Core \
    --method org.gnome.Mutter.IdleMonitor.GetIdletime
done

You can use GIO’s D-Bus support from GJS to call the method from your extension. There’s an example here.

like image 152
Philip Withnall Avatar answered Nov 03 '22 01:11

Philip Withnall