Notification_Settings = 2
"""
give 1 to Allow sites to show desktop notifications
give 2 to Don't allow any site to show desktop notifications
give 3 to Ask every time a site wants to show desktop notifications
"""

import os
from subprocess import PIPE, Popen
import ctypes

class disable_file_system_redirection:
    _disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
    _revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
    def __enter__(self):
        self.old_value = ctypes.c_long()
        self.success = self._disable(ctypes.byref(self.old_value))
    def __exit__(self, type, value, traceback):
        if self.success:
            self._revert(self.old_value)

def ecmd(command,msg):   
    from subprocess import Popen, PIPE
    import ctypes
    
    with disable_file_system_redirection():
        obj = Popen(command, shell = True, stdout = PIPE, stderr = PIPE)
    out, err = obj.communicate()
    ret=obj.returncode
    if ret==0:
        if out:
            print(out)
        print(msg)
        print(ret)
    else:
        if err:
            print(err)
        else:
            print("something went wrong while executing command")
            print("return code: %s"%(ret))

if Notification_Settings==1:
    msg = "successfully set Microsoft Edge to Allow sites to show desktop notifications"
    ecmd('reg add "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Edge" /v DefaultNotificationsSetting /t REG_DWORD /d 1 /f',msg)
elif Notification_Settings==2:
    msg = "successfully set Microsoft Edge to Don't allow any site to show desktop notifications"
    ecmd('reg add "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Edge" /v DefaultNotificationsSetting /t REG_DWORD /d 2 /f',msg)
elif Notification_Settings==3:
    msg = "successfully set Microsoft Edge to Ask every time a site wants to show desktop notifications"
    ecmd('reg add "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Edge" /v DefaultNotificationsSetting /t REG_DWORD /d 3 /f',msg)