在 Gnome 中的不同工作区中打开应用程序
鉴于我的懒惰,我尝试编写一个 bash 脚本,在不同的桌面上同时打开一些日常应用程序。该脚本应该可以在 Gnome 中运行。到目前为止我已经写过:
#!/bin/bash
firefox &
thunderbird &
/usr/bin/netbeans --locale en &
amsn &
gnome-terminal &
sleep 2
wmctrl -r firefox -t 0 && wmctrl -r netbeans -t 1 && wmctrl -r gnome-terminal -t 2 && wmctrl -r amsn -t 6 && wmctrl -r thunderbird -t 7
......但它不起作用。我的应用程序打开,但它们不会分配给我指定的桌面:(。
我将 sleep 的值更改为 15。,但只有 firefox 和 netbeans 被正确分配;其余的在我执行脚本的工作区中打开从。
Given my laziness, I tried to write a bash script that opens at once some daily apps in different desktops. This script should work in Gnome. I've written that so far:
#!/bin/bash
firefox &
thunderbird &
/usr/bin/netbeans --locale en &
amsn &
gnome-terminal &
sleep 2
wmctrl -r firefox -t 0 && wmctrl -r netbeans -t 1 && wmctrl -r gnome-terminal -t 2 && wmctrl -r amsn -t 6 && wmctrl -r thunderbird -t 7
... but it doesn't work. My apps open, but they won't be assigned to the desktops I specify :(.
I changed the value of sleep to 15., but only firefox & netbeans are assigned correctly; the rest opens in the workspace where I execute the script from.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
感谢 Akira 评论,我终于成功地让它工作了(脚本在启动时像魅力一样运行)这是新代码:
Thanks to Akira comment, I finally succeeded at making it work (the script runs at startup like a charm) Here is the new code:
签出 DevilsPie,它会监视窗口的创建并采取相应的操作。
或者您可以使用能够在内部执行相同操作的窗口管理器,例如。 fluxbox。
checkout DevilsPie, it watches creation of windows and act accordingly.
Or you can use a window manager which is able to do the same in-house, eg. fluxbox.
在 dconf 编辑器中:
In dconf-editor:
该脚本将检查是否需要更改工作区,切换到工作区,启动应用程序,等待窗口创建并切换回原始命名空间。
因为它使用 wmctrl -l 来检查是否创建了新窗口,所以它可以处理快速启动和慢速启动的应用程序,而无需等待静态的秒数。
我将此脚本称为
start-on-workspace
。用法:
start-on-workspace <工作区> <命令> [参数...
This script will check if it's required to change the workspace, switches to it, starts the app, waits until the window is created and switches back to the origin namespace.
Because it uses
wmctrl -l
to check if a new window was created, it can handle fast as well as slow started applications, without the need to wait for for a static amount of seconds.I called this script
start-on-workspace
.Usage:
start-on-workspace <Workspace> <command> [argument...