emacs key binding

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?
 
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
Code:
(global-set-key (kbd "<f11>") (lambda nil (interactive) (shell-command "setxkbmap it")))
(global-set-key (kbd "<f12>") (lambda nil (interactive) (shell-command "setxkbmap us")))
 
Back
Top