如何使终结器模拟器出现并像guake一样消失?
我使用终结器0.96作为终端仿真器。 如何使其在后台运行并使其像guake终端一样显示/消失(即使用快捷键)。
我正在尝试做同样的事情(成为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
- 使其可执行:
chmod +x ~/bin/launch_focus_min.sh
3)制作键盘快捷键:
-
打开键盘设置并使用以下命令创建自定义shorcut:/
/home/
/</bin/launch_focus_min.sh terminator /home/
(〜/ bin将不起作用)/bin/launch_focus_min.sh terminator -
将此命令分配给Shift + Escape(或用于guake的任何键盘快捷键)。
最简单的方法是使用xdotool
,并使用windowunmap/windowmap
命令隐藏/取消隐藏所需的窗口类。 (在提到xdotool
的其他答案中没有提到这种方法。)该解决方案适用于所有桌面,无论他们使用什么窗口管理器。 正如手册页所述 ,
在X11术语中,映射窗口意味着在屏幕上显示它。
因此,取消映射窗口将执行相反操作并隐藏窗口。 不幸的是,没有切换可用于xdotool
在map / unmap状态之间切换,但是你需要的两个命令如下。 第一个隐藏窗口:
xdotool search --class terminator windowunmap %@
第二个逆转效果:
xdotool search --class terminator windowmap %@
请注意,如果窗口已经最小化,则windowunmap
命令将失败。
有关更多信息,请参阅man xdotool
, 在线Ubuntu联机帮助页以及我对此相关问题的回答 。
通过在“终结者”中选择一组首选项,您可以使其与Guake几乎相似。
有关详细说明,请参阅以下文章。
http://www.webupd8.org/2011/07/install-terminator-with-built-in-quake.html
我建议您按照文章中的所有步骤来获得所需的结果。 我跳了几步,认为没有必要,但实际上需要克服一些错误。
我建议只使用yakuake
,一个与kde桌面相同风格的终端。
您可以通过运行sudo apt-get install yakuake
来安装它。
那么最简单的解决方案就是将Terminator锁定到启动器并使用Ubuntu提供的快捷方式 。
您可以使用启动器快捷方式启动锁定到启动器的任何应用程序:
超级+ 1到9
有关现成可用快捷方式的完整列表,请按住超级键。
我写了一个脚本来提高和最小化linux中的byobu终端的gnome终端,因为guake有一些奇怪的控制台输出混乱。 然后我将它添加到管理员keyboard-> shurtcuts部分的快捷方式中。
名为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就是这里的窗口名称。