first commit
This commit is contained in:
23
one.py
Executable file
23
one.py
Executable file
@@ -0,0 +1,23 @@
|
||||
import evdev
|
||||
from evdev import InputDevice, categorize, ecodes
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
# Use relative path
|
||||
# venv_python = os.path.abspath('./myenv/bin/python')
|
||||
|
||||
# Use full absolute path to the Python inside your virtual environment
|
||||
venv_python = os.path.abspath('/home/dhruv/Desktop/python_power_button__based__rustdesk_toggler/myenv/bin/python')
|
||||
|
||||
# Power button device
|
||||
device = InputDevice('/dev/input/event2') # Change if needed
|
||||
|
||||
for event in device.read_loop():
|
||||
if event.type == ecodes.EV_KEY and event.code == ecodes.KEY_POWER:
|
||||
if event.value == 1: # 1 = key down
|
||||
print("Power button pressed!")
|
||||
|
||||
# Call 2.py using the correct Python interpreter
|
||||
subprocess.run([venv_python, "/home/dhruv/Desktop/python_power_button__based__rustdesk_toggler/two.py"])
|
||||
|
||||
# break
|
||||
Reference in New Issue
Block a user