#!/bin/bash # getdclick: simulate double-clic and get selected word # Time to wait between clicks (test what works for you) DCLICK_WAIT=0.1 # Before double-click, simulate a Release of all buttons xte "mouseup 1" "mouseup 2" "mouseup 3" "mouseup 4" "mouseup 5" # Now simulate double click xte "mouseclick 1" "sleep $DCLICK_WAIT" "mouseclick 1" # Get selection first word from primary X clipbloard SELECTION=$(xsel -p | awk '{print $1}') echo $SELECTION exit 0