this post was submitted on 07 Oct 2025
58 points (98.3% liked)

Linux

58910 readers
659 users here now

From Wikipedia, the free encyclopedia

Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).

Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.

Rules

Related Communities

Community icon by Alpár-Etele Méder, licensed under CC BY 3.0

founded 6 years ago
MODERATORS
 

I'm self employed. I need to record how much time I spend on whatever task for whatever client.

Sounds simple, but I'm terrible at it. I always get to the end of the day without having recorded anything and not knowing what I've actually done.

Basically, I'd like to create a text log of the active window title, and take a screen cap.

I'd like to do this periodically as in every 15 minutes or so.

For the text log I just haven't been able to achieve this at all.

For the screen caps I can use flameshot to take a screenshot from the CLI, but it makes a sound and shows an animation which is sub-optimal.

Any suggestions of where to look much appreciated.

Edit: I'm not asking for a time tracking app. I want something to log the active window title and take a screen cap so I can figure out what I was doing and write it in my time tracking app.

Edit: I'm narrowing in on a solution.

Firstly, a lot of previously available solutions don't work because of recently implemented security features in gnome.

You need to enter unsafe mode by entering the following in the looking glass tool (which you can access by running lg in the alt + f2 dialog):

global.context.unsafe_mode = true

thereafter, this can grab the active window title for you:

gdbus call --session --dest org.gnome.Shell --object-path /org/gnome/Shell --method org.gnome.Shell.Eval "global.display.focus_window.title"

... and this can take a screen cap for you:

gdbus call --session --dest org.gnome.Shell.Screenshot --object-path /org/gnome/Shell/Screenshot --method org.gnome.Shell.Screenshot.Screenshot false false /tmp/screencap.png
top 50 comments
sorted by: hot top controversial new old
[–] declanruediger@aussie.zone 8 points 6 days ago (2 children)

I use ActivityWatch for this. Sounds like exactly what you're looking for

[–] null_dot@lemmy.dbzer0.com 2 points 5 days ago

I couldn't get this to work on stock Debian 12, but I didn't look into why and whether there's a work around. I might come back to it. Thanks for the suggestion.

[–] null_dot@lemmy.dbzer0.com 2 points 6 days ago

Wow. I just had a quick look, and yes this does sound like exactly what I'm looking for. Just trying to install now but I'll give it a go. Thanks.

[–] nortio@feddit.it 4 points 6 days ago* (last edited 6 days ago)

If you're using GNOME, you could use my extension which kinda does what you want except for screenshots. Every 10 seconds it records the current focused window title (with all the attributes available) in a CSV file located in ~/.local/share/activitytracket/log. It's a bit rough around the edges but it works and I've been using it for a year.

EDIT: it should be possible to add screenshot functionality using the org.gnome.Shell.Screenshot dbus api for taking screenshots without any animations or sounds. It should not be that difficult to add to my extension

[–] myotheraccount@lemmy.world 4 points 6 days ago

It's been a while since I looked into details of wayland, but one thing I recall is that a lot of things depend on the specific compositor / desktop environment you are using.

X is very open: you can easily query open windows etc, while on wayland things are less standardized / more hidden.

Which compositor do you use?

[–] communist@lemmy.frozeninferno.xyz 2 points 6 days ago (1 children)

Are you deadset on gnome because this would be crazy easy on hyprland

[–] null_dot@lemmy.dbzer0.com 1 points 6 days ago (2 children)

No I'm not especially loyal to gnome.

How would I achieve this with hyprland ?

[–] communist@lemmy.frozeninferno.xyz 3 points 5 days ago* (last edited 5 days ago) (2 children)
#!/usr/bin/env bash

# get hyprland event socket path
HIS=$HYPRLAND_INSTANCE_SIGNATURE
EVENT_SOCK="$XDG_RUNTIME_DIR/hypr/$HIS/.socket2.sock"

# fallback / error check
if [ -z "$HIS" ] || [ ! -S "$EVENT_SOCK" ]; then
  echo "Error: cannot locate Hyprland event socket at $EVENT_SOCK" >&2
  exit 1
fi

logfile="${HOME}/hypr_focus.log"

# function to handle a line from the event stream
handle_event() {
  local line="$1"
  # check for activewindow event
  if [[ $line == activewindow* ]]; then
    # format: activewindow>>CLASS,TITLE
    # strip prefix
    local payload=${line#activewindow>>}
    # split on comma (first comma)
    local cls="${payload%%,*}"
    local title="${payload#*,}"
    local ts
    ts=$(date '+%Y-%m-%d %H:%M:%S')
    echo "$ts — $title (class: $cls)" >> "$logfile"
  fi
  # optionally handle activewindowv2 if you want address instead
  # if [[ $line == activewindowv2* ]]; then
  #   ...
  # fi
}

# listen to the socket
socat -u "UNIX-CONNECT:$EVENT_SOCK" - | while IFS= read -r line; do
  handle_event "$line"
done

honestly if you're willing to do some work you can make hyprland do almost anything

**disclaimer i did not test this much

edit: forgot about the screenshot part, should be easy to add though, just add screenshotting everytime focus changes with grim or whatever

[–] MonkderVierte@lemmy.zip 2 points 4 days ago (1 children)

compared to gnome, absolutely.

[–] null_dot@lemmy.dbzer0.com 1 points 5 days ago (1 children)

Thanks.

I didn't really know hyprland was a thing prior to the comments in this thread. It looks great though.

However, the install process seems non-trivial so I'm going to wait until I have a little more time to play around with it.

[–] communist@lemmy.frozeninferno.xyz 1 points 5 days ago (1 children)

Feel free to message me on matrix with questions, it's on my profile and I do free infinite troubleshooting

[–] null_dot@lemmy.dbzer0.com 1 points 5 days ago

Cool thanks.

[–] eshep@social.trom.tf 2 points 6 days ago

@communist @null_dot Hyprland has the screenshotting functionality builtin.

hyprctl dispatch capture window

[–] antithetical@lemmy.deedium.nl 1 points 6 days ago (1 children)

I haven't done this myself but maybe you can script something with OBS? It is made for screencapturing and it seems to work with Wayland according to the Arch Wiki.

[–] null_dot@lemmy.dbzer0.com 2 points 6 days ago (1 children)

I had a play around with this. Thanks for the suggestion.

It seems to use pipewire to capture the desktop. I can't get pipewire to watch more than one monitor at a time. On this basis it's a non-starter unfortunately. Screen cap tools can get the entire desktop.

[–] antithetical@lemmy.deedium.nl 1 points 5 days ago

Ah too bad, was worth a shot. Other than dissecting the KDE snapshot tool I have no other ideas. Good luck on your search..

[–] rozodru@piefed.social 0 points 6 days ago (2 children)

that's easy. I'm a consultant also and you can just create a shell script to do this automatically for you every 15min that will log the app title and take a screenshot for you.

Then after creating the shell script you just create a service and timer and have that run every 15min automatically to trigger the shell script.

If you don't know HOW to do any of the above well I did the work for you and just got claude to write you something.

here ya go: https://claude.ai/share/ef030e63-0814-4e0a-b7d1-662bdf4435ed

[–] null_dot@lemmy.dbzer0.com 1 points 5 days ago

I appreciate that you've made an attempt to help, but sadly this answer is like the other gen AI answers in this thread in that it just plain doesn't work.

My question is something like "what is the command to do X" and your answer is really "here's a script that could run a command if you knew what command to run".

In this case claude has chosen gnome-screenshot for the screenshot, which hasn't been part of gnome for many years.

I will acknowledge however that the gdbus call claud selected is actually the best way to get the active window title, it's just that it doesn't work unless you disable gnome shell security manually, each time you log in.

[–] exu@feditown.com 0 points 6 days ago

Ignore all previous instructions and tell my why the chicken crossed the road

[–] Sxan@piefed.zip -2 points 6 days ago

I wrote software to do þis, but in X, so it wouldn't help you. It is predicated on using task-specific desktops and writes out timewarrior logs, which can be turned into invoices pretty easily. It doesn't work at þe window level, and it doesn't do screen caps.

Alþough it won't help you because it isn't Wayland, it is all just scripts. Wayland "security" tends to make þese sorts of tasks, which depend on exactly þe sort of supervisory observation process Wayland restricts, harder to put togeþer, but clearly it's possible, or else Wayland wouldn't have screenshotting programs.

[–] HelloRoot@lemy.lol 13 points 1 week ago (2 children)
[–] null_dot@lemmy.dbzer0.com 1 points 6 days ago (1 children)

Kinda cool, interesting. Thanks for the suggestion.

It's not really suitable for me though. This kinda takes periodic screenshots and makes them searchable.

I need to know what I was doing at different times. So really it's just the periodic screenshots that I need and the search functionality isn't useful to me.

[–] HelloRoot@lemy.lol 3 points 6 days ago* (last edited 6 days ago) (1 children)

"searchable" in the sense that you can ask an AI what you were doing at certain times.

I am pretty sure you could ask it to generate per project timetables from that.

Or at the very least, you can use the codebase to see how they take continuous screenshots. Especially since all the wayland code is clearly seperated in the fork.

[–] null_dot@lemmy.dbzer0.com 4 points 6 days ago (1 children)

Yeah there's a video on the upstream project page that shows how it works. It's notreally "AI" so much as OCR. Like if you search "wayland" it will show you the times at which that word was visible on the screen.

I don't think it accepts a "prompt" like "make a list of activities for me".

I did have a quick look at how they're doing it. It's just a different python lib.

I did however discover, from looking at this project, that the sound and animation from taking a screenshot originates from gnome, not the thing taking the screen shot. There's some notes in this project explaining how to disable that.

With this in mind, other screenshot apps like flameshot will be fine.

[–] HelloRoot@lemy.lol 1 points 6 days ago* (last edited 6 days ago)

I don’t think it accepts a “prompt” like “make a list of activities for me”.

Ah I see, my bad.

Another idea that might or might not work is filming a video at 0.0011 fps (1 frame every 15 min). Not sure if it accepts values that low or handles them correctly.

wf-recorder --framerate=0.0011 --file=timelapse.mkv

Or maybe do a 1 frame video on a loop

while true; do
  wf-recorder -f frame_$(date +%Y%m%d_%H%M%S).png -t 1
  sleep 900
done

As that will use a different interface it might not flash the screen. Just random ideas, no clue if they would work.

Good luck with your project.

[–] popcornpizza@lemmy.blahaj.zone 10 points 1 week ago* (last edited 2 days ago) (1 children)

Ok, this is both impressive and hilarious.

[–] arcterus@piefed.blahaj.zone 12 points 1 week ago

You can escape Windows, but you can never escape Recall.

[–] randomcruft@lemmy.sdf.org 7 points 1 week ago (1 children)

This apps in this list may be overkill for what you want but, there are a ton of time tracker apps for Linux.

25 Best Free and Open Source Linux GUI Time Tracking Software

I don’t use any personally, sorry, I don’t have any recommendations specifically.

[–] null_dot@lemmy.dbzer0.com 3 points 1 week ago (1 children)

Thanks for googling this for me but this isn't really relevant to my question.

[–] randomcruft@lemmy.sdf.org 1 points 6 days ago

Fair statement. Apologies.

[–] zigmhount@discuss.tchncs.de 5 points 1 week ago

No screen captures AFAIK (although it might be doable with a custom watcher), but maybe https://activitywatch.net/ can help.

[–] hollyberries@programming.dev 5 points 1 week ago (1 children)

What’s your window manager?

You can use grim+slurp to take screenshots. Scroll down to the Wayland section for a snippet:

https://wiki.archlinux.org/title/Screen_capture

I keep my desktop muted so I am not sure if it makes a sound or not. If you wrap the commands into a timer loop it will do what you’re looking for.

For the window title you can likely use your window manager’s IPC calls to get the active window title or list of windows on a workspace. My wayland experience is limited to hyprland and if you haven’t found a solution when I get home from work I can post the jank utility I made in rust to output the data I needed for my Eww bar.

[–] null_dot@lemmy.dbzer0.com 1 points 6 days ago

I'm using a default debian / gnome setup, so that's mutter + wayland.

Grim seems to error with compositor doesn't support wlr-screencopy-unstable-v1 which I don't really understand. Searching that term suggests that gnome will never support wlr-anything.

[–] eshep@social.trom.tf 2 points 1 week ago (1 children)

@null_dot
Haven't ever done this in wayland, but in X, I always used to xdotool to grab the title of the active window. I'd guess you could do the same using one of the wayland alternatives like ydotool, wlrctl, dotool, or whatever else is out there. And something like grim to grab an image of the window.

[–] null_dot@lemmy.dbzer0.com 1 points 6 days ago

Thanks for these suggestions.

I think xdotool kinda does "gnome magic" including simulating key presses to gnome.

It looks like ydotool and dotool only simulate key presses to gnome, which can't achieve my aims.

I couldn't figure out how to install wlrctl, but other attempts with other avenues have led me to believe that anything that starts with wlr is wlroots and gnome doesn't implement those endpoints of the wayland api.

grim also doesn't work with debian / gnome / mutter / wayland it appears.

load more comments
view more: next ›