gpt4 book ai didi

bash - 使用 bash 最小化启动 chromium-browser

转载 作者:行者123 更新时间:2023-11-29 09:50:55 25 4
gpt4 key购买 nike

我想在终端中使用 bash 启动最小化的 chromium-browser

目前正在使用 chromium-browser 打开 Chromium。但是如何使用 bash 命令将其最小化。

最佳答案

使用 wmctrl , (在基于 Debian 的系统上使用 apt install wmctrl 安装),向任何 NetWM window manager 发送命令:

chromium-browser && \
last_chrom=$(wmctrl -l |
grep -i chrom | tail -1 |
while read a b ; do echo $a ; done) ; \
wmctrl -ir $last_chrom -b toggle,hidden

工作原理:

  1. 启动浏览器。
  2. 在变量 $last_chrom 中保存最近一次调用 chromium-browserwindow identity 编号。
  3. 使用 wmctrl 隐藏该窗口。

(可选)要在运行一分钟后关闭窗口,再添加一行:

chromium-browser && \
last_chrom=$(wmctrl -l |
grep -i chrom | tail -1 |
while read a b ; do echo $a ; done) ; \
wmctrl -ir $last_chrom -b toggle,hidden ; \
{ sleep 1m && wmctrl -ic $last_chrom ; } &

关于bash - 使用 bash 最小化启动 chromium-browser,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45041663/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com