0

I was having issues with pulseaudio and had to every time type in 'pulseaudio -D' in terminal each time I booted up. However, this was quite frustrating and so I was looking forward to make pulseaudio to startup each time at bootup by editing .bashrc

I added these lines at the end of the .bashrc file :

until [[ `ps aux | grep "pulseaudio -D" | grep -v grep | wc -l` -eq 1 ]]
do
    pulseaudio -D >/dev/null 2>&1
    if [[ `ps aux | grep "pulseaudio -D" | grep -v grep | wc -l` -gt 1 ]]
    then
        kill -9 `pidof pulseaudio`
        pulseaudio -D
    fi

https://pastebin.com/QC6LV50d

But since after that I have been getting the error of 'unexpected end of file' as enclosed in the Screenshot.

How can I solve it?

dessert
  • 39,392
  • 12
  • 115
  • 163
  • 4
    All you're missing is the `done` after `fi` to close the `do` loop. – Terrance Jan 03 '18 at 14:33
  • After adding done to it, each time I open a new terminal, I have to do ctrl+C to continue using the terminal. It's like as if a process is already running after adding the 'done' word in the end – Sarthak Thakur Jan 03 '18 at 15:41
  • 1
    Technically Kali is not supported here. So, this should be asked at https://unix.stackexchange.com/ Secondly, Kali was never intended to be installed as an everyday OS. See https://docs.kali.org/introduction/should-i-use-kali-linux That being said, The .bashrc is loaded every single time you launch a terminal window. This would be best to be dropped into a script that is called at start up and possibly put into a CRON job to run every so often. – Terrance Jan 03 '18 at 16:02
  • 2
    And now it aint about Kali anymore :) – Rinzwind Jan 03 '18 at 16:06

1 Answers1

4

Your do loop lacks ending with done. Compare

#!/bin/bash
for i in *; do
    echo "item: $i"
done
dessert
  • 39,392
  • 12
  • 115
  • 163
gonczor
  • 181
  • 9
  • 1
    FYI I changed `for i in $( ls )` because of [Bash Pitfall #1](https://mywiki.wooledge.org/BashPitfalls#for_i_in_.24.28ls_.2A.mp3.29) - I suggest you find a more reliable programming guide than the one you linked. – steeldriver Jan 03 '18 at 14:54
  • I'm OK with it, it was first I found and I don't do much bash scripting so any tips on good practice is welcome. – gonczor Jan 03 '18 at 14:55
  • After adding done to it, each time I open a new terminal, I have to do ctrl+C to continue using the terminal. It's like as if a process is already running after adding the 'done' word in the end – Sarthak Thakur Jan 03 '18 at 15:41
  • 2
    @gonczor [Why you shouldn't parse the output of `ls`](http://mywiki.wooledge.org/ParsingLs) – dessert Jan 03 '18 at 16:10