14

I am using terminator 0.96 as terminal emulator. How can I make it run in the background and make it appear/disappear like guake terminal (i.e. using a shortcut key).

jokerdino
  • 41,762
Chirag
  • 2,099

8 Answers8

17

I was trying do the same thing (being a fan of both guake and terminator). Here's what I came up with (a customized version of desqua's answer to this question):

To launch an application or to show its window if already launched or to minimize if it is focused

1) Install wmctrl & xdotool, or in a terminal: sudo apt-get install wmctrl xdotool

2) Make a script:

  • Make a file gedit ~/bin/launch_focus_min.sh

And paste this:

#!/bin/bash                                                                                                            
#
# This script does this:
# launch an app if it isn't launched yet,
# focus the app if it is launched but not focused,
# minimize the app if it is focused.
#
# by desgua - 2012/04/29
# modified by olds22 - 2012/09/16
#  - customized to accept a parameter
#  - made special exception to get it working with terminator


# First let's check if the needed tools are installed:

tool1=$(which xdotool)
tool2=$(which wmctrl)

if [ -z $tool1 ]; then
  echo "Xdotool is needed, do you want to install it now? [Y/n]"
  read a
  if [[ $a == "Y" || $a == "y" || $a = "" ]]; then
    sudo apt-get install xdotool
  else
    echo "Exiting then..."
    exit 1
  fi
fi

if [ -z $tool2 ]; then
  echo "Wmctrl is needed, do you want to install it now? [Y/n]"
  read a
  if [[ $a == "Y" || $a == "y" || $a = "" ]]; then
    sudo apt-get install wmctrl
  else
    echo "Exiting then..."
    exit 1
  fi
fi


# check if we're trying to use an app that needs a special process name
# (because it runs multiple processes and/or under a different name)
app=$1
if [[ $app == terminator ]]; then
  process_name=usr/bin/terminator
else
  process_name=$app
fi

# Check if the app is running (in this case $process_name)

#pid=$(pidof $process_name) # pidof didn't work for terminator
pid=$(pgrep -f $process_name)

# If it isn't launched, then launch

if [ -z $pid ]; then
  $app

else

  # If it is launched then check if it is focused

  foc=$(xdotool getactivewindow getwindowpid)

  if [[ $pid == $foc ]]; then

    # if it is focused, then minimize
    xdotool getactivewindow windowminimize
  else
    # if it isn't focused then get focus
    wmctrl -x -R $app
  fi
fi

exit 0
  • Make it executable: chmod +x ~/bin/launch_focus_min.sh

3) Make your keyboard shortcut:

  • Open your keyboard settings and create a custom shorcut with the command: /home/<user>/bin/launch_focus_min.sh terminator (~/bin won't work)

  • assign this command to Shift+Escape (or whatever keyboard shortcut you used for guake).

olds22
  • 186
4

The easiest way to do this would be use xdotool, and use the windowunmap/windowmap command to hide/unhide the desired class of windows. (This approach was not mentioned in the other answers that mention xdotool.) The solution will work well across all desktops, whatever window manager they are using. As the manpage notes,

In X11 terminology, mapping a window means making it visible on the screen.

So, unmapping a window will do the opposite and hide the window. Unfortunately, there is no toggle available to use with xdotool to switch between map/unmap states, but the two commands you need are below. The first hides the window:

xdotool search --class terminator windowunmap %@

and the second reverses the effect:

xdotool search --class terminator windowmap %@

Please note that if the window is already minimised, the windowunmap command will be unsuccessful.

For more information see man xdotool, the Ubuntu manpages online, and my answer to this related question.

2

By selecting a set of preferences in Terminator, you can make it work almost similar to Guake.

Refer to the following article for detailed explanation.
http://www.webupd8.org/2011/07/install-terminator-with-built-in-quake.html

I would advise you to follow all the steps in the article to get the desired results. I skipped a few steps, thinking they weren't necessary, but were actually needed to overcome some bugs.

Hashken
  • 6,350
0

I wrote a script to raise and minimize the gnome terminal with byobu in linux mint, because guake has some weird console output messes. Then I added it to the shortcuts in the administrator keyboard->shurtcuts section.

script named guake-toggling-for-gnome-terminal.sh:

#!/usr/bin/env bash
if ! pgrep -x "gnome-terminal" > /dev/null
then
    gnome-terminal --app-id us.kirkland.terminals.byobu -e byobu
fi

byobuVisible=$(xdotool search --onlyvisible byobu)
byobuNotVisible=$(xdotool search byobu)
xdotool windowminimize ${byobuVisible}
xdotool windowraise ${byobuNotVisible}

Byobu is just the window name here.

metanerd
  • 201
0

The accepted answer didn't fully worked for me.

pgrep -f terminal // this does not give pid of renning terminator

I tweak this with


pid=`ps aux | grep terminator | awk '{print $2}'`

in line 54

0

Another version which relies on window name and class instead of pid. The advantage is that you can start other instances of Terminator independently.

Put the script into a file quakinator, make it executable, and associate it with a shortcut. The script assumes that xdotool, xwininfo, and wmctrl are installed.

Terminator is started with a layout called "Quakinator", which you can define to your liking. If it doesn't exist, Terminator uses the default layout.

The only problem I occasionally encounter is if I press the shortcut twice, then starting Terminator on the first press is not fast enough to prevent starting Terminator on the second press.

#!/bin/bash

associate with a KDE shortcut in Shortcuts / Custom shortcuts

dependencies: xdotool, xwininfo, wmctrl

function find_quakinator () {

find the window id such that is has both

the specified class and the specified name

TMP=mktemp -d xdotool search --class terminator | sort > "$TMP/terminator" xdotool search --name Quakinator | sort > "$TMP/quakinator" comm -1 -2 "$TMP/terminator" "$TMP/quakinator" }

find the Quakinator window id, launching it if it does not exist

WIDS=find_quakinator if [[ $WIDS == "" ]] then echo "Quakinator does not run, launching" terminator --layout "Quakinator" --title "Quakinator" WIDS=find_quakinator fi

toggle the hidden state of all found windows

there shouldn't be more than one, but just in case

for WID in $WIDS do echo "Quakinator window id: $WID" if xwininfo -id $WID | grep 'Map State: IsUnMapped' > /dev/null then echo " Window is invisible, making it visible" xdotool windowmap $WID wmctrl -i -R $WID # xdotool windowraise doesn't work else echo " Window is visible, making it invisible" xdotool windowunmap $WID fi done

A. Donda
  • 184
0

I would recommend simply using yakuake, a terminal in the same style as guake for the kde desktop.

You can install it by running sudo apt-get install yakuake.

Alex L.
  • 3,488
  • 1
  • 21
  • 22
  • Cannot leave terminator. I am using it since, last 2 years. Almost addicted to it by now. :) – Chirag Aug 10 '12 at 19:31
0

Well the simplest solution would be just to lock Terminator to launcher and use the shortcuts that Ubuntu provides.

You can starts any application that is locked to launcher using the launcher shortcut:

Super + 1 to 9

For a full list of ready available shortcuts, hold the Super key.

Waqleh
  • 911