MrBeaker escribió:
Que es lo que quieres ejecutar exactamente?
El script lo puedes modificar y poner como accion cualquier linea de codigo que tu quieras, por lo que en vez de que apague puedes hacer que reinicie, te muestre configuracion de red, etc etc etc... Lo que le das es funcionalidad al botón, en este caso de apagado por la linea shutdown -h, pero sustituyendo esa linea le indicas que quieres hacer otra cosa.
Te explico.
Este es el script que he construido y que ya funciona:
Código: Seleccionar todo
#!/usr/bin/python
# led control cpu temp
import time
import commands
#Temperature Read
def get_cpu_temp():
tempFile = open( "/sys/class/thermal/thermal_zone0/temp" )
cpu_temp = tempFile.read()
tempFile.close()
return float(cpu_temp)/1000
#what's the temp?
try:
while True:
#Blue Color, When we have: 30*<=>34*
if get_cpu_temp() >= 30 and get_cpu_temp() <= 34:
import os
os.system("neouart -q -s16 3c000000 3c000040")
#Light Blue Color, When we have: 35*<=>40*
elif get_cpu_temp() >= 35 and get_cpu_temp() <= 40:
import os
os.system("neouart -q -s16 3c000000 3c002040")
#Light Green Color, When we have: 41*<=>44*
elif get_cpu_temp() >= 41 and get_cpu_temp() <= 44:
import os
os.system("neouart -q -s16 3c000000 3c004020")
#Green Color, When we have: 45*<=>55*
elif get_cpu_temp() >= 45 and get_cpu_temp() <= 55:
import os
os.system("neouart -q -s16 3c000000 3c004000")
#Yello Color, When we have: 56*<=>65*
elif get_cpu_temp() >= 56 and get_cpu_temp() <= 65:
import os
os.system("neouart -q -s16 3c000000 3c404000")
#Orange Color, When we have: 66*<=>70*
elif get_cpu_temp() >= 66 and get_cpu_temp() <= 70:
import os
os.system("neouart -q -s16 3c000000 3c402000")
#Violet Color, When we have: 71*<=>75*
elif get_cpu_temp() >= 71 and get_cpu_temp() <= 75:
import os
os.system("neouart -q -s16 3c000000 3c400040")
#Bright Red Color, When we have: 76*<=>90*
elif get_cpu_temp() >= 76 and get_cpu_temp() <= 90:
import os
os.system("neouart -q <sos.nua")
#check every 3 secons (change to crontab)
time.sleep(3)
except KeyboardInterrupt:
import os
os.system('neouart -q -s16 ff050000')
print("Exit")
Me gustaría añadir una linea, que cuando se haga la llamada a shutdown o reboot. Ya sea con el pulsador o por consola se ejecute la orden: " neouart -q -s16 3c050000 000000 3c050000"
¿Es posible hacer eso? Mis conocimientos en programación son nulos.
Muchas gracias.