Ubuntu/Scripts/PulseAudio
From r00tedvw.com wiki
(Difference between revisions)
(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/$ | + | 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 02: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