Ubuntu/Scripts/PulseAudio

From r00tedvw.com wiki
Jump to: navigation, search

Scripts | SSL Expire | PulseAudio

stupid dock. script to change audio back to bluetooth speakers after dock crashes and recovers, but fails to set audio back to bluetooth

#!/bin/bash
logfile=/var/log/bluetooth/log
btsinkname=bluez_sink.60_F4_3A_71_89_E0.a2dp_sink
function btcheck {
  logprefix=$(echo "$(date +%b" "%d" "%H":"%M":"%S) $(hostname) btcheck [$(echo $BASHPID)]:")
  if [[ $(cat /sys/class/bluetooth/hci0:256/power/control 2>&1 | grep -Ec "^auto") -eq 1 ]]; then
    echo "$logprefix connected" | tee -a $logfile
    userid=$(runuser -l username -c "id -u")
    runuser -l username -c "export XDG_RUNTIME_DIR=/run/user/$userid && pacmd set-default-sink $btsinkname 2>&1"
  else
    echo "$logprefix not connected" | tee -a $logfile
  fi
  sleep 2s
  btcheck
}

btcheck

Personal tools
Namespaces

Variants
Actions
Navigation
Mediawiki
Confluence
DevOps Tools
Open Source Products
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
MagicMirror
OwnCloud
Pivotal
osTicket
OTRS
phpBB
WordPress
VmWare ESXI 5.1
Crypto currencies
HTML
CSS
Python
Java Script
PHP
Raspberry Pi
Canvas LMS
Kaltura Media Server
Plex Media Server
MetaSploit
Zoneminder
ShinobiCE
Photoshop CS2
Fortinet
Uploaded
Certifications
General Info
Games
Meal Plans
NC Statutes
Politics
Volkswagen
Covid
NCDMV
Toolbox