Ubuntu/Scripts/PulseAudio

From r00tedvw.com wiki
(Difference between revisions)
Jump to: navigation, search
(Created page with "Scripts | SSL Expire | PulseAudio stupid dock. script to change audio back to bluetooth speake...")
 
 
Line 11: Line 11:
 
   if [[ $(cat /sys/class/bluetooth/hci0:256/power/control 2>&1 | grep -Ec "^auto") -eq 1 ]]; then
 
   if [[ $(cat /sys/class/bluetooth/hci0:256/power/control 2>&1 | grep -Ec "^auto") -eq 1 ]]; then
 
     echo "$logprefix connected" | tee -a $logfile
 
     echo "$logprefix connected" | tee -a $logfile
     runuser -l username -c "export XDG_RUNTIME_DIR=/run/user/$(id -u) && pacmd set-default-sink $btsinkname 2>&1"
+
    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
 
   else
 
     echo "$logprefix not connected" | tee -a $logfile
 
     echo "$logprefix not connected" | tee -a $logfile

Latest revision as of 03:34, 14 January 2022

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
Ubuntu
Ubuntu 22
Mac OSX
Oracle Linux
AWS
Windows
OpenVPN
Grafana
InfluxDB2
TrueNas
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
2020 Election
Volkswagen
Covid
NCDMV
Toolbox