该脚本运行前要安装wmctrl.运行该脚本后,可以通过点击任务栏上的程序 最小化和还原 程序窗口。
#! /bin/sh
# minimize/restore windows on current desktop
# -----------------------------------
# vermaden [AT] interia [DOT] pl
# ~vermaden/links.htm
CURRENT_DESKTOP=$( wmctrl -d | egrep "^[0-9][ ]{2}\*" | awk '{print $1}' )
WINDOW_LIST=$( wmctrl -l | egrep "^[0-9]x.{8}\ {2}${CURRENT_DESKTOP}" | awk '{print $1}' )
WINDOW_COUNT=0
for WINDOW in ${WINDOW_LIST} ;do
WINDOW_COUNT=$(( ${WINDOW_COUNT} + 1 ))
done
minimize () {
for WINDOW in ${WINDOW_LIST}; do
wmctrl -t ${CURRENT_DESKTOP} -i -r ${WINDOW} -b add,hidden
done
}
restore () {
for WINDOW in ${WINDOW_LIST}; do
wmctrl -t ${CURRENT_DESKTOP} -i -r ${WINDOW} -b remove,hidden
done
}
MINIMIZED=0
for WINDOW in ${WINDOW_LIST}; do
if xprop -id ${WINDOW} _NET_WM_STATE | grep -q NET_WM_STATE_HIDDEN; then
MINIMIZED=$(( ${MINIMIZED} + 1 ))
fi
done
if [ ${MINIMIZED} -eq ${WINDOW_COUNT} ]; then
restore
else
minimize
fi
阅读(2644) | 评论(0) | 转发(0) |