Quantcast
Viewing all articles
Browse latest Browse all 3790

Troubleshooting • Re: Need help with triggerhappy

Hello,

The only IR key that works by only mapping scan codes to key code is KEY_POWER.
It does not need anything else. The volume and mute keys need some support like this from the OS.

I put together a script that works great when run manually but cannot get it to work on reboot.
In the log file I get an error to the tune amixer cannot connect to pipewire and host is down kind of errors.
Any thoughts?

the script is as below:

Code:

import evdevimport subprocess# Define the input event device pathINPUT_EVENT_PATH = '/dev/input/event0'def increase_volume():    change_volume('+')def decrease_volume():    change_volume('-')def change_volume(ch_sign):    subprocess.Popen(['amixer', '-D', 'pipewire', 'sset', 'Master', '5%{}'.format(ch_sign)])def mute_volume():    subprocess.Popen(['amixer', '-D', 'pipewire', 'sset', 'Master', 'toggle'])def handle_key_event(event):    if event.code in IR_KEY_MAP:        if event.code == evdev.ecodes.KEY_VOLUMEUP or event.code == evdev.ecodes.KEY_VOLUMEDOWN:            if event.value == 1 or event.value == 2:  # Key press or hold                IR_KEY_MAP[event.code]()        elif event.code == evdev.ecodes.KEY_MUTE:            if event.value == 1:  # Only key press                IR_KEY_MAP[event.code]()# Mapping of IR input events to corresponding functionsIR_KEY_MAP = {    evdev.ecodes.KEY_VOLUMEUP: increase_volume,    evdev.ecodes.KEY_VOLUMEDOWN: decrease_volume,    evdev.ecodes.KEY_MUTE: mute_volume,}def main():    # Open the input event device    device = evdev.InputDevice(INPUT_EVENT_PATH)    print(f"Listening for IR inputs on {device.name}...")    # Process events indefinitely    for event in device.read_loop():        if event.type == evdev.ecodes.EV_KEY and event.code in IR_KEY_MAP:            handle_key_event(event)if __name__ == "__main__":    main()
The sudo crontab -e line reads:
@reboot /usr/bin/python3 /opt/scripts/vctl.py >> /opt/scripts/vctl.log 2>&1

Statistics: Posted by karagir — Mon Jul 08, 2024 1:13 pm



Viewing all articles
Browse latest Browse all 3790

Trending Articles