跳转至内容

Guake

来自 ArchWiki

Guake 是一款顶置式终端模拟器,适用于 GNOME(风格类似于 Yakuake for KDETilda 或 Quake 中的终端)。

安装

安装 guake 包。

用法

安装完成后,您可以在终端中使用以下命令启动 Guake:

$ guake

Guake 启动后,您可以右键单击界面并选择*首选项*来更改自动下拉终端的热键,默认设置为 F12

自动启动

您可能希望 Guake 在启动桌面环境时自动加载。为此,您需要

# cp /usr/share/applications/guake.desktop /etc/xdg/autostart/

有关更多信息,请参阅 自动启动

Guake 脚本

Yakuake 类似,Guake 允许通过发送 D-Bus 消息来在运行时控制自身。因此,它可以用于在用户定义的会话中启动 Guake。您可以创建标签页,为它们分配名称,还可以要求在任何打开的标签页中运行任何特定命令,或者仅仅是显示/隐藏 Guake 窗口,这可以通过手动在终端中操作,或创建自定义脚本来实现。

此类脚本的示例在此部分下方给出。

您可以使用 guake 可执行文件本身来发送 D-Bus 消息。以下是您可能感兴趣的可用选项列表:

  • -t, --toggle-visibility — 切换终端窗口的可见性。实际上,您只需键入 guake,它就会切换已运行实例的可见性。
  • -f, --fullscreen — 将 Guake 置于全屏模式。
  • --show — 显示 Guake 主窗口。
  • --hide — 隐藏 Guake 主窗口。
  • -n CUR_DIR, --new-tab=CUR_DIR — 创建新标签页并选中它。如果指定了 CUR_DIR,则该值用于为标签页设置当前目录。
  • -s INDEX, --select-tab=INDEX — 选择索引为 INDEX 的标签页。标签页索引从 0 开始。
  • -g, --selected-tab — 打印当前选定标签页的索引。
  • -e CMD, --execute-command=CMD — 在选定的标签页中执行任意命令 CMD
  • -i INDEX, --tab-index=INDEX — 与 --rename-tab 一起使用,用于指定要重命名的标签页的索引 INDEX。默认值为 0。
  • --rename-tab=TITLE — 将标签页名称设置为 TITLE。通过传递单个连字符 ("-") 可以将标签页名称重置为默认值。使用 -i 选项指定要重命名的标签页。
  • --bgcolor=RGB — 将选定标签页的背景颜色 RGB 设置为十六进制 (#rrggbb) 值。
  • --fgcolor=RGB — 将选定标签页的前景色 RGB 设置为十六进制 (#rrggbb) 值。
  • -r TITLE, --rename-current-tab=TITLE — 与 --rename-tab 相同,但重命名当前选定的标签页。
  • -q, --quit — 关闭正在运行的 Guake 实例。

多个选项可以组合在单个调用中。如果没有运行 guake 实例,则所有指定的选项都将应用于新创建的实例。

要显示所有可用选项的列表,请键入 guake --help

有两种方法可以在应用这些脚本的同时启动 guake:

  • 将下面的示例复制到一个文件中,例如 guake-init.sh,使其可执行,然后运行该文件而不是 guake。
  • 右键单击 Guake Terminal > Preferences > Hooks,然后在“On start:”字段中添加 guake-init.sh 脚本的路径,同时确保从下面的脚本中注释掉 /usr/bin/guake &sleep 5

第二种方法更可取,如果您希望脚本无论 Guake 如何启动都运行,并且仍然可以使用 guake --no-startup-script 指示 Guake 不要运行脚本(如果需要)。

示例

#!/bin/sh

/usr/bin/guake &
sleep 5 # let main guake process start and initialize D-Bus session

# adjust tab which was opened by default
guake --rename-tab="iotop" --execute="/usr/bin/iotop"

# create new tab, start bash session in it
guake --new-tab --execute="/usr/bin/bash"
# and then execute htop, renaming the tab to "htop"
guake --execute="/usr/bin/htop" --rename-current-tab="htop"

# ...
guake --new-tab --execute="/usr/bin/bash"
guake --execute="/usr/bin/atop" --rename-current-tab="atop"

guake --new-tab --execute="/usr/bin/bash"
guake --execute="~/.iptables.sh" --rename-current-tab="iptables -nvL"

guake --new-tab --execute="/usr/bin/bash"
guake --execute="/usr/bin/journalctl --follow --full" --rename-current-tab="journalctl"

guake --new-tab --execute="/usr/bin/bash"
guake --execute="/usr/bin/irssi" --rename-current-tab="irssi"

guake --new-tab --execute="/usr/bin/bash"
guake --execute="/usr/bin/sudo -i" --rename-current-tab="rootshell0"

guake --new-tab --execute="/usr/bin/bash"
guake --execute="/usr/bin/sudo -i" --rename-current-tab="rootshell1"

guake --new-tab --execute="/usr/bin/bash"
guake --rename-current-tab="shell0"

guake --new-tab --execute="/usr/bin/bash"
guake --rename-current-tab="shell1"

请注意,我们应该在调用 sleep 时等待一段时间,以避免运行实例之间的竞态条件。

警告 --execute 选项可能会对正在运行文本界面程序的标签页造成损害,例如 fdiskinnotop。请谨慎使用。GitHub 上有一个关于此问题的 bug:guake#921

故障排除

窗口管理器中的浮动模式

在某些 窗口管理器 中,Guake 可能无法以浮动模式打开。这可以通过使用 Guake 的窗口类字符串(根据 xprop WM_CLASS"guake""Guake")来解决。例如,请参阅 i3i3#Correct handling of floating dialogs 中的“WM_CLASS”。

切换 Guake 可见性无效 (Wayland)

如果您使用的是 Wayland,Guake 可见性切换热键在某些应用程序下可能无效。这是因为 Guake 使用了一个为 X 环境设计的全局热键库,而 Wayland 没有等效的全局热键接口。许多应用程序(例如 Firefox)通过 Xwayland 在 Wayland 上运行,此时 Guake 切换将生效,但其他原生运行在 Wayland 上的应用程序(例如 GNOME 应用程序)会禁用 Guake 切换功能。

如果您不想切换到 X 环境,一个简单的解决方法是为 guake-toggle 命令配置一个与您的窗口管理器/桌面环境相关的快捷方式。

有关更多详细信息,请参阅 github issue

注意 建议使用 guake-toggle 而不是 guake -t。它要快得多,因为它直接通过 D-Bus 进行通信,而无需完全初始化 Guake。

Wayland 下 Guake 模糊

如果您使用的是具有分数缩放的 Wayland 桌面环境,Guake 可能会显得模糊。如果出现这种情况,很可能是因为您的桌面环境正在对 Guake 进行上采样。Guake 不会遵守 GDK_BACKEND 环境变量。相反,要使 Guake 使用 Wayland,请设置 GUAKE_ENABLE_WAYLAND=1 环境变量。

参见

© . This site is unofficial and not affiliated with Arch Linux.

Content is available under GNU Free Documentation License 1.3 or later unless otherwise noted.