首页 > 编程知识 正文

linux快速切换窗口,linux快捷键打开指令窗口

时间:2023-05-05 10:09:33 阅读:240693 作者:1617

linux窗口切换快捷键

We’ve already shown you how to customize shortcut keys in any Linux application, but for today’s lesson we’ll take it a step nqdxq—and assign a shortcut key that switches an open application to be the currently focused window.

我们已经向您展示了如何在任何Linux应用程序中自定义快捷键 ,但是在今天的课程中,我们将进一步介绍它,并指定将打开的应用程序切换为当前焦点窗口的快捷键。

The idea is that instead of using the mouse or flipping through a set of windows in the Alt+Tab switcher, you can quickly assign a hotkey to your most important windows and switch to them with a single keystroke, saving yourself a lot of time. To accomplish this task on Linux, we’ll use the excellent AutoKey utility.

这个想法是,您无需使用鼠标或在Alt + Tab切换器中浏览一组窗口,而是可以将热键快速分配给最重要的窗口,并通过一次按键即可切换到它们,从而节省了很多时间。 为了在Linux上完成此任务,我们将使用出色的AutoKey实用程序。

Note: if you want the Windows way to do this, you can accomplish the task with AutoHotkey easily.

注意:如果您希望使用Windows的方式来执行此操作,则可以使用AutoHotkey轻松完成任务 。

场景 (The Scenario)

Since I do most of my work in Google Chrome, I need to have it accessible as quickly as possible and I generally assign the Alt+G key combination to switch to my open Chrome window.

由于我的大部分工作都是在Google Chrome浏览器中完成的,因此我需要尽快对其进行访问,并且通常会分配Alt + G组合键切换到打开的Chrome窗口。

安装自动密钥 (Installing AutoKey)

You’ll want to open up the Synaptic Package Manager and do a quick search for autokey, check the box, and then install the package. You could also install it using the apt-get command like this:

您将要打开Synaptic软件包管理器并快速搜索autokey ,选中该复选框,然后安装该软件包。 您也可以使用apt-get命令安装它,如下所示:

sudo apt-get install autokey

sudo apt-get install autokey

将快捷键分配给应用程序窗口 (Assigning a Shortcut Key to an Application Window)

Open up the AutoKey configuration screen from the system tray icon, and then create a New Script from the menu, and then paste in the following code:

从系统任务栏图标打开“自动键配置”屏幕,然后从菜单中创建“新脚本”,然后粘贴以下代码:

window.activate(‘Google Chrome’)

window.activate('Google Chrome')

You’ll want to use the Set button next to the Hotkey setting, and assign your preferred hotkey—mine is Alt+G, though you’ll want to make sure that you use a lowercase g while setting the hotkey—if you set it using an uppercase letter it won’t behave right.

您将要使用“热键”设置旁边的“设置”按钮,并分配您首选的热键(我的是Alt + G,尽管要确保在设置热键时使用小写的g)(如果设置了该键)使用大写字母将无法正常工作。

Once you save the setting and minimize or close the AutoKey configuration screen, you can hit the Alt+G shortcut key combination anytime you want to switch to the open window.

保存设置并最小化或关闭“自动键”配置屏幕后,您随时可以切换到打开的窗口,按Alt + G快捷键组合。

这是如何运作的? (How Does This Work?)

When you hit the shortcut key that you’ve assigned, AutoKey will run the script that you’ve added—in this case, it’s a simple Python script that uses the wmctrl functions to control open windows. Here’s the syntax for the window.activate function, which switches the specified window to be the active window:

当您按下分配的快捷键时,AutoKey将运行您添加的脚本-在这种情况下,这是一个简单的Python脚本,使用wmctrl函数控制打开的窗口。 这是window.activate函数的语法,该函数将指定的窗口切换为活动窗口:

window.activate(‘partial window title here’)

window.activate('部分窗口标题在这里')

Basically all you need to do is match part of the window title, and in the case of Google Chrome, the window title always has “- Google Chrome” at the end.

基本上,您需要做的就是匹配窗口标题的一部分,对于Google Chrome,窗口标题的末尾总是带有“-Google Chrome”。

翻译自: https://www.howtogeek.com/howto/26937/assign-a-shortcut-key-to-activate-an-open-application-window-on-linux/

linux窗口切换快捷键

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。