forked from mirrors/org-mode
Add an X11 equivalent to org-mac-idle-seconds.
This needs a small C program (in UTILITIES/x11idle.c) to work.
This commit is contained in:
parent
c248cc69b2
commit
0410d6460c
|
@ -58,3 +58,4 @@ TODO
|
||||||
# fill-column: 72
|
# fill-column: 72
|
||||||
# mode: conf
|
# mode: conf
|
||||||
# End:
|
# End:
|
||||||
|
/UTILITIES/x11idle
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
2009-10-21 James TD Smith <ahktenzero@mohorovi.cc>
|
||||||
|
|
||||||
|
* UTILITIES/x11idle.c: Add a small C program which outputs the X11
|
||||||
|
idle time
|
||||||
|
|
||||||
2009-09-16 Carsten Dominik <carsten.dominik@gmail.com>
|
2009-09-16 Carsten Dominik <carsten.dominik@gmail.com>
|
||||||
|
|
||||||
* Makefile: Add dependencies for org-crypt.el.
|
* Makefile: Add dependencies for org-crypt.el.
|
||||||
|
@ -65,4 +70,3 @@
|
||||||
2008-04-25 Carsten Dominik <dominik@science.uva.nl>
|
2008-04-25 Carsten Dominik <dominik@science.uva.nl>
|
||||||
|
|
||||||
* Makefile (BATCH): Fix the path to the local lisp files.
|
* Makefile (BATCH): Fix the path to the local lisp files.
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
#include <X11/extensions/scrnsaver.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Based on code from
|
||||||
|
* http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/
|
||||||
|
*
|
||||||
|
* compile with 'gcc -l Xss x11idle.c -o x11idle' and copy x11idle into your
|
||||||
|
* path
|
||||||
|
*/
|
||||||
|
main() {
|
||||||
|
XScreenSaverInfo *info = XScreenSaverAllocInfo();
|
||||||
|
Display *display = XOpenDisplay(0);
|
||||||
|
|
||||||
|
//check that X11 is running or else you get a segafult/coredump
|
||||||
|
if (display != NULL) {
|
||||||
|
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
|
||||||
|
}
|
||||||
|
XScreenSaverQueryInfo(display, DefaultRootWindow(display), info);
|
||||||
|
printf("%u\n", info->idle);
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -73,6 +73,12 @@
|
||||||
modeline when habits are being displayed (if that module is being
|
modeline when habits are being displayed (if that module is being
|
||||||
loaded).
|
loaded).
|
||||||
|
|
||||||
|
2009-10-21 James TD Smith <ahktenzero@mohorovi.cc>
|
||||||
|
|
||||||
|
* org-clock.el (org-x11-idle-seconds): Add a method to get the X11
|
||||||
|
idle time using the xscreensaver extension.
|
||||||
|
(org-user-idle-seconds): Use X11 idle time if available.
|
||||||
|
|
||||||
2009-10-20 Carsten Dominik <carsten.dominik@gmail.com>
|
2009-10-20 Carsten Dominik <carsten.dominik@gmail.com>
|
||||||
|
|
||||||
* org-agenda.el (org-agenda-next-line): New command.
|
* org-agenda.el (org-agenda-next-line): New command.
|
||||||
|
@ -197,7 +203,7 @@
|
||||||
currently active clock if the user has exceeded the time returned
|
currently active clock if the user has exceeded the time returned
|
||||||
by `org-user-idle-seconds', based on the value of
|
by `org-user-idle-seconds', based on the value of
|
||||||
`org-clock-idle-time'.
|
`org-clock-idle-time'.
|
||||||
(org-clock-in): If, after resolving clocks,
|
(org-clock-in): If, after resolving clocks,
|
||||||
(org-clock-out): Cancel the `org-clock-idle-timer' on clock out.
|
(org-clock-out): Cancel the `org-clock-idle-timer' on clock out.
|
||||||
|
|
||||||
* org-clock.el (org-clock-resolve-clock): New function that
|
* org-clock.el (org-clock-resolve-clock): New function that
|
||||||
|
|
|
@ -762,16 +762,22 @@ non-dangling (i.e., currently open and valid) clocks."
|
||||||
"Return the current Mac idle time in seconds"
|
"Return the current Mac idle time in seconds"
|
||||||
(string-to-number (shell-command-to-string "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle; last}'")))
|
(string-to-number (shell-command-to-string "ioreg -c IOHIDSystem | perl -ane 'if (/Idle/) {$idle=(pop @F)/1000000000; print $idle; last}'")))
|
||||||
|
|
||||||
|
(defun org-x11-idle-seconds ()
|
||||||
|
"Return the current X11 idle time in seconds"
|
||||||
|
(/ (string-to-number (shell-command-to-string "x11idle")) 1000))
|
||||||
|
|
||||||
(defun org-user-idle-seconds ()
|
(defun org-user-idle-seconds ()
|
||||||
"Return the number of seconds the user has been idle for.
|
"Return the number of seconds the user has been idle for.
|
||||||
This routine returns a floating point number."
|
This routine returns a floating point number."
|
||||||
(if (eq system-type 'darwin)
|
(if (or (eq system-type 'darwin) (eq window-system 'x))
|
||||||
(let ((emacs-idle (org-emacs-idle-seconds)))
|
(let ((emacs-idle (org-emacs-idle-seconds)))
|
||||||
;; If Emacs has been idle for longer than the user's
|
;; If Emacs has been idle for longer than the user's
|
||||||
;; `org-clock-idle-time' value, check whether the whole system has
|
;; `org-clock-idle-time' value, check whether the whole system has
|
||||||
;; really been idle for that long.
|
;; really been idle for that long.
|
||||||
(if (> emacs-idle (* 60 org-clock-idle-time))
|
(if (> emacs-idle (* 60 org-clock-idle-time))
|
||||||
(min emacs-idle (org-mac-idle-seconds))
|
(min emacs-idle (if (eq system-type 'darwin)
|
||||||
|
(org-mac-idle-seconds)
|
||||||
|
(org-x11-idle-seconds)))
|
||||||
emacs-idle))
|
emacs-idle))
|
||||||
(org-emacs-idle-seconds)))
|
(org-emacs-idle-seconds)))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue