Skip to content

Instantly share code, notes, and snippets.

@drobune
Last active March 29, 2016 23:24
Show Gist options
  • Save drobune/68fe60c5da2b3766b4f0 to your computer and use it in GitHub Desktop.
Save drobune/68fe60c5da2b3766b4f0 to your computer and use it in GitHub Desktop.
#!/bin/bash -xe
base=`basename $0 | sed -e 's/\.sh$//g'`
cmd=`echo $base | awk -F '_' '{print $1}'`
keystroke=`echo $base | sed -e 's/^[^_]\+_//g'`
id=`xdotool getwindowfocus`
# Avoid chikachika-terminal
#app_name=`xprop -id ${id} | grep M_CLASS | cut -f3 -d ' ' | tr '[:upper:]' '[:lower:]' | tr -d ',','"',' ',"\'"`
#if [ "$app_name" == "terminator" ]; then
# exit 0
#fi
case $cmd in
key)
xdotool key --window $id "$keystroke" > /dev/null 2>&1
;;
type)
echo -n "$keystroke" | xclip -i -selection clipboard
xdotool key --window $id "ctrl+v" > /dev/null 2>&1
;;
*)
echo "usage: ln -s $0 {key|type}_<keystroke>.sh"
exit 1;;
esac
@drobune
Copy link
Author

drobune commented Mar 29, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment