From 78044da52194ee0604a02659b58063e666de9c9c Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Tue, 11 Mar 2008 15:20:06 +0000 Subject: (is_user_switching_enabled,set_user_switching,switch) add support to enable/disable user switching (#37826) --- perl-install/NEWS | 1 + perl-install/harddrake/sound.pm | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'perl-install') diff --git a/perl-install/NEWS b/perl-install/NEWS index 357dd05bb..c2ef64662 100644 --- a/perl-install/NEWS +++ b/perl-install/NEWS @@ -2,6 +2,7 @@ o really fix partition device name for some dmraid (missing "p", cf #38363) - draksound (#37826): o add support to enable/disable PulseAudio + o add support to enable/disable user switching - cpufreq: fix gsx-suspmod probe - scannerdrake: fix to open usbtable.gz instead of usbtable diff --git a/perl-install/harddrake/sound.pm b/perl-install/harddrake/sound.pm index c210f76ae..12d0879fd 100644 --- a/perl-install/harddrake/sound.pm +++ b/perl-install/harddrake/sound.pm @@ -183,6 +183,25 @@ my $blacklisted = 0; my $config_file = '/etc/sysconfig/pulseaudio'; +sub is_user_switching_enabled() { + my $output = run_program::get_stdout('polkit-action', '--action', + 'org.freedesktop.hal.device-access.sound'); + my ($val) = $output =~ /default_inactive: (.*)/; + to_bool($val eq 'no'); +} + +sub set_user_switching { + my ($val) = @_; + if ($val) { + run_program::get_stdout('polkit-action', '--reset-defaults', + 'org.freedesktop.hal.device-access.sound'); + } else { + run_program::get_stdout('polkit-action', '--set-defaults-inactive', + 'org.freedesktop.hal.device-access.sound', 'yes'); + } +} + + sub is_pulseaudio_enabled() { my %h = getVarsFromSh($config_file); $h{PULSE_SERVER_TYPE} eq 'personal'; @@ -256,6 +275,7 @@ sub switch { my %des = modules::category2modules_and_description('multimedia/sound'); my $is_pulseaudio_enabled = is_pulseaudio_enabled(); + my $is_user_switching = is_user_switching_enabled(); my @common = ( get_any_driver_entry($in, $modules_conf, $driver, $device), @@ -263,6 +283,10 @@ sub switch { text => N("Enable PulseAudio"), type => 'bool', val => \$is_pulseaudio_enabled, }, + { + text => N("Enable user switching for audio applications"), + type => 'bool', val => \$is_user_switching, + }, ); if ($new_driver eq 'unknown') { @@ -274,6 +298,7 @@ sub switch { \@common, )) { set_pulseaudio($is_pulseaudio_enabled); + set_user_switching($is_user_switching); } } elsif ($in->ask_from_({ title => N("Sound configuration"), messages => @@ -315,6 +340,7 @@ To use alsa, one can either use: ])) { set_pulseaudio($is_pulseaudio_enabled); + set_user_switching($is_user_switching); return if $new_driver eq $device->{current_driver}; log::explanations("switching audio driver from '" . $device->{current_driver} . "' to '$new_driver'\n"); $in->ask_warn(N("Warning"), N("The old \"%s\" driver is blacklisted.\n -- cgit v1.2.1