astrand / xclip

Command line interface to the X11 clipboard
GNU General Public License v2.0
1.04k stars 75 forks source link

timeout with -o would be nice #48

Open hildred opened 6 years ago

hildred commented 6 years ago

so I have script that begins with something very much like

#!/bin/bash
echo debug 1
var="$(xclip -o)"
echo debug 2
echo "$var"
#do something with var.

now 95% of the time it works just fine exiting in less than a second and actually doing something useful, but sometimes it hangs during xclip (hours or days If i do not notice and kill it sooner). Now I do not think the problem is with xclip ( I think it is probably a problem with the X server or window manager but so far I have not been able to track it down), but It would be nice if I could set a timeout for reading the clipboard so I could add error handling to the script.

tangxinfa commented 5 years ago

You can use "timeout" command to run xclip:

   timeout 0.1 xclip -o