如何在bash脚本执行命令,然后集中显示的窗口 [英] How to execute a command in a bash script and then focus the appearing window

查看:135
本文介绍了如何在bash脚本执行命令,然后集中显示的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个bash脚本这样

I have a bash script like this

#!/bin/sh
firefox &

Firefox窗口打开,但它不具有焦点。我能做些什么,以便它会自动具有焦点?

The Firefox window opens, but it doesn't have focus. What can I do so that it has the focus automatically?

我可以使用一些X Window工具/命令,但我怎么得到的Firefox窗口ID?窗口名称与网址显示的变化,因此不实用。

I could use some X window tools / commands, but how do I get the window ID of Firefox? The window name is changing with the URLs displayed and therefore not useful.

编辑:我的窗口管理器是侏儒

My window manager is Gnome.

推荐答案

xdotool 是这样做的工具。

为特定的任务最简单的形式是

The simplest form for your particular task is

xdotool  windowactivate `xdotool search --pid $! `

这篇关于如何在bash脚本执行命令,然后集中显示的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆