Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm quite impressed of emacs' org-mode. So I want to use it for note-taking during lectures. To use it "distraction-free" my idea is the following:

I want to register a bash-command, which swaps the x-server session with tty2 and starts emacs with its org-mode. Is it possible to pass my credentials from the x-server session to tty2 (optional)?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

By default tty2 is occupied by init for getty. You can probably change this by removing /etc/init/tty2.conf, but that was too adventurous for me and the instructions here are for tty9 instead (which is by default unallocated).

First, put these commands to ${HOME}/bin/orgmode.sh or other file:

#!/bin/bash

TTY=/dev/tty9
USER=pschmidt

/usr/bin/sudo chown ${USER}.tty ${TTY}
/usr/bin/sudo chmod 620 ${TTY}
( /usr/bin/sudo -u ${USER} /usr/bin/emacs -t ${TTY} -nw ) &
/usr/bin/sudo chvt 9

(Use a different value for USER as necessary.)

Then, execute this bash command (not sure what you meant by register):

sudo time getty -n -l "${HOME}/bin/orgmode.sh" tty9 230400

Some caveats:

  • The time command (or a similar dummy) is needed to prevent sudo terminal rearrangements from placing emacs on your current terminal
  • The speed value of 230400 is there only because getty requires it, other values probably work also
  • If sudo needs to ask your password and that messes up things, you can first run sudo echo and then the above command.
share|improve this answer
    
Thanks. Works fine –  pschmidt May 1 '12 at 20:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.