"Después del juego es antes del juego"
Sepp Herberger

jueves, 12 de septiembre de 2019

Toquemos el Touchpad de los TC11.

Nuestros Techcomputer TC11 son unos clónicos que van a darnos algunos quebraderos de cabeza hasta hacerlos funcionar completamente con Linux. Uno de estas puñetas es el touchpad, que se queda congelado de forma aleatoria obligando a reiniciar o cerrar sesión para hacerlo de nuevo utilizable.

Hemos probado con distintos kernels y configuraciones de /usr/share/X11/xorg.conf.d/70-synaptics.conf sin éxito. Es el típico problema que un día con una actualización se arreglará de forma inesperada y nadie sabrá que ha pasado, pero mientras tanto hay que dar una solución.

El touchpad se maneja con el módulo "i2c_hid". Si descargamos y cargamos dicho módulo cuando se queda pillado comprobamos que todo vuelve a funcionar. Entonces, en plan chapuza...¿podemos hacer un script que pueda ejecutar el usuario de forma sencilla para realizar tal tarea cuando se quede pillado? Sería una solución rápida y sucia pero al final nos sacaría del apuro. La respuesta a esta cuestión es "SÍ".

El script sería:
# cat /usr/local/bin/reinicio_touchpad 
#!/bin/bash
rmmod i2c_hid
modprobe i2c_hid
exit 0
Este script no puede usarse por un usuario regular, ya que para ejecutar rmmod/modprobe necesitas ser administrador. La solución es utilizar sudoers, añadiendo en /etc/sudoers la línea:
ALL   ALL = (ALL) NOPASSWD: /usr/local/bin/reinicio_touchpad
Para que el usuario no tenga que abrir un terminal y lanzar el script usamos un atajo de teclado de XFCE4, asociando la tecla F12 a dicha acción:
# cat /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml
<?xml version="1.0" encoding="UTF-8"?>

<channel name="xfce4-keyboard-shortcuts" version="1.0">
  <property name="commands" type="empty">
    <property name="default" type="empty">
      <property name="&lt;Alt&gt;F1" type="string" value="xfce4-popup-applicationsmenu"/>
      <property name="&lt;Alt&gt;F2" type="string" value="xfce4-appfinder --collapsed">
        <property name="startup-notify" type="bool" value="true"/>
      </property>
      <property name="&lt;Alt&gt;F3" type="string" value="xfce4-appfinder">
        <property name="startup-notify" type="bool" value="true"/>
      </property>
      <property name="&lt;Primary&gt;&lt;Alt&gt;Delete" type="string" value="xflock4"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;l" type="string" value="xflock4"/>
      <property name="XF86Display" type="string" value="xfce4-display-settings --minimal"/>
      <property name="&lt;Super&gt;p" type="string" value="xfce4-display-settings --minimal"/>
      <property name="&lt;Primary&gt;Escape" type="string" value="xfdesktop --menu"/>
      <property name="XF86WWW" type="string" value="exo-open --launch WebBrowser"/>
      <property name="XF86Mail" type="string" value="exo-open --launch MailReader"/>
    </property>
    <property name="custom" type="empty">
      <property name="override" type="bool" value="true"/>
      <property name="&lt;Primary&gt;F12" type="string" value="/usr/local/bin/brillo"/>
      <property name="F12" type="string" value="gksu /usr/local/bin/reinicio_touchpad"/>
    </property>
  </property>

  <property name="xfwm4" type="empty">
    <property name="default" type="empty">
      <property name="&lt;Alt&gt;Insert" type="string" value="add_workspace_key"/>
      <property name="Escape" type="string" value="cancel_key"/>
      <property name="Left" type="string" value="left_key"/>
      <property name="Right" type="string" value="right_key"/>
      <property name="Up" type="string" value="up_key"/>
      <property name="Down" type="string" value="down_key"/>
      <property name="&lt;Alt&gt;Tab" type="string" value="cycle_windows_key"/>
      <property name="&lt;Alt&gt;&lt;Shift&gt;Tab" type="string" value="cycle_reverse_windows_key"/>
      <property name="&lt;Alt&gt;Delete" type="string" value="del_workspace_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;Down" type="string" value="down_workspace_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;Left" type="string" value="left_workspace_key"/>
      <property name="&lt;Shift&gt;&lt;Alt&gt;Page_Down" type="string" value="lower_window_key"/>
      <property name="&lt;Alt&gt;F4" type="string" value="close_window_key"/>
      <property name="&lt;Alt&gt;F6" type="string" value="stick_window_key"/>
      <property name="&lt;Alt&gt;F7" type="string" value="move_window_key"/>
      <property name="&lt;Alt&gt;F8" type="string" value="resize_window_key"/>
      <property name="&lt;Alt&gt;F9" type="string" value="hide_window_key"/>
      <property name="&lt;Alt&gt;F10" type="string" value="maximize_window_key"/>
      <property name="&lt;Alt&gt;F11" type="string" value="fullscreen_key"/>
      <property name="&lt;Alt&gt;F12" type="string" value="above_key"/>
      <property name="&lt;Primary&gt;&lt;Shift&gt;&lt;Alt&gt;Left" type="string" value="move_window_left_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;End" type="string" value="move_window_next_workspace_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;Home" type="string" value="move_window_prev_workspace_key"/>
      <property name="&lt;Primary&gt;&lt;Shift&gt;&lt;Alt&gt;Right" type="string" value="move_window_right_key"/>
      <property name="&lt;Primary&gt;&lt;Shift&gt;&lt;Alt&gt;Up" type="string" value="move_window_up_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_1" type="string" value="move_window_workspace_1_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_2" type="string" value="move_window_workspace_2_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_3" type="string" value="move_window_workspace_3_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_4" type="string" value="move_window_workspace_4_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_5" type="string" value="move_window_workspace_5_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_6" type="string" value="move_window_workspace_6_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_7" type="string" value="move_window_workspace_7_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_8" type="string" value="move_window_workspace_8_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;KP_9" type="string" value="move_window_workspace_9_key"/>
      <property name="&lt;Alt&gt;space" type="string" value="popup_menu_key"/>
      <property name="&lt;Shift&gt;&lt;Alt&gt;Page_Up" type="string" value="raise_window_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;Right" type="string" value="right_workspace_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;d" type="string" value="show_desktop_key"/>
      <property name="&lt;Primary&gt;&lt;Alt&gt;Up" type="string" value="up_workspace_key"/>
      <property name="&lt;Super&gt;Tab" type="string" value="switch_window_key"/>
      <property name="&lt;Primary&gt;F1" type="string" value="workspace_1_key"/>
      <property name="&lt;Primary&gt;F2" type="string" value="workspace_2_key"/>
      <property name="&lt;Primary&gt;F3" type="string" value="workspace_3_key"/>
      <property name="&lt;Primary&gt;F4" type="string" value="workspace_4_key"/>
      <property name="&lt;Primary&gt;F5" type="string" value="workspace_5_key"/>
      <property name="&lt;Primary&gt;F6" type="string" value="workspace_6_key"/>
      <property name="&lt;Primary&gt;F7" type="string" value="workspace_7_key"/>
      <property name="&lt;Primary&gt;F8" type="string" value="workspace_8_key"/>
      <property name="&lt;Primary&gt;F9" type="string" value="workspace_9_key"/>
      <property name="&lt;Primary&gt;F10" type="string" value="workspace_10_key"/>
      <property name="&lt;Primary&gt;F11" type="string" value="workspace_11_key"/>
      <property name="&lt;Primary&gt;F12" type="string" value="workspace_12_key"/>
    </property>
  </property>
</channel>
De esta manera, a nivel de sistema (ya que lo definimos /etc/xdg/xfce4/xfconf/xfce-perchannel-xml/ en lugar del home del usuario) asociamos la ejecución de "gksu /usr/local/bin/reinicio_touchpad" a la tecla F12.

Si nos fijamos hay un bonus track: con CTRL-F12 ejecutamos el script "brillo". Este script pone a 100% el brillo de la pantalla del portátil. Esto es debido a que hemos observado a que a veces (algo relacionado con la suspensión o algún enredo similar) baja mucho y no es trivial subirlo de nuevo.
# cat /usr/local/bin/brillo
#!/bin/bash
xrandr --output eDP1 --brightness 1.0
exit 0
Como no vamos a hacer todo esto a mano portátil a portátil, ponemos finalmente las reglas puppet que meten todos estos ficheros y configuraciones anteriores en su sitio:
#No tiene control de brillo con Fn, script que pone el brillo al 100% de nuevo
file {"/usr/local/bin/brillo":
  owner => root , group => root , mode => 755 ,
  source => "puppet:///modules/xubuntu18_portatil_ajustes/brillo",
}
#Script que reinicia el touchpad quitando y poniendo el módulo
file {"/usr/local/bin/reinicio_touchpad":
  owner => root , group => root , mode => 755 ,
  source => "puppet:///modules/xubuntu18_portatil_ajustes/reinicio_touchpad",
}
line { sudoers:
 file => "/etc/sudoers",
 line => "ALL   ALL = (ALL) NOPASSWD: /usr/local/bin/reinicio_touchpad",
 ensure => present
}
# Atajos de teclado: CTRL-F12 ejecuta "brillo", F12 ejecuta "gksu renicio_touchpad"
file {"/etc/xdg/xfce4/xfconf/xfce-perchannel-xml/xfce4-keyboard-shortcuts.xml" :
 owner => root , group => root , mode => 644 ,
 source => "puppet:///modules/xubuntu18_portatil_ajustes/xfce4-keyboard-shortcuts.xml"
}
Cambia "xubuntu18_portatil_ajustes" por la tarea puppet que uses en tu caso para configurar los portátiles.

La nave india Chandrayaan 2 finalmente aterrizó en la Luna, aunque durante un tiempo nos hicieron creer que se había pegado un castañazo como hizo la sonda israelí.

El reto ahora es saber por qué se cortó la comunicación en el último momento y determinar el estado operativo de la sonda. Esto convierte a la India en el 4 país en aterrizar sobre nuestro satélite, en su caso con misiones muy baratas y optimizadas: mandar la sonda con un rover ha costado 130 millones de euros, más o menos unos 20 km de autovía en España.


Y otra imagen maravillosa:



Algún día de este siglo, un descendiente de esta máquina aterrizará en Marte con humanos dentro.

No hay comentarios:

Publicar un comentario