如何让终结者模拟器像 guake 一样出现和消失?

Chi*_*rag 14 shortcut-keys terminator guake

我使用终结器 0.96 作为终端模拟器。我怎样才能让它在后台运行并让它像 guake 终端一样出现/消失(即使用快捷键)。

小智 17

我试图做同样的事情(既是 guake 又是终结者的粉丝)。这是我想出的(desqua这个问题的回答的定制版本):

启动应用程序或在已启动时显示其窗口或在聚焦时最小化

1) 安装wmctrl & xdotool,或在终端中:sudo apt-get install wmctrl xdotool

2)编写脚本:

  • 制作一个文件 gedit ~/bin/launch_focus_min.sh

并粘贴这个:

#!/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
Run Code Online (Sandbox Code Playgroud)
  • 使其可执行: chmod +x ~/bin/launch_focus_min.sh

3)制作键盘快捷键:

  • 打开您的键盘设置并使用以下命令创建自定义快捷方式:/home/<user>/bin/launch_focus_min.sh terminator(~/bin 不起作用)

  • 将此命令分配给 Shift+Escape(或您用于 guake 的任何键盘快捷键)。