Preamble
It was possible in previous note models and tablets to disable the Air command.
On Marshmallow (version 6) there's no such toggle.
To turn off the Air command feature of the Samsung Galaxy Note 4 (at release):
Go to Settings > Controls.
Tap on S Pen.
Tap on Air Command.
Disable Air Command.
The Air command (packagecom.samsung.android.service.aircommand
) is implemented via a system service.
Code
Notionally You cannot programmatically remove/disable this Air service (permissions) and as a system service
it seems to have first dibs on the hardware events (you get them later/also and it's too late to stop Air if it is active).
That being said Greenify does it so I sought out other options and found Brevent. This is totally free source code it the GitHub (AS 3), I'm playing with it right now (be aware it contains C code so NDK required if you want to build it, or see ->). Brevent Play Store
air command is grayed out in Galaxy Note 5
For the users here this graying out is a problem, for you it might be a solution.
Here are some choice comments:
Some owners reported that air command in Galaxy Note 5 was grayed out.
The cause of grayed out Galaxy Note 5 air command is usually due to
some accessibility settings (Go to Accessibility and switch on Voice Assistant ?). Actually, when you enabled such accessibility settings, there were the warning message on air command. But most of time, nobody reads it.
I have a galaxy note 5 and everything was fine until the device
suggest me to update its android software from 5.1.1 to 6.0.1
I have Note 5 and the Air command stopped working after I installed
Norton Antivirus.
Greenify
For your own personal use you can use the 'free' app:
(Android version 6+, even without root!) Greenify to disable the Air Command Service
(to disable system apps/services you need to make a small "donation" and the function is described as "experimental").