home *** CD-ROM | disk | FTP | other *** search
/ PCNET 2006 September - Disc 1 / PCNET_CD_2006_09.iso / linux / puppy-barebones-2.01r2.iso / pup_201.sfs / usr / local / jwmconfig / changeKey < prev    next >
Encoding:
Text File  |  2006-05-06  |  3.2 KB  |  156 lines

  1. #!/bin/sh
  2.  
  3. ####
  4. #
  5. # changeKey: to be used with the 
  6. # jwmConfigMgr and keyboard scripts
  7. # provides gui for changing or deleting
  8. # a shortcut
  9. # author: thoughtjourney
  10. # date: 22/08/2005
  11. #
  12. # modified by kwiller on 07-May-2006
  13. # to allow use of multiple mask keys
  14. #
  15. #
  16. ####
  17.  
  18. #------------variables--------------->>
  19. TMP1="/tmp/addmask.tmp.$$"
  20. TMP2="/tmp/maskkey.tmp.$$"
  21. K=
  22. M=
  23. MASK=`echo $KEY | grep -c mask`
  24. A=
  25. TMPFILE="/tmp/shortcut"
  26. #SCRIPT_DIR="/root/.jwm"
  27. SCRIPT_DIR="/usr/local/jwmconfig"
  28. ID=
  29.  
  30. PATH1=$PATH
  31.  
  32. #-----find key value and mask value--->>
  33.  
  34. if [ $MASK -eq 1 ]; then
  35.    M=`echo $KEY | awk -F\" '/key/ {print $2}'`
  36.    K=`echo $KEY | awk -F\" '/key/ {print $4}'`
  37.    echo M: $M
  38.    echo K: $K 
  39. else
  40.    K=`echo $KEY | awk -F\" '/key/ {print $2}'`
  41.    echo K: $K  
  42. fi
  43. echo key $KEY
  44. export $KEY
  45.  
  46. ##------------write current key details to a file--------->>
  47.  
  48. echo "old|$M|$K">/tmp/short
  49. sync
  50.  
  51. #-------find line in config file------>>
  52.  
  53. if [ $MASK -eq 1 ]; then
  54.    RES=`echo $KEY | awk -F_ '/mask/ {print $1 " " $2}'`
  55. else
  56.    RES=$KEY
  57. fi
  58.  
  59. echo res $RES
  60.  
  61. KEYLINE=`grep "$RES" /root/.jwm/jwmrc-personal`
  62.  
  63. #xmessage -name "Current Details" -nearmouse "Current shortcut details:  $KEYLINE" &
  64.    echo $KEYLINE
  65.    A=`echo $KEYLINE | awk -F\> '/key/ {print $2}' | awk -F\< '/Key/ {print $1}'`
  66.    export A
  67.  
  68. ##------write to temp file------------>>
  69.  
  70. MASKKEY=
  71.  
  72. if [ -z $M  ]; then
  73.    echo -e "KEY:        $K\nACTION:  $A" > $TMPFILE
  74. else
  75.   echo "$M" > $TMP1
  76.   sed -e "s#A#Alt-#" \
  77.       -e "s#C#Ctrl-#" \
  78.       -e "s#H#Hyper-#" \
  79.       -e "s#M#Meta-#" \
  80.       -e "s#S#Shift-#" \
  81.       -e "s#P#Super-#" $TMP1 > $TMP2
  82.  
  83.   MASKKEY=`cat $TMP2`
  84.   rm -f $TMP1
  85.   rm -f $TMP2
  86.  
  87.   echo -e "KEY COMBO:  $MASKKEY$K\nACTION:           $A" > $TMPFILE
  88. fi
  89. #   echo A: $A >> /tmp/shortcut
  90.  
  91. ##---taskbar config for jwmConfigMgr--->>
  92.  
  93. export Change_Shortcut="
  94.  <vbox>
  95.   <frame Shortcut Details>
  96.    <hbox>
  97.     <edit><input file>$TMPFILE</input><width>300</width><height>45</height></edit> 
  98.    </hbox>
  99.   </frame>
  100.   <frame Delete>
  101.    <hbox>
  102.     <pixmap><input file>mini-cross.xpm</input></pixmap>
  103.     <checkbox>
  104.       <label>Delete this shortcut?</label>
  105.       <default>no</default>
  106.       <action>if true disable:MSK</action>
  107.       <action>if true disable:KY</action>
  108.       <action>if false enable:MSK</action>
  109.       <action>if false enable:KY</action>
  110.       <variable>CHECK</variable>
  111.     </checkbox>
  112.    </hbox>
  113.   </frame>
  114.   <frame Change Shortcut>
  115.    <hbox>
  116.     <text><label>Enter Mask (optional):</label></text>
  117.     <entry>
  118.      <default>mask</default>
  119.      <visible>enabled</visible>
  120.       <variable>MSK</variable>
  121.     </entry>
  122.     <text><label>Enter Key:</label></text>
  123.     <entry>
  124.      <default>key</default>
  125.      <visible>enabled</visible>
  126.       <variable>KY</variable>
  127.     </entry>
  128.    </hbox>
  129.   </frame>
  130.    <hbox>
  131.    <button>
  132.      <action>confirmKey &</action>
  133.      <action>exit</action>
  134.    </button>
  135.    <button help>
  136.       <action>dillo http://www.joewing.net/programs/jwm/config.shtml#keys &</action>
  137.    </button>
  138.    <button cancel></button>
  139.    </hbox>
  140.  </vbox>"
  141.  
  142. ##----------run------------>>
  143. cd $SCRIPT_DIR
  144. export PATH="$PATH:."
  145. gtkdialog --program Change_Shortcut
  146.  
  147. ##-------cleanup---------->>
  148. #rm -f $TMPFILE
  149. unset Change_Shortcut    
  150. unset A
  151. export PATH=$PATH1
  152. #clear    
  153.  
  154.  
  155.