# emacs key binding



## kb6rxe (Nov 9, 2010)

I'd like to be able to send a command to the shell from inside emacs and have the control 
returned immediately to emacs after the command is executed. 
I'd like to bind that command to one key, perhaps F12.
The command I'd like to send is 

`setxkbmap us`

I'll define another key, perhaps F11, to send the command 

`setxkbmap lt`

I want to switch between US and Lithuanian keyboards

Any ideas?


----------



## luna (Nov 9, 2010)

If you want to send commands to emacs from outside it consider using emacsclient(1), e.g.
`$ emacsclient --eval '(shell-command "ps")'`
And then you can bind such command to a key in window manager.

As for keybindings that work only in emacs

```
(global-set-key (kbd "<f11>") (lambda nil (interactive) (shell-command "setxkbmap it")))
(global-set-key (kbd "<f12>") (lambda nil (interactive) (shell-command "setxkbmap us")))
```


----------



## kb6rxe (Nov 9, 2010)

that did the trick
Thanks. I'm sure I'll be able to use that a lot.


----------

