Advertisement
Guest User

Untitled

a guest
Dec 28th, 2023
35
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.74 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # PipeWire launcher script for XDG compliant desktops on OpenRC.
  4. #
  5. # systemd users are very _STRONGLY_ advised to use the much
  6. # more reliable and predictable user units instead.
  7.  
  8. # WARNING: This script assumes being run inside XDG compliant session,
  9. # which means D-Bus session instance is expected to be correctly set up
  10. # prior to this script starting. If that is not true, things may break!
  11.  
  12. DATE_FORMAT='+%Y-%m-%dT%H:%M:%S%Z'
  13.  
  14. CONF="${XDG_CONFIG_HOME:-${HOME}/.config}/gentoo-pipewire-launcher.conf"
  15. if [ -f "${CONF}" ]
  16. then
  17. . "${CONF}"
  18. else
  19. GENTOO_PIPEWIRE_LOG='/dev/null'
  20. GENTOO_PIPEWIRE_PULSE_LOG='/dev/null'
  21. GENTOO_WIREPLUMBER_LOG='/dev/null'
  22. fi
  23. for L in \
  24. "${GENTOO_PIPEWIRE_LOG}" \
  25. "${GENTOO_PIPEWIRE_PULSE_LOG}" \
  26. "${GENTOO_WIREPLUMBER_LOG}"
  27. do
  28. if [ ! -e "${L}" ]
  29. then
  30. touch "${L}"
  31. fi
  32. done
  33.  
  34. restart () {
  35. echo "Terminating PipeWire processes ..."
  36. pkill -u "${USER}" -x pipewire\|wireplumber 1>/dev/null 2>&1
  37.  
  38. # pidwait was renamed to pwait w/ procps-4 (bug #914030)
  39. if command -v pidwait > /dev/null ; then
  40. pidwait -u "${USER}" -x pipewire\|wireplumber
  41. elif command -v pwait > /dev/null ; then
  42. pwait -u "${USER}" -x pipewire\|wireplumber
  43. fi
  44.  
  45. echo "PipeWire terminated."
  46. }
  47.  
  48. if [ "${#}" -gt 0 ]
  49. then
  50. if [ "${1}" = 'restart' ]
  51. then
  52. restart
  53. else
  54. echo "Unrecognised argument." >&2
  55. echo "Usage: gentoo-pipewire-launcher [restart]" >&2
  56. exit 1
  57. fi
  58. fi
  59.  
  60. if pgrep -u "${USER}" -x pipewire\|wireplumber 1>/dev/null 2>&1
  61. then
  62. echo "PipeWire already running, exiting." >&2
  63. echo "(Use 'gentoo-pipewire-launcher restart' to restart PipeWire and WirePlumber.)" >&2
  64. exit 1
  65. fi
  66.  
  67. # The core daemon which by itself does probably nothing.
  68. echo "[$(/bin/date ${DATE_FORMAT})] Starting PipeWire." 1>>"${GENTOO_PIPEWIRE_LOG}"
  69. /usr/bin/pipewire 1>>"${GENTOO_PIPEWIRE_LOG}" 2>&1 &
  70.  
  71. # The so called pipewire-pulse daemon used for PulseAudio compatibility.
  72. # Commenting this out will stop the PA proxying daemon from starting,
  73. # however ALSA (with pipewire-alsa), JACK (with jack-sdk) and PW API using
  74. # clients will still have access to audio and may end up clashing with
  75. # non-PW apps over HW control (most notably, /usr/bin/pulseaudio daemon).
  76. echo "[$(/bin/date ${DATE_FORMAT})] Starting PipeWire-Pulse." 1>>"${GENTOO_PIPEWIRE_PULSE_LOG}"
  77. /usr/bin/pipewire -c pipewire-pulse.conf 1>>"${GENTOO_PIPEWIRE_PULSE_LOG}" 2>&1 &
  78.  
  79. # Hack for bug #822498
  80. sleep 1
  81.  
  82. # Finally a session manager is required for PipeWire to do anything.
  83. echo "[$(/bin/date ${DATE_FORMAT})] Starting WirePlumber." 1>>"${GENTOO_WIREPLUMBER_LOG}"
  84. exec /usr/bin/wireplumber 1>>"${GENTOO_WIREPLUMBER_LOG}" 2>&1
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement