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.

To restart Ubuntu 12.04 you now have to open a terminal (ctrl+alt+t), type "sudo shutdown -r 0" , followed by your password. I have been trying to write a script in Autokey to do this automatically, but can't manage to bring up the terminal window: keyboard.send_keys("++t") doesn't seem to work, so presumably an instruction to open gnome-terminal is needed. If anyone has a quick answer to this I would be very grateful - otherwise I'll try to learn some Debian coding..... Thanks in advance, Kaspin"

share|improve this question
    
If you're running GNOME 3 or Unity, let me know because my answer may not work then. –  cpburnz Jan 23 '13 at 16:02
add comment

2 Answers

If you're open to an easier suggestion not using AutoKey, you can go to System -> Preferences -> Keyboard Shortcuts.

System -> Preferences -> Keyboard Shortcuts

From there click "Add".

Add

Now name it "Shutdown" or something, and use "gksu shutdown -r 0" as the command.

Shutdown

Now click the "Shortcut" cell for its row, and press you're desired key combination.

Shortcut

NOTE: I am running Ubuntu 11.04 but this should be applicable.

share|improve this answer
add comment

To shutdown your system using an AutoKey script here's what you need to do.

  1. Select a folder in AutoKey ("New Script" will only be available when a folder is selected)

  2. Go to File -> Create -> New Script

  3. Enter the following for the script:

    system.exec_command("gksu shutdown -r 0", False)
    

    NOTE: Looking at the AutoKey sample scripts it looks like you use system.exec_command() to execute shell commands which would be the equilivlent to calling the standard python function subprocess.call("Some shell command", shell=True) (if you're familiar with python).

  4. Click the "Set" button to the right of "Hotkey". Click "Press to Set", press your desired shortcut key, and then click any desired modifiers for that key ("Control", "Alt", "Shift", "Super"), and then "OK".

    NOTE: Alt+Control+T is the shortcut combo for opening gnome-terminal.

  5. Click "Save" and you're done.

share|improve this answer
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.