@@ -63,6 +63,13 @@ def __init__(self):
63
63
self .systemAutostart = '/usr' + self .systemAutostart
64
64
self .userAutostart = os .path .join (xdg_config_home , 'autostart' , desktopFile )
65
65
66
+ def _copyfile (self , src , dst ):
67
+ """copy file (.desktop) to dst. Ignore exception if src and dst are equal"""
68
+ try :
69
+ shutil .copyfile (src , dst )
70
+ except shutil .SameFileError :
71
+ pass
72
+
66
73
def createUserDir (self ):
67
74
if not os .path .isdir (xdg_config_home ):
68
75
os .makedirs (xdg_config_home , 0o700 )
@@ -88,10 +95,10 @@ def enable(self, mode=True):
88
95
if os .path .isfile (self .systemAutostart ) and os .path .isfile (self .userAutostart ):
89
96
os .remove (self .userAutostart )
90
97
elif os .path .isfile (self .systemDesktop ):
91
- shutil . copyfile (self .systemDesktop , self .userAutostart )
98
+ self . _copyfile (self .systemDesktop , self .userAutostart )
92
99
else :
93
100
if os .path .isfile (self .systemAutostart ):
94
- shutil . copyfile (self .systemAutostart , self .userAutostart )
101
+ self . _copyfile (self .systemAutostart , self .userAutostart )
95
102
with open (self .userAutostart , 'a' ) as f :
96
103
f .write ('Hidden=true\n ' )
97
104
elif os .path .isfile (self .userAutostart ):
0 commit comments