#!/usr/bin/bash # 监控时间,50 * 0.1秒 = 5秒 MTIME=50 for ((i=0; i<${MTIME}; i++)); do # 查询当前是否处于概览模式 read -r DUMMY DUMMY IS_OVERVIEW <<< "$(dbus-send --print-reply=literal --session --dest=org.gnome.Shell --type=method_call /org/gnome/Shell org.freedesktop.DBus.Properties.Get string:org.gnome.Shell string:OverviewActive)" if [[ "${IS_OVERVIEW}" = "true" ]] ; then # 如果处于概览模式,发送命令关闭它 /usr/bin/dbus-send --session --dest=org.gnome.Shell --type=method_call /org/gnome/Shell org.freedesktop.DBus.Properties.Set string:org.gnome.Shell string:OverviewActive variant:boolean:false exit fi sleep 0.1 done