#!/bin/bash

# Minimal OS variable loading for performance
. /etc/profile.d/001-functions

(
  if [ "$(get_setting bluetooth.enabled)" == "1" ]
  then
    #tocon "Starting bluetooth..."
    if [ ! -e "/storage/.cache/services/bluez.conf" ]
    then
      cp -f /usr/share/services/bluez.conf /storage/.cache/services/bluez.conf
    fi
    nohup systemctl start bluetooth &
    nohup systemctl start bluetooth-agent &
    nohup systemctl start bluetoothsense &
    rfkill unblock bluetooth
  else
    rfkill block bluetooth
  fi
) &
