5

I want to make a list of commands to install everything so it's easier the next time I do it, however, I wanted one of the commands to do CTRL+ALT+F1 for me.

4
  • 1
    Why would you want to switch to tty1 when you can just run the commands in a gnome terminal?
    – psusi
    May 28, 2017 at 2:07
  • perhaps make it lock screen
    – ravery
    Oct 9, 2017 at 14:45
  • @AndroidDev that's very close to the solution I was looking for, but I needed one that doesn't need sudo.
    – ArM
    Oct 9, 2017 at 16:23
  • @ArM see the second answer on that question Oct 9, 2017 at 17:16

3 Answers 3

8

This is quite simple actually. Just run this command:

sudo chvt 1
3

If you want to send keystrokes xdotool is the tool you need:

xdotool key Ctrl+Alt+F1

This will send the combination Ctrl+Alt+F1 as you requested, for other TTYs just change F1. You may need to install xdotool first with e.g.:

sudo apt install xdotool

The following merely answers How to programmatically trigger Ctrl+Alt+F1 without sudo?, from where this answer was moved here.

I find osd_cat (package xosd-bin) a fun way to notify myself, try:

echo alarm | osd_cat -Acenter -d10 -f"-adobe-helvetica-bold-*-*--400-*-*-*-*"

-d sets the time in seconds the notification is displayed, see man osd_cat for the many options.

1

It could be done also via additional program as xte fron the package xautomation. Install the package:

sudo apt install -y xautomation 

And run this command:

xte 'keydown Control_L' 'keydown Alt_L' 'key F1'

References:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .