自动检测并关闭对话框的程序示例
创建并打开KDialog的脚本
#!/bin/bash
kdialog --msgbox "demo"
自动检测并定时关闭KDialog的脚本
#!/bin/bash
# Continuously check for kdialog dialog
while true; do
# Get the window ID of the kdialog dialog
DIALOG_WIN_ID=$(wmctrl -lp | grep "KDialog" | awk '{print $1}')
# If a window ID is found, wait 5 seconds and then close the dialog
if [ -n "$DIALOG_WIN_ID" ]; then
echo "Dialog detected, it will be closed in 5 seconds..."
sleep 5
wmctrl -ic $DIALOG_WIN_ID
echo "Dialog has been closed."
fi
# Check every second
sleep 1
done