Botspot / youtubuddy

Search/Watch/Download YouTube videos with a lightweight, interactive tool
GNU General Public License v3.0
36 stars 10 forks source link

Change /home/pi to ${HOME} #17

Closed Jai-JAP closed 3 years ago

Botspot commented 3 years ago

Have you tested this? :)

Itai-Nelken commented 3 years ago

I'm pretty sure this won't work because bash isn't expanding that variable anywhere. the correct way to do it (in my opinion) is to write that file the first time the gui script runs maybe using pi-apps's runonce function.

Botspot commented 3 years ago

I've added this code to the gui script's check() function, in order to solve this issue:

  #if username is different (not /home/pi), but dl-location contains /home/pi, delete the file to regenerate it in the subsequent 'if' statement
  if [ -f "${DIRECTORY}/data/options/dl-location" ] && [ "$HOME" != '/home/pi' ] && cat "${DIRECTORY}/data/options/dl-location" | grep -q '/home/pi';then
    rm -f "${DIRECTORY}/data/options/dl-location"
  fi

  #regenerate dl-location to use the current home directory
  if [ ! -f "${DIRECTORY}/data/options/dl-location" ];then
    echo "$HOME/Downloads" > "${DIRECTORY}/data/options/dl-location"
  fi

Hopefully it's self-explanatory, but anyone is welcome to ask questions about it.