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
  • hollyberries@programming.dev
    link
    fedilink
    arrow-up
    4
    arrow-down
    1
    ·
    3 months ago

    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.comOP
      link
      fedilink
      English
      arrow-up
      1
      ·
      3 months 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.

  • myotheraccount@lemmy.world
    link
    fedilink
    arrow-up
    3
    ·
    3 months 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?

  • Eugenia@lemmy.ml
    link
    fedilink
    English
    arrow-up
    2
    arrow-down
    5
    ·
    3 months ago

    There’s nothing like you ask. Most time tracker apps are just a calendar where you write manually how much time you spent on something. So you can use something like Kimai, or use a paper calendar and write on it.

    But text log of the active window and a screencap, that’s the stuff of Microsoft Recall AI nightmares that Linux developers wouldn’t be keen to implement. What you’re asking is intrusive AI for others. Maybe you need to actually learn to be punctual and write down your activities, or simply, buy a Snapdragon laptop with Windows AI on it. And even then, that info stays with the AI, I don’t think it’s shared much with the user.

    • null_dot@lemmy.dbzer0.comOP
      link
      fedilink
      English
      arrow-up
      7
      ·
      3 months ago

      Most time tracker apps

      That’s not what I asked for.

      use a paper calendar and write on it.

      You don’t really understand time tracking, I see.

      But text log of the active window and a screencap, that’s the stuff of Microsoft Recall AI nightmares

      How is logging the title of the active window an AI nightmare ?

      the stuff of Microsoft Recall AI nightmares that Linux developers wouldn’t be keen to implement

      Like this you mean? Yes, surely that doesn’t exist.

      Maybe you need to actually learn to be punctual and write down your activities

      Maybe you need to try being… a bit less of a dick ?

      buy a Snapdragon laptop with Windows AI on it

      Kinda speechless at this one. Well done.

  • BCsven@lemmy.ca
    link
    fedilink
    arrow-up
    1
    arrow-down
    13
    ·
    3 months ago

    Chatgt says build a scrip using a few tools. xdotool and scrot. I don’t know if this code is good or not. And some hashes are making markdown headers. How do we paste code on here?

    #!/bin/bash

    Set interval (in seconds)

    INTERVAL=10

    Output directories

    LOG_FILE=“$HOME/window_log.txt” IMG_DIR=“$HOME/window_snaps” mkdir -p “$IMG_DIR”

    while true; do # Get timestamp TS=$(date “+%Y-%m-%d_%H-%M-%S”)

    # Get active window title
    TITLE=$(xdotool getactivewindow getwindowname 2>/dev/null)
    
    # Fallback if title is empty
    if [ -z "$TITLE" ]; then
        TITLE="(No active window)"
    fi
    
    # Take screenshot
    IMG_FILE="$IMG_DIR/snap_$TS.png"
    scrot "$IMG_FILE"
    
    # Log entry
    echo "$TS | $TITLE" >> "$LOG_FILE"
    
    # Wait before next iteration
    sleep $INTERVAL
    

    done

    • MasterOKhan@lemmy.ca
      link
      fedilink
      English
      arrow-up
      7
      ·
      3 months ago

      There is an etiquette to not just copy and pasting from ChatGPT. The fact you couldn’t verify the code yourself is a bigger issue.

      I understand you may have thought this may help, it really does not.

      • null_dot@lemmy.dbzer0.comOP
        link
        fedilink
        English
        arrow-up
        2
        ·
        3 months ago

        There’s several answers like this in this thread.

        I feel like the community would benefit from a sticky explaining some basic etiquette and how not to “help”.

        It’s not just dumping gen AI output in a thread, there’s other poorly considered answers here too.

      • BCsven@lemmy.ca
        link
        fedilink
        arrow-up
        1
        arrow-down
        1
        ·
        edit-2
        3 months ago

        Sure, seemed OP wasn’t a google searcher so I tried to show an example of two programs coming together. The code seems plausible, but its there as an example of steps. I find LMM is typically trash, but can get you started. But your etiquette note is noted

    • null_dot@lemmy.dbzer0.comOP
      link
      fedilink
      English
      arrow-up
      5
      ·
      3 months ago

      Maybe ask chatgpt whether xdotool is compatible with wayland.

      I get that you’re trying to help but, this is not the way.

        • null_dot@lemmy.dbzer0.comOP
          link
          fedilink
          English
          arrow-up
          2
          ·
          3 months ago

          This might shock you but… I have actually spent some time looking into this.

          The tools you’ve suggested aren’t compatible with Wayland. It seems that alternatives don’t really exist, or cause the problems I mentioned in my post.

          Additionally, I have a few decades experience with Linux and while I’m not some amazing Linux guru I do know what a bash script is and how to “link two programs together”.

          Finally, like everyone on the planet I also know what chatgpt is and might even consider using it to create a bash script if I knew what tools were compatible with Wayland.

          • BCsven@lemmy.ca
            link
            fedilink
            arrow-up
            1
            arrow-down
            1
            ·
            3 months ago

            No worries, the post made it sound like you had not tries searching. So I assumed your were a new person that had put in no effort yet. My mistake

              • BCsven@lemmy.ca
                link
                fedilink
                arrow-up
                1
                arrow-down
                1
                ·
                3 months ago

                Lol, this is why the Linux community gets a bad rap. Somebody tries to be helpful and the community gets hostile. Hope you have a good rest of your week dude.

                • null_dot@lemmy.dbzer0.comOP
                  link
                  fedilink
                  English
                  arrow-up
                  2
                  arrow-down
                  1
                  ·
                  3 months ago

                  It’s funny you say that. I was thinking exactly the same thing about your comments.

                  I’ve asked for help, you posted a chatgpt response, and now you’ve claimed eleventy times that I seem like I don’t know where to start or don’t seem like the type to search things.

                  “OP should’ve googled it first” is one of the hallmarks of toxic communities.