costalat

list-rc-core.sh

Aug 31st, 2012
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.62 KB | None | 0 0
  1. #!/bin/bash
  2. #by_seahawk1986
  3.  
  4. if [[ $UID -ne 0 ]]; then
  5. echo "$0 must be run as root"
  6. echo " Please use: sudo $0"
  7. exit 1
  8. fi
  9.  
  10. for rc in $( ir-keytable 2>&1 | grep rc/rc | egrep -o -e 'rc[0-9]{1,}')
  11. do
  12. #echo $rc
  13. INFO=$( ir-keytable 2>&1 | grep "$rc" -A 3)
  14. echo "###*** sudo ir-keytable for $rc ***###"
  15. #echo -e $RC
  16. #echo $INFO
  17. ir-keytable 2>&1 | egrep $rc -A 3
  18. echo "##########################################"
  19. DRIVER=$( echo "$INFO" | grep "Driver" | sed -r 's/.*Driver\ (.*),.*/\1/')
  20. TABLE=$( echo "$INFO" | grep "table" | sed -r 's/.*table\ (.*)/\1/')
  21. TYPE=$( echo "$INFO" | grep "Enabled protocols" | sed s/Enabled\ protocols:\ //g;)
  22. KEYS=$(ir-keytable -r --sysdev $rc 2>&1 | grep "scancode" | sed 's/scancode\ //g;s/\ (.*//g;')
  23. if [ "$1" = "" ]
  24. then
  25. echo "*** keytable $TABLE for $DRIVER ***"
  26. echo ""
  27. echo -e "# table $TABLE, type:$TYPE"
  28. echo -e "$KEYS"
  29. echo
  30. echo "### End of Keytable for $TABLE ####"
  31. echo "*** suggested entry for custom keytable in /etc/rc_maps.cfg: ***"
  32. echo "$DRIVER $TABLE /etc/rc_keymaps/$TABLE"
  33. fi
  34.  
  35. if [ "$1" = "set" ]
  36. then
  37.  
  38. RC_KEYTABLE="/etc/rc_keymaps/$TABLE"
  39. TEMPLATE="/etc/yavdr/templates_custom/etc/rc_maps.cfg/90_$TABLE"
  40. if [ -d /etc/yavdr/templates_custom/etc/rc_maps.cfg ]
  41. then
  42. echo "custom template-directory already exists"
  43. else
  44. mkdir -p /etc/yavdr/templates_custom/etc/rc_maps.cfg
  45. fi
  46.  
  47. if [ -e /etc/yavdr/templates_custom/etc/rc_maps.cfg/90_$TABLE ]
  48. then
  49. read -p "Do you want to replace existing custom template $TEMPLATE?" yn
  50. case $yn in
  51. [Yy]* ) echo "$DRIVER $TABLE /etc/rc_keymaps/$TABLE" > $TEMPLATE && process-template /etc/rc_maps.cfg;;
  52. [Nn]* ) ;;
  53. * ) echo "Please answer yes or no.";;
  54. esac
  55. else
  56. echo "$DRIVER $TABLE /etc/rc_keymaps/$TABLE" > $TEMPLATE && process-template /etc/rc_maps.cfg
  57. fi
  58.  
  59. if [ -e /etc/yavdr/templates_custom/etc/rc_maps.cfg/90_$TABLE ]
  60. then
  61. read -p "Do you want to replace existing custom keytable $RC_KEYTABLE?" yn
  62. case $yn in
  63. [Yy]* ) echo -e "# table $TABLE, type:$(echo $TYPE | sed 's/\(.*\)_NUMERIC_\([0-9]\)/\1_\2/g')" > $RC_KEYTABLE && echo -e "$KEYS" >> $RC_KEYTABLE;;
  64. [Nn]* ) ;;
  65. * ) echo "Please answer yes or no.";;
  66. esac
  67. else
  68. echo -e "# table $TABLE, type:$(echo $TYPE | sed 's/\(.*\)_NUMERIC_\([0-9]\)/\1_\2/g')" > $RC_KEYTABLE && echo -e "$KEYS" >> $RC_KEYTABLE
  69. fi
  70. ir-keytable -a /etc/rc_maps.cfg --sysdev $rc
  71. fi
  72. done
Advertisement
Add Comment
Please, Sign In to add comment