The entirety of my Openbox autostart file is as follows:

# Compositor
picom &

# Korean input
ibus-daemon -dr &

# Screensaver
xscreensaver -no-splash &

# Wallpaper
while true; do
    nitrogen --random --set-auto
    sleep 3600

But when I login, it appears as though only picom was run successfully.

Running bash ~/.config/openbox/autostart from a terminal indicates

/home/max/.config/openbox/autostart: line 33: syntax error: unexpected end of file

so I think something is wrong with my while loop, but what?


1 Answer 1


In bash like in the Bourne shell where that syntax initially comes from, while loops end with done:

# Wallpaper
while true; do
    nitrogen --random --set-auto
    sleep 3600

What's happening is that the shell is finding the start of the while loop and then reads ahead, searching for its end. It reaches the end of the file before finding the terminating done keyword and complains. Hence "unexpected end of file".

  • That does it. Thank you.
    – Max
    May 31 at 22:47
  • 2
    @Max please see: unix.stackexchange.com/help/someone-answers you can also accept an answer if it's ok for you.
    – thanasisp
    May 31 at 22:56
  • It is customary to wait 24 hours to accept an answer in order to encourage people from various time zones to respond
    – Max
    May 31 at 23:23
  • @Max There is no such custom, but it's perfectly fine to accept one answer first and then change one's mind and accept another.
    – Kusalananda
    Jun 1 at 5:19
  • FWIW and for completeness, end is used to terminate while loops in csh, tcsh and fish. zsh has short forms that don't require the do and done, reminiscent of rc's while (cond) cmd's ones. Jun 1 at 6:59

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