Linux 如何从终端重新加载谷歌浏览器标签?
有没有办法只用终端在Ubuntu中重新加载Google Chrome标签。我不想只打开一个新窗口,而是想刷新一个标签 额外问题: 在其他浏览器(如Opera、Safari、Firefox)中也可以这样做。这可能是解决您问题的(最简单的)方法Linux 如何从终端重新加载谷歌浏览器标签?,linux,google-chrome,browser,terminal,Linux,Google Chrome,Browser,Terminal,有没有办法只用终端在Ubuntu中重新加载Google Chrome标签。我不想只打开一个新窗口,而是想刷新一个标签 额外问题: 在其他浏览器(如Opera、Safari、Firefox)中也可以这样做。这可能是解决您问题的(最简单的)方法 xdotool key --windowid "$(xdotool --search --class Chrome | head -n 1)" F5 编辑:这也适用于其他浏览器,没有问题看起来user2974830的答案是对xdool使用了一些不正确的(
xdotool key --windowid "$(xdotool --search --class Chrome | head -n 1)" F5
编辑:这也适用于其他浏览器,没有问题看起来user2974830的答案是对xdool使用了一些不正确的(可能是旧的)语法
--search
应该是search
(不带破折号),而--windowid
应该是--window
也就是说,这里有一个更全面的解决方案。链接使用inotifywait,但我更喜欢哪个包装inotifywait
echo "$(date --rfc-3339=seconds) Refresh: $FILE"
CUR_WID=$(xdotool getwindowfocus)
#gets the first $BROWSER window, if you have more than one
#$BROWSER window open, it might not refresh the right one,
#as an alternative you can search by the window/html title
WID=$(xdotool search --onlyvisible --class $BROWSER|head -1)
#TITLE="window/html file title"
#WID=$(xdotool search --title "$TITLE"|head -1)
xdotool windowactivate $WID
xdotool key 'ctrl+r'
xdotool windowactivate $CUR_WID
我将它保存到一个名为
reloadcromenix
的文件中,然后运行find-键入f | entr./reload chrome nix
一个内衬,它将聚焦chrome窗口,然后通过发送控件+r来重新加载浏览器:
xdotool search --onlyvisible --class Chrome windowfocus key ctrl+r
重要提示:在此之后,可能会发布一个更好的答案,请根据工具查看该答案,并根据您的用例使用您喜欢的答案 这个答案是从blackloop提供的解决方案开始的,但它可以在多个窗口中工作,让您在正确的窗口中选择正确的选项卡,方法是对选项卡标题使用字符串比较,并使用某些浏览器的功能通过发送击键选择特定的选项卡 代码有两个参数:窗口中的制表符位置(1到8之间的数字)和制表符标题的子字符串,用于标识正确的制表符 下面的代码基于Google Chrome,请参阅一些代码行上的注释,了解如何为Firefox案例更改它(或者您可以修改它以在输入中使用浏览器名称) 将此代码保存在文件中,例如
tab\u refresh.sh
(注意:此代码扩展为blockloop的答案) 创建文件后,使其可执行,例如键入:
chmod +x tab_refresh.sh
最后,要使用此脚本,必须键入以下内容:
./tab_refresh.sh TABNUM TABTITLE
例如,假设您想要更新Google Chrome窗口中的第四个选项卡,其中第四个选项卡标题包含字符串foo
./tab_refresh.sh 4 foo
解决方案:chromix也是
Chromix也是通过命令行向现有Chrome会话发送多种命令的工具,包括在给定选项卡标识符的情况下重新加载选项卡。如前所述,它由三个组件组成:Google Chrome的扩展、服务器和chromix工具
如何安装chromix呢
sudo apt-get install npm
sudo npm install -g chromix-too
chromix-too-server
chromix too
工具,您可以列出具有相应标识符的所有选项卡,以便能够选择正确的选项卡
chromix-too ls
结果会是这样
35 The foo bar website
136 https://another.website.foo/
142 https://another.one.bar/
如您所见,第一列显示唯一的数字标识符,第二列显示选项卡标题chromix-too reload 136
--devtools服务器端口
)和--remote debuging port=9222
参数来启用远程调试(只需记住事先关闭浏览器的所有实例)这就是你所需要的。如果其中一些不适合你,我正在为维瓦尔第寻找一个类似的东西,并设法将这里的一些东西和其他一些结合起来
xdool windowactivate$(xdool search--class vivaldi | tail-1)按ctrl+r windowactivate$(xdool getactivewindow)
您可以在第一个xdoool:unrecogned选项'--search'和key:unrecogned选项'--windowid'之后添加其他键-键值组合。我用来安装它的。到目前为止,这一切正常:xdoool windowactivate“65011713”和这个xdoool键“F5”,但我似乎无法向特定的窗口id发送密钥。它一直在说key:unrecognized option'--windowid'请尝试使用--window,我现在无法测试该命令,很抱歉,非常感谢您的解决方案(刚刚投票),因为这是编写a的一个很好的起点
35 The foo bar website
136 https://another.website.foo/
142 https://another.one.bar/
chromix-too reload 136
sudo apt-get update
sudo apt-get install xdotool
DISPLAY=:0 xdotool key F5