return JSON string stop working

My script worked fine until I updated to 3.332 (1526) but now it get displayed like this:

My script:

do shell script "pmset -g batt | grep InternalBattery | column -t"

set x to the result

set percentage to word 6 of x

set state to word 7 of x

set remaininghours to the word 8 of x

set remainingmins to the word 9 of x

if percentage is less than 20 and percentage is not "100" then

return "{\"text\":\"" & percentage & "%" & "\",\"background_color\":\"255,124,124,100\",\"font_color\": \"255,255,255,255\",\"font_size\": 16}"

else if state is "charging" or state is "charged" then

return "{\"text\":\"" & "⬆" & percentage & "%" & "\",\"background_color\":\"0,0,0,0\", \"font_color\": \"23,253,11,255\",\"font_size\": 16}"

else

return "{\"text\":\"" & percentage & "%" & "\",\"background_color\":\"0,0,0,0\", \"font_color\": \"255,255,255,255\",\"font_size\": 16}"

end if

-- return "{\"text\":\"" & percentage & "%" & "\",\"background_color\":\"0,0,0,0\",\"icon_data\": \"iVBORw0KGgoAAAANSUhEUgAAAPcAAAEGCAYAAAC5NQNbAAAABHNCSVQICAgIfAhkiAAAAF96VFh0UmF3IHByb2ZpbGUgdHlwZSBBUFAxAAAImeNKT81LLcpMVigoyk/LzEnlUgADYxMuE0sTS6NEAwMDCwMIMDQwMDYEkkZAtjlUKNEABZiYm6UBoblZspkpiM8FAE+6FWgbLdiMAAAPkElEQVR4nO3dfXRU5Z3A8XvnZoYMhMQMzCYhgJsF5TQtCvUYypYWilJx6abrFvAIB9AVca0sVKSVw8q6rBypaJEVwZJiI7iAK8JWcEFeckiIB4ulIHhITwDNbgIENnTI5IW8TGae/YOiWF5mJvPy3OeZ7+cc/iBM7v2dw/mee+fOnecaBlLCjkkZoyceGnBgUYl3sexZAMTBkVGuwskH88u/V1cgrvwh8NRgyR4AiSEMwxUo9S5+Y36f9Zcy0wZd/W+1t7lGT/ua07F/+6VySeMhCYhbQ9V3GAUzPxi469Q30h80TPO6/8cErj/i1szWGT3HP//Lfrsu9bYGhXstgeuNuDWyfKln9n/M9awPWo5ekf4OgeuLuDUghLCavr7m1f0TMv7VME1HtL9P4Hoibs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aIq4AU0RN6Ap4gY0RdyApogb0BRxA5oibiiD9eyiQ9yApogb0BRxA5oibkBTxA1oirgBTRE3oCniBjRF3ICmiBvQFHEDmiJuQFPEDWiKuAFNETegKeIGNEXcgKaIG9AUcQOaIm5AU8QNaIq4w+CZ0FAVcQOaIu4wWCsbqiJuQFPEDWiKuAFNETegKeIGNEXcgKaIG8rghqLoEDegKeIGNEXcgKaIG9AUcUMpPuHjolqEiBvQFHEDmiJuQFPEDWiKuKEUy2i1ZM+gCuKGUi4YTRmyZ1AFcQOaIm4opcvo4rQ8QsQNpTQHGjktjxBxQyltgXaX7BlUQdxQSruj1S17BlUQN5TSHPJzWh4h4oZSmrv8fHEkQsQNpZwP1efKnkEVxA2lNAcbPbJnUAVxQynnu84WyJ5BFcQNJaS3hmoeXuab1MfynpE9iypM2QPY3b2f39rIkrpyONtDDXm1XR+O/U3Lxukr/f9lGkbwSMfBwuE9RlTJnk0FxB3G9+oKhOwZdNPbH6xyBIy2K3/P9AfPZF4MnXMGROeg4x2f9qvrOnPnb5s/HVRl1MqcU3XEnULe+mjt4GZXa9zOQv6qM69m/MjJvnhtD/H1//iQFUOEVXYXAAAAAElFTkSuQmCC\", \"font_color\": \"255,255,255,255\",\"font_size\": 16}"

-- Cuando queda menos de 10, no entra en ningun if-else

return "{\"text\":\"" & percentage & "%" & "\",\"background_color\":\"255,124,124,100\",\"font_color\": \"255,255,255,255\",\"font_size\": 16}"

Should wok again in build 1527!

1 Like

I am version 3.346 and I dont seem to get this working.
I return:

return "{\"text\":\"off\" , \"background_color\": \"255,0,0,255\"}"

But nothing changes

Imprint | Privacy Policy