Skip to content

Add custom logcat parsing as a trigger #2121

@sudomain

Description

@sudomain

Have you checked if an issue already exists for this feature request?

  • Nobody else has requested this feature before

What feature would you like added?

Sorry if this is terse, I lost a long earlier draft of this:
Expert mode has access to adb shell, and thus builtin tools such as logcat and grep. There should be a special Key Mapper trigger type (similar to floating buttons) that can utilize these tools.

This would allow for responding to headset buttons such as KEYCODE_[PLAY/PAUSE/NEXT/PREVIOUS]. For example:

adb shell 'logcat -T "$(date +"%s.%N")" MediaSessionService:D' | adb shell grep 'callingPackage:com.android.bluetooth.*KEYCODE_MEDIA'| grep -vi com.termux

This runs in Termux, but could be converted to Key Mapper by removing the instances of adb shell and the extra quoting needed for the subshell. Some notes:

  1. logcat -T streams new events starting at a specific time.
  2. $(date +"%s.%N") gets the time that it is right now and outputs it in a format that logcat -T can use (though it's not the only format it can use)
  3. MediaSessionService:D is the log component that contains KEYCODE_MEDIA* events. D is the debug priority which I've found is the least verbose priority that still contains the events
  4. grep 'callingPackage:com.android.bluetooth.*KEYCODE_MEDIA allows us to filter KEYCODE_MEDIA events that originate from a bluetooth device, as opposed to software media buttons of media app, e.g. VLC. USB devices would probably need a different regex.
  5. grep -vi com.termux remove lines originating from Termux itself, which would get reported by logcat from previous executionof this command.

Using adb shell in a trigger would also probably solve another cool idea: #1696

App version

4.0.5 247

Device model and manufacturer

Galaxy S22

Extra info

  • My device is rooted

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions