website/content/blog/enable-real-idletime-for-org-mode-on-ubuntu.md
2023-10-19 01:04:39 +02:00

64 lines
3.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: 'Enable real idletime for Org Mode on Ubuntu'
date: 2011-07-04T09:11:00.000Z
draft: false
taxonomies:
tags: [ "emacs" ]
categories: [ "apps" ]
---
Org Mode can use the idle time to correct time tracking entries. On the Mac this works on the idle time of the computer, on other platforms it uses the idle time of emacs. Hence if you do a significant task in another program it will be idle for org-mode. There is a little program delivered with org-mode sources to estimate the "real" idle time based on the information used by screensavers. Unfortunaltely it is in source code and needs to be compiled first. Everything is actually well documented, just scattered. Let's see where that little program is located
$ locate x11idle
/home/pti/.emacs.d/vendor/org-mode/UTILITIES/x11idle.c
This conveniently shows the location of the source file. If you might find a **x11info** file (without .c) in a bin directory then it is already installed and you're done. If you get no results and there is some remark that the database is too old then it is time to refresh it using **sudo updatedb**. Then the lookup should find the file. Now go to the folder where the file is located. In my case :
$ cd ~/.emacs.d/vendor/org-mode/UTILITIES
We need to make sure we have the necessary X screensaver libraries for compiling :```
$ sudo apt-get install lib-xss-de
sudo apt-get install libxss-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
x11proto-scrnsaver-dev
The following NEW packages will be installed:
libxss-dev x11proto-scrnsaver-dev
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 34.1 kB of archives.
After this operation, 225 kB of additional disk space will be used.
Do you want to continue \[Y/n\]?
Get:1 http://be.archive.ubuntu.com/ubuntu/ natty/main x11proto-scrnsaver-dev all 1.2.1-1 \[21.3 kB\]
Get:2 http://be.archive.ubuntu.com/ubuntu/ natty/main libxss-dev amd64 1:1.2.1-1 \[12.9 kB\]
Fetched 34.1 kB in 0s (200 kB/s)
Selecting previously deselected package x11proto-scrnsaver-dev.
(Reading database ... 567603 files and directories currently installed.)
Unpacking x11proto-scrnsaver-dev (from .../x11proto-scrnsaver-dev\_1.2.1-1\_all.deb) ...
Selecting previously deselected package libxss-dev.
Unpacking libxss-dev (from .../libxss-dev\_1%3a1.2.1-1\_amd64.deb) ...
Processing triggers for man-db ...
Setting up x11proto-scrnsaver-dev (1.2.1-1) ...
Setting up libxss-dev (1:1.2.1-1) ...
Now we can compile **x11idle**. We need to specify to link against the X11 and X Screensaver libraries (Xss). I immediately place the resulting executable file in **~/bin/x11idle**. Alternatively you could use the /usr/local/bin folder, but first compile to a temporary location like **/tmp** and move it there : **sudo mv /tmp/x11idle /usr/local/bin**.```
$ gcc -o ~/bin/x11idle -lX11 -lXss x11idle.c
x11idle.c: In function main:
x11idle.c:19:5: warning: format %u expects type unsigned int, but argument 2 has type long unsigned int
$ x11idle
22
$ x11idle
20
I tried to run it using the normal path and got 22 and 20 seconds idle time : it works !!! The orgmode code will now find and use it. For more background info see
* [Blogpost about getting idle time in linux.](http://coderrr.wordpress.com/2008/04/20/getting-idle-time-in-unix/)
* [The message with the patch proposal for including it with org-mode](http://osdir.com/ml/emacs-orgmode-gnu/2009-10/msg00545.html)
2011-07-04 Mon 11:11 [Track down reason for Dangling Time References](file:///home/pti/org/emacs.html)