我正在尝试创建两个 .desktop 条目来启动 shell 脚本。
应执行 shell 脚本 fullLaunch.sh 和 tracepen.sh。这两个脚本在从终端启动时运行。
它们启动多个其他文件,包括 ros 启动文件和其他 shell 脚本。
tracepen.desktop 如下所示:
[Desktop Entry]
Type=Application
Exec=bash /home/qiaoyue/happyspace/src/fmp_robot_shellscripts/robot/tracepen.sh
Icon=/home/qiaoyue/happyspace/src/fmp_robot_shellscripts/icons/tracepen.png
Name=Trace Pen
Terminal=true
tracepen.sh:
#!/bin/bash
# Check if SteamVR is running
if pgrep -x "vrmonitor" > /dev/null
then
echo "SteamVR is running"
else
echo "SteamVR is not running, starting it now..."
xdg-open steam://rungameid/250820 & disown
echo "Waiting for SteamVR to start..."
# Wait for SteamVR to start
while ! pgrep -x "vrmonitor" > /dev/null
do
sleep 1
done
fi
echo "Starting up tracepen"
rosrun fmp_tracepen_node tracepen_node.py
行为:steam 已启动,但最后我没有打开运行 tracepen_node.py 的终端。直接使用 ./tracepen.sh 启动它就可以了。
fullLaunch.desktop(基本相同):
[Desktop Entry]
Type=Application
Exec=/home/qiaoyue/happyspace/src/fmp_robot_shellscripts/robot/fullLaunch.sh
Icon=/home/qiaoyue/happyspace/src/fmp_robot_shellscripts/icons/launch.png
Name=Robot
Terminal=true
fulLaunch.sh:
#!/bin/bash
wait_for_topic() {
TOPIC=$1
while true; do
if rostopic list | grep -q "$TOPIC"; then
break
else
sleep 0.5
fi
done
}
# Check if roscore is already running, if yes then kill it
if (rosnode list &> /dev/null); then
killall -9 roscore
killall -9 rosmaster
fi
# Start roscore in a new tab
nohup roscore &> /dev/null &
# Wait for roscore to start
while ! (rosnode list &> /dev/null); do
sleep 0.5
done
gnome-terminal -- bash -c "roslaunch fmp_launch trajServer.launch"
# Wait for move_group to start
wait_for_topic "/sequence_move_group"
gnome-terminal --tab -- bash -c "rosrun fmp_move_traj trajectory_server.py"
gnome-terminal --tab -- bash -c "rosrun fmp_move_traj pose_server.py"
gnome-terminal --tab -- bash -c "rviz -d $(rospack find fmp_move_traj)/rvizLaunch/realRobot.rviz"
gnome-terminal --tab -- bash -c "rosrun fmp_move_traj buttons.py"
gnome-terminal --tab -- bash -c "rosrun fmp_move_traj poseModifier.py"
.desktop 启动两个终端,其中一个出现错误并立即终止。
答案1
如果您希望弹出终端,则需要自行启动它,然后在该终端中运行命令。尝试替换:
rosrun fmp_tracepen_node tracepen_node.py
类似于
gnome-terminal -x rosrun fmp_tracepen_node tracepen_node.py