1

I am using Ubuntu 20.04, and I'm one of those who enjoys Gnome. Even so, sometimes I like tiling my terminals for work. Usually I'll set them up like so:

enter image description here

I use the Terminator terminal to achieve that effect.

Now, it takes a lot of hotkeys to get to that setup. I have Terminator set as Super-T; then I need to split vertically (Ctrl-Shift-O), then split horizontally (Ctrl-Shift-O). Then I shift the terminals around with Ctrl-Down and Ctrl-Right. I'd like to create a single hotkey that can sequence all those combinations in a single press. I tried to write a script using xdotool:

#!/bin/bash
xdotool key super+j
xdotool key shift+F1
xdotool key super+Up
xdotool key ctrl+shift+o
xdotool key ctrl+shift+e
xdotool key ctrl+shift+Down
xdotool key ctrl+shift+Down
xdotool key ctrl+shift+Down
xdotool key ctrl+shift+Down
xdotool key ctrl+shift+Down
xdotool key ctrl+shift+Down
xdotool key ctrl+shift+Down
xdotool key alt+Down
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key ctrl+shift+Left
xdotool key alt+Right
xdotool ipython

This was going to be a quick and dirty start to get done what I need to get done, but all that it does is open a new workspace (Super-J) and a Terminator instance (Shift-F1). The other keypresses don't register in the Terminator window in order to effect the necessary window customizations.

Does anyone have a better recommendation of how to do this?

2 Answers 2

0
+50

It doesn't actually create a hotkey sequence but maybe gets the desired result (?)

Do your settings the way you like and then right click on one of the terminals -> preferences -> layout tab

Click on default and then save.

So now you just have to open terminator again and you will have your layout immediately.

I didn't understand the "shifting terminals around" part though...

3
  • While I did create a layout called IDE that allows me to, for example, run a dmenu line as terminator -l IDE (not that I'm a big expert in dmenu, or really even use it, for that matter--I don't want to give you the wrong idea about my expertise, or lack thereof), I don't always want to open Terminator with that layout. It also opens a second instance with the default layout for some reason. The "shifting terminals" is a feature of Terminator that allows for resizing of terminal windows within the single instance of Terminator.
    – Yehuda
    Oct 25, 2021 at 22:22
  • 2
    Hmmm, OK. I don't have any experience with dmenu... If you don't want it to be the default layout why don't you create a custom layout and then just make a hotkey to run terminator with that custom layout ? For shifting, I thought it was something like that, IDK why but it doesn't work on my system...
    – golder3
    Oct 25, 2021 at 22:30
  • After messing around with the layouts, I've concluded that saving the layout saves the positions of the terminal windows as well. The script now works perfectly, thanks.
    – Yehuda
    Oct 28, 2021 at 0:12
0

You can write all the commands from the hotkeys on a shell script and refence the new hotkey to execute that script. Locate the script in /bin/ (with execute permissions) or adding the path of the script to the environment variable PATH so that the hotkey can detect it as a command.

2
  • I figured, but I have no idea how to do that. I'll update my question with the script I wrote and the issues I had.
    – Yehuda
    Oct 24, 2021 at 20:21
  • Instead of using the commands "xdtool key...." write the actual command linked to that key combination.
    – esantix
    Oct 25, 2021 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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