我想在我的X运行时立即启动自定义脚本。现在我使用以下脚本:
#!/bin/bash
# Wait until X server is running, indicated by a PID of XXX. Required only on first boot, not on resume.
X=$( pidof X )
while [ ${#X} != 3 ]
do
sleep 10
X=$( pidof X )
done
echo "Running autostart in 5 seconds..."
# Wait 5 seconds on resume before running.
sleep 5
# Do the rest...
这成功等待,直到X在首次启动时启动。但是,在恢复时X已经在运行并输出PID。尽管如此,我还是要等到恢复过程完全结束。现在我只能想到一段时间睡觉的解决方案。还有其他解决方案吗?