deepin shell脚本切换多个窗口
Tofloor
poster avatar
song123
deepin
2017-07-01 17:15
Author
求助贴~
经常开几个窗口,用super+table切换很不方便,能不能使用脚本+自定一快捷键的方式切换至指定的窗口,比如设置快捷键alt+g打开Google chrome,如果chrome已经运行,则把chrome窗口切换至最前?求脚本
Reply Favorite View the author
All Replies
avatar
153******66
deepin
2017-07-01 18:09
#1
Gnome pie?
Reply View the author
avatar
song123
deepin
2017-07-01 23:16
#2
了解了2楼说的gnome ple ,但并不是楼主想要的,后来发现解决办法,分享给大家https://bbs.deepin.org/user/11116
首先安装工具wmctrl
sudo apt-get install wmctrl
然后编写she'll脚本:
#!/bin/bash
#参数1为窗口标题包含的字符串,注意大小写
#参数2为未打开时执行的命令

app=$1
temp=0
for window in `wmctrl -l`
do
  if [[ "$app" == "$window" ]]
  then
    `wmctrl -R $app`
    temp=1
    break
  fi
done
if [[ $temp == 0 ]]
then
  `$2`
fi
然后保存到一个地方,楼主保存在了/opt/myshell/openWindow.sh
然后打开控制中心的快捷键设置,以chrome为例,设置命令为:
/opt/myshell/openWindow.sh Chrome /opt/google/chrome/chrome

完美运行。
Reply View the author
Comments
eleveni386
2017-07-02 03:02
[赞]  自己动手 丰衣足食. 哈哈.jpg
avatar
zzz19760225
deepin
2017-07-02 00:28
#3
要是有个对脚本代码的补充解说就更好了
Reply View the author
avatar
firstuanl
deepin
2017-07-02 00:42
#4
本帖最后由 firstuanl 于 2017-7-1 16:44 编辑

行 9: [[chrome: 未找到命令

PS:nautilus的标题信息是什么,还有,firefox我用 Mozilla Firefox怎没效果
Reply View the author
avatar
song123
deepin
2017-07-02 01:23
#5
https://bbs.deepin.org/post/141846
行 9: [[chrome: 未找到命令

PS:nautilus的标题信息是什么,还有,firefox我用 Mozilla Firefox怎没效果

注释---------------
Reply View the author
avatar
song123
deepin
2017-07-02 01:26
#6
https://bbs.deepin.org/post/141846
行 9: [[chrome: 未找到命令

PS:nautilus的标题信息是什么,还有,firefox我用 Mozilla Firefox怎没效果

sorry刚才回复错楼层了,标题信息可以在这里看到(见图片),脚本只能识别单个单词,把Mozilla Firefox 换成Firefox 就好了

Reply View the author
avatar
song123
deepin
2017-07-02 01:27
#7
https://bbs.deepin.org/post/141846
要是有个对脚本代码的补充解说就更好了

注释见6楼
Reply View the author
avatar
zzz19760225
deepin
2017-07-02 02:25
#8

收到,谢谢回答。
Reply View the author
avatar
firstuanl
deepin
2017-07-02 19:51
#9
不知怎的,firefox和nautilus还是没效果
Reply View the author
avatar
song123
deepin
2017-07-04 16:18
#10
https://bbs.deepin.org/post/141846
不知怎的,firefox和nautilus还是没效果

把你的快捷键执行的命令发来看看 注意Firefox 首字母要大写
Reply View the author
avatar
firstuanl
deepin
2017-07-05 05:32
#11
https://bbs.deepin.org/post/141846
把你的快捷键执行的命令发来看看 注意Firefox 首字母要大写

rt

终端和gedit可以

nautilus不知是什么标题,firefox是直接再开窗口

Reply View the author
avatar
song123
deepin
2017-07-05 17:26
#12
https://bbs.deepin.org/post/141846
rt

终端和gedit可以

nautilus的标题可以设置为nautilus , Firefox那个就不知道了,你可以对着脚本调试一下
Reply View the author