使用 bash 最小化启动铬浏览器

Start chromium-browser minimized using bash

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

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

使用wmctrl, (on Debian-based systems install with apt install wmctrl), to send commands to any 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. 保存最近调用chromium-browserwindow身份号在变量$last_chrom.
  3. 使用 wmctrl 隐藏 window。

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

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 ; } &