[Nexus 4 Q&A, Help & Troubleshooting] Methroix:
This is probably a rather kernel/rom specific question, but since I'm a newly registered member I can't post in the specific thread.

Kernel: _motley b35

ROM: Xylon Nightly Feb08

The issue I'm having is that a color correction script gives a different result when placed inside init.d as opposed to running it as su in a terminal.

The script I'm using the one posted in the _motley thread, minus the last lines used only to display the already written values.

I've set the permissions to the same as the other scripts in the init.d folder.

Am I missing something?

The script:

#!/system/bin/sh

#Setting rgb
color_r=248
color_g=248
color_b=248
echo "$color_r $color_g $color_b" > /sys/devices/platform/kcal_ctrl.0/kcal
echo 1 > /sys/devices/platform/kcal_ctrl.0/kcal_ctrl

#Setting gamma
g_white=114 #Whitepoint, LG=0x72, GOOG=0x40,40,20 Low values=extreme whites, risk of blown out highlights
g_mids=21
g_black=118 #Blackpoint, LG=0x76, GOOG=0x76,76,74 Low values=cut out, banding in the shadows
g_unknown1=0
g_contrast=0 #Contrast, LG=0x00, GOOG=0x00,00,1F
g_brightness=0 #Brightness, LG=0x00, GOOG=0x00,00,10
g_saturation=80 #Saturation, LG=0x50, GOOG=0x30,30,50
g_greys=48
g_unknown2=2

#Tweak red gamma values here if needed
gr_white=`expr $g_white + 0`
gr_mids=`expr $g_mids + 0`
gr_black=`expr $g_black + 0`
gr_unknown1=`expr $g_unknown1 + 0`
gr_contrast=`expr $g_contrast + 10`
gr_brightness=`expr $g_brightness + 4`
gr_saturation=`expr $g_saturation + 0`
gr_greys=`expr $g_greys + 0`
gr_unknown2=`expr $g_unknown2 + 0`
gr_cksummotley=`expr $gr_white + $gr_mids + $gr_black + $gr_unknown1 + $gr_contrast + $gr_brightness + $gr_saturation + $gr_greys + $gr_unknown2`

#Tweak green gamma values here if needed
gg_white=`expr $g_white + 0`
gg_mids=`expr $g_mids + 0`
gg_black=`expr $g_black + 0`
gg_unknown1=`expr $g_unknown1 + 0`
gg_contrast=`expr $g_contrast + 7`
gg_brightness=`expr $g_brightness + 4`
gg_saturation=`expr $g_saturation + 0`
gg_greys=`expr $g_greys + 0`
gg_unknown2=`expr $g_unknown2 + 0`
gg_cksummotley=`expr $gg_white + $gg_mids + $gg_black + $gg_unknown1 + $gg_contrast + $gg_brightness + $gg_saturation + $gg_greys + $gg_unknown2`

#Tweak blue gamma values here if needed
gb_white=`expr $g_white + 0`
gb_mids=`expr $g_mids + 0`
gb_black=`expr $g_black + 0`
gb_unknown1=`expr $g_unknown1 + 0`
gb_contrast=`expr $g_contrast + 5`
gb_brightness=`expr $g_brightness + 1`
gb_saturation=`expr $g_saturation + 0`
gb_greys=`expr $g_greys + 0`
gb_unknown2=`expr $g_unknown2 + 0`
gb_cksummotley=`expr $gb_white + $gb_mids + $gb_black + $gb_unknown1 + $gb_contrast + $gb_brightness + $gb_saturation + $gb_greys + $gb_unknown2`

echo "$gr_cksummotley $gr_white $gr_mids $gr_black $gr_unknown1 $gr_contrast $gr_brightness $gr_saturation $gr_greys $gr_unknown2" > /sys/devices/platform/mipi_lgit.1537/kgamma_red
echo "$gg_cksummotley $gg_white $gg_mids $gg_black $gg_unknown1 $gg_contrast $gg_brightness $gg_saturation $gg_greys $gg_unknown2" > /sys/devices/platform/mipi_lgit.1537/kgamma_green
echo "$gb_cksummotley $gb_white $gb_mids $gb_black $gb_unknown1 $gb_contrast $gb_brightness $gb_saturation $gb_greys $gb_unknown2" > /sys/devices/platform/mipi_lgit.1537/kgamma_blue