-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Maybe want:
- Detect Inactivity: Automatically detect when the mouse and keyboard have been idle for a specified period (e.g., 3 minutes).
- Start Testing: When inactivity is detected, start the automated testing process (which involves running
pyautoguion the host). - Pause Testing on Activity: Immediately pause the testing process if any mouse or keyboard activity is detected.
- Log Results: Log the results of the tests to a file.
- Provide Audio Feedback: Use
espeak-ngto provide audio feedback on the status of the tests. - Run
pyautoguion the Host: Run thepyautoguiscript directly on the host machine (instead of inside the Docker container).
Here's a possible approach to achieve this:
1. Detect Inactivity (Host - Linux Specific):
You can use xprintidle command to detect inactivity. You may need to install it first
sudo apt-get install xprintidleor
sudo pacman -S xprintidleThen you can check the inactivity
xprintidleThis command will print the time, in milliseconds, that the system has been idle.
2. Main Script on the Host:
#!/bin/bash
# Settings
IDLE_TIME=180000 # 3 minutes in milliseconds (3 * 60 * 1000)
LOG_FILE="$HOME/test_results.log"
PY_SCRIPT="$HOME/path/to/your/script.py" #Set your right path here
SPEAK_CMD="espeak-ng" # Assuming espeak-ng is in your PATH
# Function to speak a message
speak() {
$SPEAK_CMD "$1" &
}
# Start with a clean log file
> "$LOG_FILE"
# Function to run the tests
run_tests() {
speak "Starting automated tests"
echo "Starting tests at $(date)" >> "$LOG_FILE"
# Run your python script and append output
python3 "$PY_SCRIPT" >> "$LOG_FILE" 2>&1
TEST_EXIT_CODE=$?
if [ $TEST_EXIT_CODE -eq 0 ]; then
speak "Automated tests completed successfully"
echo "Tests completed successfully at $(date)" >> "$LOG_FILE"
else
speak "Automated tests failed with code $TEST_EXIT_CODE"
echo "Tests failed with code $TEST_EXIT_CODE at $(date)" >> "$LOG_FILE"
fi
speak "Stopping automated tests"
}
# Main loop
while true; do
idle_time=$(xprintidle)
if [ "$idle_time" -gt "$IDLE_TIME" ]; then
run_tests
# Sleep for sometime to avoid constantly triggering the tests.
sleep 60
fi
sleep 10 # Check for idle every 10 seconds.
done- It uses a loop to constantly check the idle time using
xprintidle. - If the idle time exceeds the specified threshold (
IDLE_TIME), it runs the test suite. - It logs the output and exit code of the test suite to a log file.
- It uses
espeak-ngto provide audio feedback. - All configuration is in the first 4 lines, change the paths there
- To stop, use ctrl + c (and improve this with better method)
Remember that it does NOT pause the tests as you asked. Since the sleep command makes it work correctly I dont see how a pause command should improve it, you may want to run all the test
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request