def _write_key_to_root_file_linux(self, key_hex: str) -> None:
        """
        Spawns a pkexec subprocess to write the key to a file with root permissions.
        This will open an OS dialog asking for the root password. Can only succeed if
        the system has polkit installed.
        """
        assert os.path.exists("/etc"), "System does not have /etc directory"

        sh_command: str = self._posix_plugin_key_creation_command(key_hex)
        commands = ['pkexec', 'sh', '-c', sh_command]
        self._execute_commands_in_subprocess(commands)

        # check if the key was written correctly
        with open(self.keyfile_posix, 'r') as f:
            assert f.read() == key_hex, f'file content mismatch: {f.read()} != {key_hex}'
        self.logger.debug(f'file saved successfully to {self.keyfile_posix}')

        Spawns a pkexec subprocess to write the key to a file with root permissions.
        This will open an OS dialog asking for the root password. Can only succeed if
        the system has polkit installed.
        
electrum/plugin.py