JNA is unable to get system idle time in ubuntu 11.10 version onwards
NickName:Martin Ask DateTime:2013-01-19T21:16:35

JNA is unable to get system idle time in ubuntu 11.10 version onwards

JNA is unable to get system idle time in ubuntu 11.10 version onwards.

    public static long getIdleTimeMillis() {
            X11.Window win = null;
            Xss.XScreenSaverInfo info = null;
            X11.Display dpy = null;

            final X11 x11 = X11.INSTANCE;
            final Xss xss = Xss.INSTANCE;

            long idlemillis = 0L;
            try {
                    dpy = x11.XOpenDisplay(null);
                    win = x11.XDefaultRootWindow(dpy);
                    info = xss.XScreenSaverAllocInfo();
                    xss.XScreenSaverQueryInfo(dpy, win, info);

                    idlemillis = info.idle.longValue();

            } finally {
                    if (info != null)
                            x11.XFree(info.getPointer());
                    info = null;

                    if (dpy != null)
                            x11.XCloseDisplay(dpy);
                    dpy = null;
            }
            return idlemillis;

I am using this code to capture idle time. It is working fine in lower versions of ubuntu. but it is not working in latest versions.

It is not moving from the line

final Xss xss = Xss.INSTANCE;

please suggest me a proper solution.

Copyright Notice:Content Author:「Martin」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/14414771/jna-is-unable-to-get-system-idle-time-in-ubuntu-11-10-version-onwards

More about “JNA is unable to get system idle time in ubuntu 11.10 version onwards” related questions

JNA is unable to get system idle time in ubuntu 11.10 version onwards

JNA is unable to get system idle time in ubuntu 11.10 version onwards. public static long getIdleTimeMillis() { X11.Window win = null; Xss.XScreenSaverInfo info = null...

Show Detail

Ubuntu 11.10 file system does not implement creationTime?

From the following quote taken from the javadoc. FileTime creationTime() Returns the creation time. The creation time is the time that the file was created. If the file system implementatio...

Show Detail

How to calculate system idle time in Ubuntu on Wayland?

I've implemented the below code to calculate system idle time in ubuntu on xorg which is working fine:- #include <X11/extensions/scrnsaver.h> #include <stdio.h> #include <X11/Xatom.h...

Show Detail

How to calculate system idle time in Ubuntu on Wayland?

I've implemented the below code to calculate system idle time in ubuntu on xorg which is working fine:- #include <X11/extensions/scrnsaver.h> #include <stdio.h> #include <X11/Xatom.h...

Show Detail

Operating System debugger for Ubuntu 11.10

I've been doing operating system development (not building a Linux kernel), and have gotten to the point where I need a debugger, for my latest OS. I've tried Bochs (under my Win 7 partition), but ...

Show Detail

jna installation for ubuntu 12.04

I started to install datastax by referring this link. It requires jna for performance improvement. I am using ubuntu:12.04 system. I installed using sudo apt-get install libjna-java I din't get...

Show Detail

Is there a way to get Selenium 2.23 on Ubuntu 11.10?

I was using Firefox 12 with Selenium::WebDriver (ver 2.22) and everything was working fine. Then I, stupidly, upgraded to Firefox 13 via the Ubuntu weekly updates. Selenium (2.22) could not contr...

Show Detail

ruby 1.8.7 installation error on ubuntu 11.10

recently I re installed Ubuntu 11.10 and was trying to set my working ruby and rails framework. But now I can not install 1.8.7 on my system. I loaded RVM successfully, i hope. The version it displ...

Show Detail

Failed to get adb version; error = 13 in Ubuntu 11.10

I added 32-bit android adk to eclipse(Classic, Indigo, Version: 3.7.0 Build id: I20110613-1736) in Ubuntu 11.10. I use 32-bit Ubuntu. When I start Eclipse the following error occurs. Failed to get...

Show Detail

JNA undefined symbol on Ubuntu 20.04

I am attempting to load a native library using JNA, using this line: MPV INSTANCE = Native.load("mpv", MPV.class, Map.of(Library.OPTION_STRING_ENCODING, "UTF-8")); This works absolutely fine on an

Show Detail