From 86af425cff12da4d1e53d9688e1130f7981648de Mon Sep 17 00:00:00 2001
From: Alan Coopersmith <[email protected]>
Date: Tue, 29 Dec 2015 16:13:34 -0800
Subject: [PATCH 08/19] audio-settings-restore
Bug 15424062/SUNBT6606096 volume control preferences don't remain after reboot
Original date:2010-02-15 owner:yippi type:feature bugster:6606096
Includes followup fix for:
Bug 18899731 - GDM: permissions for .audioctl and audioctl device file are
not set as expected.
Original date:2014-07-11 owner:abhijit type:bug bugdb:18899731
---
data/PostSession.in | 26 ++++++++++++++++++++++++++
data/Xsession.in | 24 ++++++++++++++++++++++++
2 files changed, 50 insertions(+)
diff --git a/data/PostSession.in b/data/PostSession.in
index c52d3c2..83e23d1 100755
--- a/data/PostSession.in
+++ b/data/PostSession.in
@@ -1,3 +1,29 @@
#!/bin/sh
+PATH="@SCRIPT_PATH@"
+
+AUDIOCTL_SAVE_HOSTNAME=`/usr/bin/hostname`
+AUDIOCTL_SAVE_DIR="$HOME/.audioctl"
+AUDIOCTL_SAVE_DEVICE=""
+AUDIOCTL_DEVICE_OWNER=`/usr/bin/stat -L /dev/audio -c %U`
+
+# Only set audio settings if logindevperm has set the owner of the audio device
+# to this user.
+#
+if test "x$USER" = "x$AUDIOCTL_DEVICE_OWNER" ; then
+ if test -x "/usr/bin/audioctl" ; then
+ AUDIOCTL_SAVE_DEVICE=`/usr/bin/audioctl show-device | /usr/bin/awk '/^ *Name /{ print $3; }'`
+ fi
+
+ if test -n "$AUDIOCTL_SAVE_HOSTNAME" -a -n "$AUDIOCTL_SAVE_DEVICE"; then
+ if test ! -d "$AUDIOCTL_SAVE_DIR" ; then
+ /usr/bin/su "$USER" -c "/usr/bin/mkdir $AUDIOCTL_SAVE_DIR; /usr/bin/chmod 700 $AUDIOCTL_SAVE_DIR"
+ fi
+
+ if test -d "$AUDIOCTL_SAVE_DIR" ; then
+ AUDIOCTL_SAVE_FILE="$AUDIOCTL_SAVE_DIR/audioctl-$AUDIOCTL_SAVE_HOSTNAME-$AUDIOCTL_SAVE_DEVICE"
+ /usr/bin/su "$USER" -c "/usr/bin/audioctl save-controls -f $AUDIOCTL_SAVE_FILE; /usr/bin/chmod 600 $AUDIOCTL_SAVE_FILE"
+ fi
+ fi
+fi
exit 0
diff --git a/data/Xsession.in b/data/Xsession.in
index f253375..fda4b16 100755
--- a/data/Xsession.in
+++ b/data/Xsession.in
@@ -70,6 +70,30 @@ gdmwhich () {
echo "$OUTPUT"
}
+# Reload audio settings after sourcing the user's .profile to ensure that any
+# AUDIODEV settings defined by the user are honored.
+#
+AUDIOCTL_SAVE_HOSTNAME=`/usr/bin/hostname`
+AUDIOCTL_SAVE_DEVICE=""
+AUDIOCTL_SAVE_DIR="$HOME/.audioctl"
+AUDIOCTL_DEVICE_OWNER=`/usr/bin/stat -L /dev/audio -c %U`
+
+# Only set audio settings if logindevperm has set the owner of the audio
+# device to this user.
+#
+if test "x$USER" = "x$AUDIOCTL_DEVICE_OWNER" ; then
+ if test -x "/usr/bin/audioctl" ; then
+ AUDIOCTL_SAVE_DEVICE=`/usr/bin/audioctl show-device | /usr/bin/awk '/^ *Name /{ print $3; }'`
+ fi
+
+ if test -n "$AUDIOCTL_SAVE_HOSTNAME" -a -n "$AUDIOCTL_SAVE_DEVICE"; then
+ AUDIOCTL_SAVE_FILE="$AUDIOCTL_SAVE_DIR/audioctl-$AUDIOCTL_SAVE_HOSTNAME-$AUDIOCTL_SAVE_DEVICE"
+ if test -f "$AUDIOCTL_SAVE_FILE" ; then
+ /usr/bin/audioctl load-controls $AUDIOCTL_SAVE_FILE
+ fi
+ fi
+fi
+
zenity=`gdmwhich zenity`
# Note: ~/.xsession-errors is now done in the daemon so that it
--
2.7.4