EA for disabled infrared?

corbinmharris
Contributor

My boss wants the infrared receiver disabled on all our Macs that support this feature.

Does anyone have an example of an extension attribute so I can scope the Macs to verify the that all of them get the infrared disabled.

Thanks!

Corbin

1 ACCEPTED SOLUTION

denmoff
Contributor III

This seems to do the trick for me.

#!/bin/bash

ir_check=$(/usr/bin/defaults read /Library/Preferences/com.apple.driver.AppleIRController|/usr/bin/grep DeviceEnabled|/usr/bin/awk '{print $3}')
if [[ "$ir_check" == "0;" ]]; then
    echo "<result>Disabled</result>"
else
        echo "<result>Enabled</result>"
fi

View solution in original post

10 REPLIES 10

denmoff
Contributor III

This seems to do the trick for me.

#!/bin/bash

ir_check=$(/usr/bin/defaults read /Library/Preferences/com.apple.driver.AppleIRController|/usr/bin/grep DeviceEnabled|/usr/bin/awk '{print $3}')
if [[ "$ir_check" == "0;" ]]; then
    echo "<result>Disabled</result>"
else
        echo "<result>Enabled</result>"
fi

corbinmharris
Contributor

Thanks! I will give it a try.

Corbin

corbinmharris
Contributor

Thanks! I will give it a try.

Corbin

corbinmharris
Contributor

Thanks! I will give it a try.

Corbin

jacob_salmela
Contributor II

If the IR kext is completely removed, something like this might work:

#!/bin/bash
irStatus=$(kextstat -b com.apple.driver.AppleIRController | awk NR==2)
if [ -z "$irStatus" ];then
    echo "<result>Disabled</result>"
else
    echo "<result>Enabled</result>"
fi

corbinmharris
Contributor

Jacob,

Thanks for the script, however we are just going to disable.

Corbin

denmoff
Contributor III

@jacob_salmela That would return "Enabled" if the setting was set and then later disabled, wouldn't it?

denmoff
Contributor III

@corbin3ci Now that i think about it, depending on how you plan to disable this preference, the EA script that i wrote might return incorrect info. If you set it with MCX, the preference in /Library/Preferences/ won't change. In other words, it will return as "Enabled" even tho you've disabled it using MCX or Profile Manger.

corbinmharris
Contributor

Not using MCX or Profile manager. The script you provided works great!

Screenshot: http://note.io/1jxHKpL

Thanks!

jacob_salmela
Contributor II

@denmoff Prior to running my script, I completely removed the IR extension:

srm -r /System/Library/Extensions/AppleIRController.kext
touch /System/Library/Extensions/

As far as I can tell, it returns the right values, but I did not do a lot of testing with it.