53 lines
3.2 KiB
Bash
53 lines
3.2 KiB
Bash
# Pontiac G5 Pi AUX Unit (i dont know wtf to name this thing)
|
|
clear
|
|
cat <<EOF
|
|
██╗ ██╗██████╗ ████████╗██╗ ██╗██╗ ██╗███████╗ ██████╗ ███████╗██╗ ██╗███████╗██╗ ██████╗ ██████╗ ███╗ ███╗███████╗███╗ ██╗████████╗
|
|
██║ ██╔╝╚════██╗╚══██╔══╝╚██╗██╔╝╚██╗ ██╔╝╚══███╔╝ ██╔══██╗██╔════╝██║ ██║██╔════╝██║ ██╔═══██╗██╔══██╗████╗ ████║██╔════╝████╗ ██║╚══██╔══╝
|
|
█████╔╝ █████╔╝ ██║ ╚███╔╝ ╚████╔╝ ███╔╝ ██║ ██║█████╗ ██║ ██║█████╗ ██║ ██║ ██║██████╔╝██╔████╔██║█████╗ ██╔██╗ ██║ ██║
|
|
██╔═██╗ ╚═══██╗ ██║ ██╔██╗ ╚██╔╝ ███╔╝ ██║ ██║██╔══╝ ╚██╗ ██╔╝██╔══╝ ██║ ██║ ██║██╔═══╝ ██║╚██╔╝██║██╔══╝ ██║╚██╗██║ ██║
|
|
██║ ██╗██████╔╝ ██║██╗██╔╝ ██╗ ██║ ███████╗ ██████╔╝███████╗ ╚████╔╝ ███████╗███████╗╚██████╔╝██║ ██║ ╚═╝ ██║███████╗██║ ╚████║ ██║
|
|
╚═╝ ╚═╝╚═════╝ ╚═╝╚═╝╚═╝ ╚═╝ ╚═╝ ╚══════╝ ╚═════╝ ╚══════╝ ╚═══╝ ╚══════╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
|
EOF
|
|
|
|
# Functions
|
|
logger() {
|
|
local message="$*"
|
|
local timestamp=$(date '+%b %e %H:%M:%S') # e.g., Mar 8 14:35:22
|
|
local hostname=$(hostname)
|
|
local pid=$$ # PID of the current script
|
|
echo "$timestamp g5pi[$pid]: $message"
|
|
}
|
|
|
|
# bluetooth network loop
|
|
netloop() {
|
|
# Exit if already locked
|
|
[[ -e /tmp/netloop ]] && return 0
|
|
touch /tmp/netloop
|
|
|
|
while :; do
|
|
# Check if "Pixel 6a Network" is active
|
|
if ! nmcli -t -f NAME connection show --active | grep -qx "Pixel 6a Network"; then
|
|
#echo "Connecting to Pixel 6a Network..."
|
|
nmcli connection up "Pixel 6a Network"
|
|
fi
|
|
sleep 5
|
|
done
|
|
}
|
|
echo "$(date) [g5pi] starting up.."
|
|
journalctl -f &
|
|
# bump up that aux to the highest it can be
|
|
pactl set-sink-volume alsa_output.platform-fe00b840.mailbox.stereo-fallback 100%
|
|
|
|
# Bluetooth preparation
|
|
bluetoothctl <<EOF
|
|
power on
|
|
agent NoInputNoOutput
|
|
default-agent
|
|
system-alias "Pontiac G5"
|
|
discoverable on
|
|
pairable on
|
|
EOF
|
|
|
|
netloop &
|
|
tail
|