Nat*_*man 9 command-line bash fullscreen
我有一个小的 shell 脚本,它会播放一些小叮当并在我收到新电子邮件时显示通知。
问题是这个 shell 脚本可以在任何时候被调用——包括当我在全屏模式下观看 DVD/视频并且声音很大时——这很烦人。
我想通过检测应用程序是否处于全屏模式来增强此脚本。我知道这一定是有可能的,因为在这种情况下不会显示通知。
我可以使用什么命令?
作为一个 shell 脚本有点极端矫枉过正,但它应该可以解决问题:
#!/bin/bash
WINDOW=$(echo $(xwininfo -id $(xdotool getactivewindow) -stats | \
egrep '(Width|Height):' | \
awk '{print $NF}') | \
sed -e 's/ /x/')
SCREEN=$(xdpyinfo | grep -m1 dimensions | awk '{print $2}')
if [ "$WINDOW" = "$SCREEN" ]; then
exit 0
else
exit 1
fi
Run Code Online (Sandbox Code Playgroud)
然后你可以检查它:
if is-full-screen ; then echo yup, full screen ; fi
Run Code Online (Sandbox Code Playgroud)
如下所述,您需要先安装 xdotool:
sudo apt-get install xdotool
Run Code Online (Sandbox Code Playgroud)