很棒两次启动程序

很棒两次启动程序

我在 MacBook 上运行 Ubuntu 并使用外接显示器。因此,如果外接显示器已连接到此小 ruby​​ 脚本,我会使用 xrandr 在启动时关闭笔记本电脑显示器:

#!/usr/bin/ruby

display = `xrandr -q | grep DP-1`.to_s

if !display.include? "disconnected"  then
   `xrandr --output LVDS-1 --off`
   `xrandr --output DP-1 --mode 1920x1080`
   sleep 3
end

我使用 rc.lua 来启动该脚本和 awesome 中的其他一些程序:

...
awful.util.spawn_with_shell("/home/jo/.config/awesome/setdisplay.rb")
awful.util.spawn_with_shell("nm-applet")
awful.util.spawn_with_shell("dropbox start")
awful.util.spawn_with_shell("setxkbmap de")
awful.util.spawn_with_shell("thunderbird")
awful.util.spawn_with_shell("google-chrome")
awful.util.spawn_with_shell("pidgin")
...

监控脚本运行良好,但不幸的是,一些程序启动了两次,例如google-chromenm-applet。我认为所有程序都启动了两次,但其他程序(例如、dropboxthunderbird)只允许一个实例。我这么认为是因为thunderbird抱怨另一个正在运行的实例。

是否有可能有两个 awesome 实例,每个实例都启动程序,然后当笔记本电脑显示器停用时,程序会移动到外部显示器的 awesome 实例?有什么办法可以避免这种情况吗?

答案1

在很棒的 Wiki 中,有一个关于自动启动应用程序的页面。还有一个示例代码可以强制应用程序仅运行一次,请参阅http://awesome.naquadah.org/wiki/Autostart

相关内容