How to set Bixby button to turn on flashlight on Galaxy phones

So we have that somewhat useless Bixby button on Galaxy phones. Now I am not against Bixby, quite the opposite. But I prefer to summon her via voice and use the button for something I commonly need to happen fast - turn on the flashlight.

The reason for writing this tutorial is that it was not very obvious, how to make the button turn the flashlight on from the lockscreen as well.

Instructions

  1. Download bxactions app: https://play.google.com/store/apps/details?id=com.jamworks.bxactions&hl=en&gl=US
  2. After downloading it, enable developer mode on your phone and connect it to PC
  3. Open terminal, type adb devices and check if your device is connected/confirm the connection on the phone
  4. Grant the app the following permissions (it won’t work on lock screen without them):

    # adb shell pm grant com.jamworks.bxactions android.permission.READ_LOGS
    # adb shell pm grant com.jamworks.bxactions android.permission.WRITE_SECURE_SETTINGS
    
    1. Force close bxactions or restart the phone
    2. Open bxactions and go through its usual setup process
    3. Set the Bixby button action to flashlight