Skip to content

hhpc does not reset timer on mouse events #5

@eazar001

Description

@eazar001

I actually am succesfully working around the issue at the moment, and so far it is okay; but I thought it might help if I present the information to you:

  1. I modified your program to be a 'one-shot' program, where it grabs and hides the mouse, and when the mouse is active again (i.e. moved), it unhides the mouse and actually exits altogether.
  2. I created a small wrapper script in python that creates two threads, one thread (an interrupt thread) that activates only on mouse events, and sends an interrupt request signal to the other thread, which is the timer thread. The signal is simply a boolean variable that tells the timer thread to reset the timer.
  3. If the timer counts down successfully, a process is opened that externally calls your modified one-shot version of hhpc, and then instantly hides the mouse. While your program is running, the python script is blocking any further acitivity on its end. Once the mouse is moved, your program of course, quits. After this the script is unblocked the timer is again reset and the process repeats.
  4. Events are read from /input/dev via xev bindings in a python module. The script is daemonized as a systemd service to remove the need for any manual calls to root.

I didn't bother with profiling, but a quick examination of top showed me that the cpu usage ranged from 0-0.3% CPU usage. It was at 0 of course mainly when the mouse was hidden and/or grabbed by your program. Obviously this is not the most ideal solution, as it requires a wrapper script on top of your executable, and removal of almost half of your code (but it works). I just gave you this hoping it might help you find a more direct solution, and to suggest that (maybe) threading would be a good way to approach this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions