I have a script, written in python:
#!/usr/bin/python3
from tkinter import messagebox
variable = messagebox.showinfo('title', 'question')
This python script does nothing else than showing a message box on my screen. I want to start that script whenenver I connect an usb drive to my computer.
So I created a new file 10-myself.rules in the directory /etc/udev/rules.d/.
KERNEL="sdb",RUN+="/usr/bin/python3 /home/user/projects/path_to_python.py"
But I do not see any message box when put the usb drive into my computer. Where is the error? How can I debug that?
I also called the command
udevadm control --reload-rules
And I tried to change the rule to
KERNEL="sdb*",RUN+="/usr/bin/python3 /home/user/projects/path_to_python.py"
or to the rule
KERNEL="sdb1",RUN+="/usr/bin/python3 /home/user/projects/path_to_python.py"
If I change the script to
file1 = open("/home/user/udev.txt", "w")
file1.write("Hello")
file1.close()
then this script works.