Chinaunix首页 | 论坛 | 博客
  • 博客访问: 82535
  • 博文数量: 21
  • 博客积分: 1445
  • 博客等级: 上尉
  • 技术积分: 175
  • 用 户 组: 普通用户
  • 注册时间: 2006-04-07 18:33
文章分类
文章存档

2011年(1)

2008年(1)

2007年(19)

我的朋友
最近访客

分类: BSD

2007-12-29 22:10:50

该脚本运行前要安装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) |
给主人留下些什么吧!~~