This step-by-step guide documents the setup of a Python daemon that automatically resets zoom (Ctrl+0) on a DakBoard kiosk touchscreen after a configurable delay when the user lifts their finger. It uses the GUI autostart method for reliable operation at boot and provides detailed instructions for environment setup, Python daemon creation, zoom reset scripting, autostart configuration, and verification.
! This guide assumes the user is relatively familiar with SSH, linux, and a CLI. If not, start here
No support is offered or provided beyond this guide. Use a friend or chatgpt to troubleshoot the minutia.
- Update your package lists:
sudo apt update- Install
xdotool, which allows simulating key presses in the Chromium browser:
sudo apt install xdotool- Verify the touchscreen device is detected using
libinput-debug-events:
/usr/libexec/libinput/libinput-debug-eventsYou should see lines indicating your touchscreen devices (e.g., event5, event6). Take note of the device you will use (e.g., /dev/input/event5).
This script will perform the actual zoom reset in Chromium.
- Create the script file:
sudo nano /usr/local/bin/reset-zoom.sh- Paste the following content:
#!/bin/bash
xdotool search --onlyvisible --class chromium key --clearmodifiers ctrl+0- Make the script executable:
sudo chmod +x /usr/local/bin/reset-zoom.sh- Test the script manually to make sure it resets zoom in Chromium:
/bin/bash /usr/local/bin/reset-zoom.shThis Python script monitors touch events and triggers the zoom reset after a specified delay.
- Create the daemon script:
sudo nano /usr/local/bin/touch-reset-daemon.py- Paste the following content:
#!/usr/bin/env python3
import subprocess
import time
import argparse
import re
import sys
parser = argparse.ArgumentParser(description="Touch-release Zoom Reset Daemon")
parser.add_argument('--device', required=True, help='Touch device (e.g., /dev/input/event5)')
parser.add_argument('--reset-cmd', required=True, help='Command/script to reset zoom')
parser.add_argument('--delay', type=int, default=5, help='Seconds to wait after touch release')
parser.add_argument('--debounce', type=int, default=1, help='Minimum seconds between resets')
parser.add_argument('--debug', action='store_true', help='Enable debug output')
args = parser.parse_args()
last_reset = 0
def main():
cmd = ["/usr/libexec/libinput/libinput-debug-events", "--device", args.device]
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
for raw in proc.stdout:
line = raw.rstrip()
if args.debug:
print(line, file=sys.stderr)
# Detect touch release events
if re.search(r'TOUCH_UP', line) or re.search(r'POINTER_TOUCH\s+0\b', line):
now = time.time()
if now - last_reset >= args.debounce:
last_reset = now
if args.debug:
print(f"Touch release detected — waiting {args.delay}s to reset zoom", file=sys.stderr)
subprocess.Popen(["/bin/bash", "-c", f"sleep {args.delay}; {args.reset_cmd}"])
if __name__ == "__main__":
main()- Make the Python script executable:
sudo chmod +x /usr/local/bin/touch-reset-daemon.py- Test the daemon manually (replace
/dev/input/event5with your touchscreen device):
sudo /usr/bin/python3 /usr/local/bin/touch-reset-daemon.py --device /dev/input/event5 --reset-cmd /usr/local/bin/reset-zoom.sh --debugWatch for Touch release detected messages when you lift your finger from the touchscreen.
This ensures the daemon starts automatically after the graphical session is ready, which is required for xdotool to work with Chromium.
- Create the autostart directory (if it does not exist):
mkdir -p /home/dakboard/.config/autostart- Create the
.desktopautostart file:
nano /home/dakboard/.config/autostart/touch-reset.desktop- Paste the following content:
[Desktop Entry]
Type=Application
Exec=/usr/bin/python3 /usr/local/bin/touch-reset-daemon.py --device /dev/input/event5 --reset-cmd /usr/local/bin/reset-zoom.sh --delay 5
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=Touch Reset Daemon
Comment=Reset zoom after touch release- Save and exit the editor.
- Reboot the system:
sudo reboot- After the GUI loads, verify that the daemon is running:
ps aux | grep touch-reset-daemon.py- Test the touchscreen:
- Touch and hold on the screen.
- Lift your finger.
- After approximately 5 seconds, the zoom in Chromium should reset to 100%.
- Touchscreen detection: Confirmed working with
/usr/libexec/libinput/libinput-debug-events. - Python daemon: Detects touch release and triggers a delayed zoom reset.
- xdotool: Successfully interacts with Chromium in DakBoard kiosk session.
- GUI autostart: Ensures daemon runs automatically at boot, after GUI is ready.
- Delay and debounce: Configurable to control how long zoom remains after touch release and prevent rapid multiple resets.
This setup is fully compatible with DakBoard kiosk mode and Chromium-based dashboards.