emacs-eval 912 B

1234567891011121314151617181920212223
  1. #!/bin/sh
  2. #### HELP MESSAGE ##############################################
  3. hlp='Usage: emacs-eval arg
  4. Evaluate ARG as an Emacs Lisp expression (using "emacsclient --eval").
  5. Activate Emacs if it is not activated.'
  6. if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
  7. echo "$hlp"
  8. exit 0
  9. fi
  10. ################################################################
  11. emacsclient --eval "$1" &
  12. wmctrl -ia $(emacsclient --eval "(string-to-number (frame-parameter nil 'outer-window-id))")
  13. # # this variant shows the first emacs frame and it is very slow process -
  14. # # it would be better to define the active window by a C prog (using Xlib)
  15. # #if [ -z "$(xprop -id $(xprop -root | awk '/^_NET_ACTIVE_WINDOW/ { print $5; exit }') | grep 'WM_CLASS' | grep --only-matching 'emacs')" ]; then
  16. # if [ -z $(xprop -id $(xdotool getactivewindow) | grep 'WM_CLASS' | grep --only-matching 'emacs') ]; then
  17. # wmctrl -xa emacs
  18. # fi