Skip to content

Instantly share code, notes, and snippets.

@vereist
Created September 27, 2017 02:25
Show Gist options
  • Save vereist/f660bbe81002b25f4fd72b466ecb640c to your computer and use it in GitHub Desktop.
Save vereist/f660bbe81002b25f4fd72b466ecb640c to your computer and use it in GitHub Desktop.
Headphone jack detection fails on Braswell / Realtek ALC5645 #318 headphone workaround script
#!bin/sh
# User Settings
# < whoami >
username="jackiechan"
# < id > will return the uid to put here
uid="1000"
# Device Settings
# < pacmd list | grep "name: <.*>" > for sink lists
alsaDevice="alsa_output.platform-cht-bsw-rt5645.HiFi__hw_chtrt5650__sink"
# < pacmd list | grep -F "[Out]" > for output port lists
headphonePort="[Out] Headphones"
speakerPort="[Out] Speaker"
# Event Listener
event="$*"
case "$event" in
'jack/headphone HEADPHONE plug')
logger "jackdetect: handling $event"
XDG_RUNTIME_DIR=/run/user/$uid/ runuser -u $username -- pacmd set-sink-port $alsaDevice $headphonePort
;;
'jack/headphone HEADPHONE unplug')
logger "jackdetect: handling $event"
XDG_RUNTIME_DIR=/run/user/$uid/ runuser -u $username -- pacmd set-sink-port $alsaDevice $speakerPort
;;
*)
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment