Skip to content

Instantly share code, notes, and snippets.

@fletch
Last active Aug 29, 2015
Embed
What would you like to do?
shell function sending messages to sauron using dbus
# -*- sh -*-
sauron () {
local opt_f=zsh opt_S=3 action=AddMsgEvent
local myname=${(%):-%N}
local -a extra_args
while getopts "S:f:u:" opt; do
if [[ $opt = "?" ]]; then
print -r -- "$myname: unrecognized option: -$OPTARG" >&2
return 1
fi
eval "opt_$opt=\${OPTARG:--\$opt}"
done
(( OPTIND > 1 )) && shift $(( OPTIND - 1 ))
if [[ -n $opt_u ]] ; then
action=AddUrlEvent
extra_args=( "string:$opt_u" )
fi
dbus-send --session --dest="org.gnu.Emacs" \
--type=method_call "/org/gnu/Emacs/Sauron" \
"org.gnu.Emacs.Sauron.${action}" \
string:"$opt_f" uint32:${opt_S} string:"$*" "${extra_args[@]}"
}
sauron "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment