sezanzeb / input-remapper

🎮 ⌨ An easy to use tool to change the behaviour of your input devices.
GNU General Public License v3.0
3.75k stars 155 forks source link

Get injection status via input-remapper-control #702

Open spacescientist opened 1 year ago

spacescientist commented 1 year ago

Hi, first of all many thanks for this great tool :)

I only need to load a preset for a specific application (for which I remap one of the side buttons of the mouse).

For that reason, I only start manually the injection of that preset before launching it. And when I'm back to browsing the web, etc, I need to stop the injection manually.

As I'd like to automatise this a little bit, I've made a simple toggle script, using a dummy file to toggle between on and off:

#!/bin/bash

togglefile=~/.config/input-remapper/.EU4inputmapper

if [[ -f $togglefile ]]
then
    # OK, that file exists -> turn off
    input-remapper-control --command stop --device "Razer Razer Mamba Elite" --preset "EU4"

    rm $togglefile
    echo "[input-mapper injection: OFF]"

else
    # Nope, that file does not exist ->  turn on
    input-remapper-control --command start --device "Razer Razer Mamba Elite" --preset "EU4"

    echo "See ~/scripts/toggle_input-remapper_EU4.sh." > $togglefile
    echo "[input-mapper injection: ON]"
fi

It'd be much more satisfactory to use some status from input-mapper, to check whether it's on or not, though. Indeed, as of now, I moreover have to make sure the file gets automatically deleted when I either log on or log off. It works, but it's not great.

Is there a way from the command line to check whether a preset was loaded? Any status that I could use for such a toggle script? And if not, could that become a thing? Here, I've used some bash, but I wouldn't mind doing that in Python.

Thanks a lot for your time.

Cheers!

sezanzeb commented 1 year ago

The Daemon class has a get_state function that could be used to check if an injection is running for a device, but input-remapper-control is not offering an option to use this.

I'll label this as feature request.