Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package xprintidle for openSUSE:Factory 
checked in at 2025-05-12 16:48:33
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/xprintidle (Old)
 and      /work/SRC/openSUSE:Factory/.xprintidle.new.30101 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "xprintidle"

Mon May 12 16:48:33 2025 rev:3 rq:1276483 version:0.3.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/xprintidle/xprintidle.changes    2023-05-23 
14:55:37.066864532 +0200
+++ /work/SRC/openSUSE:Factory/.xprintidle.new.30101/xprintidle.changes 
2025-05-12 16:52:14.085128044 +0200
@@ -1,0 +2,7 @@
+Fri May  2 07:58:21 UTC 2025 - Dirk Müller <dmuel...@suse.com>
+
+- update to 0.3.0:
+  * add --human-readable, -H
+  * reformat code to have less indentations
+
+-------------------------------------------------------------------

Old:
----
  xprintidle_0.2.5.orig.tar.gz

New:
----
  xprintidle_0.3.0.orig.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ xprintidle.spec ++++++
--- /var/tmp/diff_new_pack.COiMUK/_old  2025-05-12 16:52:15.481186698 +0200
+++ /var/tmp/diff_new_pack.COiMUK/_new  2025-05-12 16:52:15.481186698 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package xprintidle
 #
-# Copyright (c) 2023 SUSE LLC
+# Copyright (c) 2025 SUSE LLC
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
 
 
 Name:           xprintidle
-Version:        0.2.5
+Version:        0.3.0
 Release:        0
 Summary:        Utility to print user's idle time in X
 License:        GPL-2.0-only

++++++ xprintidle_0.2.5.orig.tar.gz -> xprintidle_0.3.0.orig.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xprintidle-0.2.5/AUTHORS new/xprintidle-0.3.0/AUTHORS
--- old/xprintidle-0.2.5/AUTHORS        2022-06-07 14:13:30.000000000 +0200
+++ new/xprintidle-0.3.0/AUTHORS        2024-07-03 13:48:46.000000000 +0200
@@ -2,3 +2,4 @@
 Eivind Magnus Hvidevold <hvidev...@gmail.com>
 Magnus Henoch <hen...@dtek.chalmers.se> (initial author)
 Richard Leitner <d...@g0hl1n.net>
+Sicelo A. Mhlongo <absi...@gmail.com>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xprintidle-0.2.5/README.md 
new/xprintidle-0.3.0/README.md
--- old/xprintidle-0.2.5/README.md      2022-06-07 14:13:30.000000000 +0200
+++ new/xprintidle-0.3.0/README.md      2024-07-03 13:48:46.000000000 +0200
@@ -14,7 +14,8 @@
 
 ### Dependencies ###
 
-You need the development files for the X11, Xext and Xss library.
+You need the development files for the X11, Xext and Xss libraries, and a
+C99-compliant compiler.
 
 ## Contributing ##
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xprintidle-0.2.5/meson.build 
new/xprintidle-0.3.0/meson.build
--- old/xprintidle-0.2.5/meson.build    2022-06-07 14:13:30.000000000 +0200
+++ new/xprintidle-0.3.0/meson.build    2024-07-03 13:48:46.000000000 +0200
@@ -1,9 +1,9 @@
 project('xprintidle',
   'c',
-  version : '0.2.5',
+  version : '0.3.0',
   license : 'GPL-2.0',
   default_options : [
-    'c_std=c89',
+    'c_std=c99',
     'warning_level=3',
     'optimization=3',
   ]
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xprintidle-0.2.5/xprintidle.1 
new/xprintidle-0.3.0/xprintidle.1
--- old/xprintidle-0.2.5/xprintidle.1   2022-06-07 14:13:30.000000000 +0200
+++ new/xprintidle-0.3.0/xprintidle.1   2024-07-03 13:48:46.000000000 +0200
@@ -33,6 +33,9 @@
 .B \-h ", " \-\^\-help
 Output a usage message and exit.
 .TP
+.B \-H ", " \-\^\-human-readable
+Output the idle time in a human-readable format.
+.TP
 .B \-v ", " \-\^\-version
 Output the version number and exit.
 .
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/xprintidle-0.2.5/xprintidle.c 
new/xprintidle-0.3.0/xprintidle.c
--- old/xprintidle-0.2.5/xprintidle.c   2022-06-07 14:13:30.000000000 +0200
+++ new/xprintidle-0.3.0/xprintidle.c   2024-07-03 13:48:46.000000000 +0200
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: GPL-2.0-only
  *
- * This program prints the "idle time" of the user to stdout.  The "idle time"
+ * This program prints the "idle time" of the user to stdout. The "idle time"
  * is the number of milliseconds since input was received on any input device.
  * If unsuccessful, the program prints a message to stderr and exits with a
  * non-zero exit code.
@@ -19,7 +19,7 @@
  *
  * xprintidle is distributed in the hope that it will be useful, but WITHOUT 
ANY
  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
FOR
- * A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+ * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License along with
  * xprintidle. If not, see <https://www.gnu.org/licenses/>.
@@ -49,8 +49,9 @@
           "Query the X server for the user's idle time\n"
           "\n"
           "Options:\n"
-          "  -h, --help        Show this text\n"
-          "  -v, --version     Print the program version\n"
+          "  -h, --help              Show this text\n"
+          "  -H, --human-readable    Output the time in a human readable 
format\n"
+          "  -v, --version           Print the program version\n"
           "\n"
           "Report bugs at: https://github.com/g0hl1n/xprintidle/issues\n";
           "Written by Magnus Henoch and others; see\n"
@@ -58,7 +59,7 @@
           name);
 }
 
-void print_version() {
+void print_version(void) {
   fprintf(stdout, "xprintidle %s\n", XPRINTIDLE_VERSION);
 }
 
@@ -68,8 +69,7 @@
  * On success 0 is returned.
  * On error -1 is returned.
  */
-int get_x_idletime(uint64_t *idle)
-{
+int get_x_idletime(uint64_t *idle) {
   XScreenSaverInfo *ssi;
   Display *dpy;
   int event_basep, error_basep, vendrel;
@@ -117,24 +117,67 @@
   return 0;
 }
 
+/* This function prints miliseconds in a human-readable format. */
+void print_human_time(uint64_t time) {
+  /* The C standard says that integer division round towards 0. */
+
+  int convFacs[] = {24 * 60 * 60 * 1000, 60 * 60 * 1000, 60 * 1000, 1000, 1};
+  char *names[] = {"day", "hour", "minute", "second", "millisecond"};
+  size_t units = sizeof(convFacs) / sizeof(int);
+
+  int firstPrint = 1;
+  size_t i;
+  for (i = 0; i < units; i++) {
+    int unitMag = time / convFacs[i];
+    time %= convFacs[i];
+
+    if (!unitMag)
+      continue;
+
+    if (!firstPrint)
+      printf(", ");
+    printf("%d %s", unitMag, names[i]);
+    if (unitMag != 1)
+      printf("s");
+
+    firstPrint = 0;
+  }
+
+  /* Smallest unit would be 0. */
+  if (firstPrint)
+    printf("0 %ss", names[units - 1]);
+
+  printf("\n");
+}
+
 int main(int argc, char *argv[]) {
   uint64_t idle;
+  int human = 0;
 
   /* TODO change this to getopts as soon as we have more options */
   if (argc != 1) {
     if (!strcmp(argv[1], "-v") || !strcmp(argv[1], "--version")) {
       print_version();
       return EXIT_SUCCESS;
+    } else if (!strcmp(argv[1], "-H") || !strcmp(argv[1], "--human-readable")) 
{
+      human = 1;
+    } else if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) {
+      print_usage(argv[0]);
+      return EXIT_FAILURE;
     }
-    print_usage(argv[0]);
-    return EXIT_FAILURE;
+
   }
 
   if (get_x_idletime(&idle) < 0) {
     return EXIT_FAILURE;
   }
 
-  printf("%lu\n", idle);
+  if (human) {
+    print_human_time(idle);
+    return EXIT_SUCCESS;
+  }
+
+  printf("%llu\n", idle);
   return EXIT_SUCCESS;
 }
 
@@ -157,32 +200,34 @@
   CARD16 state;
   BOOL onoff;
 
-  if (DPMSQueryExtension(dpy, &dummy, &dummy)) {
-    if (DPMSCapable(dpy)) {
-      DPMSGetTimeouts(dpy, &standby, &suspend, &off);
-      DPMSInfo(dpy, &state, &onoff);
-
-      if (onoff) {
-        switch (state) {
-        case DPMSModeStandby:
-          /* this check is a little bit paranoid, but be sure */
-          if (idleTime < (unsigned)(standby * 1000))
-            idleTime += (standby * 1000);
-          break;
-        case DPMSModeSuspend:
-          if (idleTime < (unsigned)((suspend + standby) * 1000))
-            idleTime += ((suspend + standby) * 1000);
-          break;
-        case DPMSModeOff:
-          if (idleTime < (unsigned)((off + suspend + standby) * 1000))
-            idleTime += ((off + suspend + standby) * 1000);
-          break;
-        case DPMSModeOn:
-        default:
-          break;
-        }
-      }
-    }
+  if (!DPMSQueryExtension(dpy, &dummy, &dummy))
+    return idleTime;
+  else if (!DPMSCapable(dpy))
+    return idleTime;
+
+  DPMSGetTimeouts(dpy, &standby, &suspend, &off);
+  DPMSInfo(dpy, &state, &onoff);
+
+  if (!onoff)
+    return idleTime;
+
+  switch (state) {
+  case DPMSModeStandby:
+    /* this check is a little bit paranoid, but be sure */
+    if (idleTime < (unsigned)(standby * 1000))
+      idleTime += (standby * 1000);
+    break;
+  case DPMSModeSuspend:
+    if (idleTime < (unsigned)((suspend + standby) * 1000))
+      idleTime += ((suspend + standby) * 1000);
+    break;
+  case DPMSModeOff:
+    if (idleTime < (unsigned)((off + suspend + standby) * 1000))
+      idleTime += ((off + suspend + standby) * 1000);
+    break;
+  case DPMSModeOn:
+  default:
+    break;
   }
 
   return idleTime;

Reply via email to