0

I have a startup script that opens some programs in each workspace. I want to do some things in the first workspace before it continues opening the programs in the next workspaces. How can I prompt to continue? I've tried using gnome-terminal -e "bash -c \"read -s -p 'Press enter to continue...'\"" but it doesn't stop, the script continues executing even though I haven't used & to move the process to background.

wmctrl -n 2
sleep 2
wmctrl -s 0
sleep 1
if command -v "firefox" > /dev/null 2>&1; then
    firefox  &
fi
gnome-terminal -e "bash -c \"read -n1 -sp 'Press enter to continue...'\""
# sleep 30
wmctrl -s 1
sleep 1
if command -v "firefox" > /dev/null 2>&1; then
    firefox --new-window &
fi
3
  • 1
    Why not make that prompt in the terminal that is already running that script? Or do you want a dialog box of some sort to appear anywhere?
    – thrig
    Apr 7 '17 at 14:53
  • It doesn't appear when the script is executed as a startup application so I have to find an alternative.
    – ajr-dev
    Apr 7 '17 at 15:05
  • Is your staturtup script running as your user? because if it's running as root you have no control over it whatsoever while running
    – Dalvenjia
    Apr 7 '17 at 17:01
1

I have no idea about the gnome-terminal, but if I start my xfce4-terminal from an already running terminal, it immediately forks itself into a standalone process, such that control can be returned to the calling shell, i.e. the previous shell will accept new commands while the new one is running as well.

I believe the gnome-terminal behaves the same way, which is why your script doesn't seem to stop-and-wait.

You could use the standard xterm instead, which does not fork itself and thus blocks the calling script. It doesn't look as pretty, but it'll do as a simple block-alert.

You may also have a look at gxmessage, xmessage or zenity.

1
  • It works perfectly with xterm -e "bash -c \"read -n1 -sp 'Press enter to continue...'\"". I tried the rest of options and they all work too. You could add the command to complete the answer. if command -v "zenity" > /dev/null 2>&1; then zenity --question --text "Open workspaces" if [ $? = 1 ]; then exit fi else echo "Install zenity" fi
    – ajr-dev
    Apr 8 '17 at 8:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.