Score:0

How to make XScreenSaver work on Ubuntu 22.04?

tl flag

I installed Ubuntu 22.04 (normal and minimum) on VirtualBox, and installed gcc, libx11-dev, libxss-dev.
Then I compiled the code using gcc -o idle idle.c -lXss -lX11. When I run ./idle, I receive the error No XSS available: event=0 error=0 errno=11`. It works on Ubuntu 14.04, 16.04, 18.04, and 20.04.

My code:

 #include <stdio.h>
 #include <errno.h>
 #include <X11/Xlib.h>
 
 #include <X11/Xlib.h>
 #include <X11/extensions/scrnsaver.h>
 
 int main(void)
 {
     Display *display = XOpenDisplay(NULL);
     if (!display) {
         printf("no display\n");
         return 1;
     }
     static XScreenSaverInfo *mit_info = NULL;
     int event_base, error_base;
     if (XScreenSaverQueryExtension(display, &event_base, &error_base))
     {
             mit_info = XScreenSaverAllocInfo();
             XScreenSaverQueryInfo(display, DefaultRootWindow(display), mit_info);
             printf("Idle Time: %li\n", mit_info->idle);
     } else {
             printf("No XSS available: event=%d error=%d errno=%d\n", event_base, error_base, errno);
     }
     return 0;
 }
ChanganAuto avatar
us flag
Ubuntu 22.04 runs with Wayland instead of X11 by default. X software doesn't work on wayland. You may want to run X11 instead.
vvkatwss vvkatwss avatar
tl flag
Thank you. After switching to X11, it works.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.