I tried running Startup Applications as root using sudo gnome-session-properties
but my autoclicker script doesn't seem to run at all. I can however get it to run in the terminal using sudo python3 ./autoclicker.py
and everything works as intended.
The program won't run without root as the uinput kernel module is restricted to privileged users, would require messing with permissions, and probably would get messy quick. Here's the script if anyone wants to test it out. I use piper to set the macro ctrl+alt+1 on one of my mouse buttons and it works like a charm.
Auto Clicker Script
#!/usr/bin/python3
import time
import uinput
import keyboard
# Install these pip packages as root as you cannot run this program in user mode.
# sudo pip install keyboard && sudo pip install python-uinput
keys = [uinput.KEY_LEFTSHIFT,
uinput.KEY_SPACE,
uinput.BTN_LEFT,
uinput.BTN_MIDDLE,
uinput.BTN_RIGHT,
uinput.REL_X,
uinput.REL_Y,
uinput.REL_WHEEL,
uinput.REL_HWHEEL,
uinput.KEY_TAB,
uinput.KEY_ENTER]
device = uinput.Device(keys)
time.sleep(0.5)
print("Waiting for Ctrl + Alt + 1...")
while True:
# Wait until Ctrl + Alt + 1 is pressed
keyboard.wait('ctrl+alt+1')
print("Key combination detected, executing button clicks...")
device.emit(uinput.BTN_LEFT, 1)
device.emit(uinput.BTN_LEFT, 0)
time.sleep(0.1)
print("Returning to wait for Ctrl + Alt + 1...")