reddit / emacs

Your tips for time recording in emacs?

thephatmaster · 2022-08-22 05:40
Morning all, tldr; what are your tips for recording in emacs? **background** I work in a legal environment. Sometimes I need to seek costs for time spent on a matter ('project' - I guess in emacs terms) I came to emacs a year or so ago via the Doom/org/org-roam popularity explosion. **what I do now** I tried using timers in org, but they are easy to forget to 'end' So, I use an excel spreadsheet, which has the same issue, but the empty cell helps remind me visually to enter my finish time on a task. It also has validation, functions etc that let me analyse and summarise my data **what I'd like to do** My workflow really could use: - Automatic time recording, for time spent editing documents; - something smart enough not to cause me to seek costs for making a coffee, or leaving my computer on during lunch; - some kind of reporting on the time spent I've seen a few solutions for emacs - wakatime, buffer timer, activity-watch-time etc, and was wondering what everyone's experience of those, or any self-made systems, are
[deleted] · 2022-08-22 06:01
[deleted]
danderzei · 2022-08-22 07:44
Try org mode. Some people use it to generate bills. You can clock in and out for each headline/action. https://orgmode.org/manual/Clocking-Work-Time.html
bring_dat · 2022-08-22 08:40
Actually a good advice. It is also worth using org-agenda and log time directly there
autechy · 2022-08-22 08:55
Sounds like org-mode is what you need, particularly clocking like was mentioned in another comment. However your workflow requires lots of customization. Ultimately you need to take a deeper dive into org-mode and what it can do(and how), along with [org-clock-convenience](https://github.com/dfeich/org-clock-convenience) with maybe [org-journal](https://github.com/bastibe/org-journal). Your starting point should always be agenda, not the .org file itself.
natrys · 2022-08-22 10:15
> I tried using timers in org, but they are easy to forget to 'end' There are safeguards in org-mode to deal with that, but for them to work you need additional component that talks to OS or display server because Emacs can't know if you have been idle outside of Emacs (if all you want to deal with is idle time inside Emacs, that should work out of box I think, so you probably didn't mean that). On Linux/Xorg, you need to install a program called `x11idle` (probably from xprintidle package, see the doc for `org-clock-x11idle-program-name` variable). Personally, for fun I wrote my own [dynamic module](https://github.com/natrys/xidle) to replace it. On MacOS looks like it needs something like `ioreg` and perl to be installed. Additionally, you have to set `org-clock-idle-time` to a non-nil value. Consult the doc for that variable. > Automatic time recording, for time spent editing documents; I agree with this, time tracking should ideally be completely automatic. I have also tried other external programs and they all fall short of expectation with the exception being [arbtt](https://arbtt.nomeata.de/). It's a fantastic little program that takes a snapshot of your desktop every N seconds (configurable). But the best part is, you can define a set of programmatic rules that automatically separate work form non-work (or literally any kind of tag you want to apply). For example, a simple configuration to demonstrate usecase: -- define idle threshold for all programs except mpv $idle > 120 && (! (current window $program == "gl")) ==> tag inactive, current window $program == "emacs" ==> { tag app:emacs, { current window $title == "*scratch*" ==> tag project:elisp; current window $title =~ m!~/blog/(.*?).org! ==> { tag project:blog, tag blog:$1 }; current window $title =~ m!~/work/(.*?)/?$! ==> { tag project:work, tag work:$1 }; current window $title =~ m!\*(?:devdocs|info)\*! ==> tag project:research; current window $title =~ m!(?:pdf|epub)$! ==> tag project:research; current window $title =~ m!^/ssh:! ==> tag project:remote_server; }}, The trick with arbtt (same as any other time tracking program) is you need to export useful information (like currently open file, url etc.) via window title. For Emacs you could do that by configuring `frame-title-format`, for firefox there are addons and so on. And then in arbtt you configure regex based rules to tag samples programmatically. The downside of arbtt is it's kinda low level, you might need to write some scripts of your own (to do things like generating plots) but I consider that an upside ;)
doolio_ · 2022-08-22 12:20
[prot/tmr](https://protesilaos.com/emacs/tmr) might be worth a look for you. Edit: another good resource is [Bernt Hansen's Org config](http://doc.norang.ca/org-mode.html#Clocking).
illustrious_trees · 2022-08-22 13:23
From the post: > I tried using timers in org, but they are easy to forget to 'end'
paretoOptimalDev · 2022-08-22 14:06
I came here to suggest arbtt as well, really good program thats really flexible and extensible.
rfeynman42 · 2022-08-22 19:20
You might like [WakaTime](https://wakatime.com/) and its corresponding Emacs mode: [https://github.com/wakatime/wakatime-mode](https://github.com/wakatime/wakatime-mode) It's fully automatic and iirc has idle detection which means you won't get timed for your breaks. It's intended for programmers, but I think it'd work well in your usecase with some hacking - even though you (presumably) always use Org mode, the project-based tracking it has could work for you.
danderzei · 2022-08-22 20:12
They are also easy to forget to start. Any timer relies on the discipline to start and stop it on time. You could write a hook perhaps that starts and stops a timer when a buffer is active
fuzunspm · 2022-08-23 19:56
I self host this and it’s used by whole team. It’s awesome