From 423faea01a8525dc4660a6aeafcdbaf5516e6994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tuncay=20=C3=87OLAK?= Date: Mon, 13 Sep 2021 16:30:40 +0300 Subject: [PATCH] crate pulseaudio autostart file while opening user session on default_policy module --- src/base/command/command_runner.py | 1 + .../config-files/ahenk.pulseaudio.start.desktop | 10 ++++++++++ src/base/default_policy/default_policy.py | 16 +++++++++++++++- src/base/registration/registration.py | 2 +- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/base/default_policy/config-files/ahenk.pulseaudio.start.desktop diff --git a/src/base/command/command_runner.py b/src/base/command/command_runner.py index b801ac1..84c2f23 100644 --- a/src/base/command/command_runner.py +++ b/src/base/command/command_runner.py @@ -142,6 +142,7 @@ class CommandRunner(object): self.logger.info("Applying default policies for user {0}".format(Util.get_username())) self.default_policy.default_firefox_policy(Util.get_username()) self.default_policy.disable_update_package_notify(Util.get_username()) + self.default_policy.create_pulseaudio_autostart() # Default policy for users --->> STOP get_policy_message = self.message_manager.policy_request_msg(username) diff --git a/src/base/default_policy/config-files/ahenk.pulseaudio.start.desktop b/src/base/default_policy/config-files/ahenk.pulseaudio.start.desktop new file mode 100644 index 0000000..317ee1a --- /dev/null +++ b/src/base/default_policy/config-files/ahenk.pulseaudio.start.desktop @@ -0,0 +1,10 @@ +[Desktop Entry] +Name=sesbaslat +Comment=Start the PulseAudio Sound System +Exec=sh -c 'killall pulseaudio; sleep 3; pulseaudio --start' +Terminal=false +Type=Application +Categories= +GenericName= +X-GNOME-Autostart-Phase=Initialization +X-KDE-autostart-phase=1 \ No newline at end of file diff --git a/src/base/default_policy/default_policy.py b/src/base/default_policy/default_policy.py index e1c82fa..d8c0d60 100644 --- a/src/base/default_policy/default_policy.py +++ b/src/base/default_policy/default_policy.py @@ -134,4 +134,18 @@ class DefaultPolicy: new_element.attrib["value"] = app_name_for_blocking tree.write(fileName) else: - self.logger.info("'" + app_name_for_blocking + "' is already added to muted_applications tag.") \ No newline at end of file + self.logger.info("'" + app_name_for_blocking + "' is already added to muted_applications tag.") + + # create pulseaudio autostart file while user opening session + def create_pulseaudio_autostart(self): + pulseaudio_des_path = "/etc/xdg/autostart/ahenk.pulseaudio.start.desktop" + pulseaudio_src_path = "/usr/share/ahenk/base/default_policy/config-files/ahenk.pulseaudio.start.desktop" + pulseaudio_old_file = "/etc/xdg/autostart/ahenk.pulseaudio.desktop" + if Util.is_exist(pulseaudio_old_file): + Util.delete_file(pulseaudio_old_file) + + if not Util.is_exist(pulseaudio_des_path): + Util.copy_file(pulseaudio_src_path, pulseaudio_des_path) + self.logger.info("Copy pulseaudio autostart file") + else: + self.logger.info("Pulseaudio autostart file already exist") diff --git a/src/base/registration/registration.py b/src/base/registration/registration.py index d374c8f..fac14cc 100644 --- a/src/base/registration/registration.py +++ b/src/base/registration/registration.py @@ -151,7 +151,7 @@ class Registration: self.install_and_config_ad(reg_reply) self.change_permissions_for_local_users() - self.create_ahenk_pulseaudio_desktop_file() + # self.create_ahenk_pulseaudio_desktop_file() except Exception as e: self.logger.error('Registration error. Error Message: {0}.'.format(str(e)))