Advertisement
Guest User

Untitled

a guest
May 6th, 2011
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.01 KB | None | 0 0
  1. #/bin/bash
  2. # vim: si ts=4 sw=4
  3.  
  4. shopt -s extglob
  5.  
  6. IFS=$'\n' DEVICE_LIST=( $(xinput list --short) )
  7.  
  8. for (( I=0; I<${#DEVICE_LIST[@]}; I++ )); do
  9.     IFS=$'\t' INFO=( ${DEVICE_LIST[$I]} )
  10.     [ "${INFO[2]:1:1}" = "s" ] || continue
  11.     NAME="${INFO[0]:6}"
  12.     NAME="${NAME%%*([[:blank:]])}"
  13.     ID="${INFO[1]#id=}"
  14.     [[ "$NAME" != *XTEST* ]] || continue
  15.     case "${INFO[2]:8:1}" in
  16.     "p" )
  17.         POINTERS+=( "$ID"$'\t'"$NAME" )
  18.         ;;
  19.     "k" )
  20.         KEYBOARDS+=( "$ID"$'\t'"$NAME" )
  21.         ;;
  22.     esac
  23. done
  24.  
  25. POINTER="$( IFS=$'\t' zenity --title="Select device" --list --text="Choose a pointer" --column="Id" --column="Name" ${POINTERS[@]} )"
  26. KEYBOARD="$( IFS=$'\t' zenity --title="Select device" --list --text="Choose a keyboard" --column="Id" --column="Name" ${KEYBOARDS[@]} )"
  27.  
  28. [ -n "$POINTER" ] && [ -n "$KEYBOARD" ] || exit 1
  29.  
  30. MASTER_NAME="second"
  31. xinput create-master "$MASTER_NAME"
  32. xinput reattach "$POINTER" "$MASTER_NAME pointer"
  33. xinput reattach "$KEYBOARD" "$MASTER_NAME keyboard"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement