mirror of
https://github.com/evilsocket/opensnitch.git
synced 2025-03-04 00:24:40 +01:00
ui, prefs: ignore SameFile error when enabling autostart
When clicking [x] Autostart the GUI upon login, ignore the exception if src and dst (opensnitch_ui.desktop) are the same file.
This commit is contained in:
parent
a21a316e34
commit
0c8935c6e8
1 changed files with 9 additions and 2 deletions
|
@ -63,6 +63,13 @@ class Autostart():
|
|||
self.systemAutostart = '/usr' + self.systemAutostart
|
||||
self.userAutostart = os.path.join(xdg_config_home, 'autostart', desktopFile)
|
||||
|
||||
def _copyfile(self, src, dst):
|
||||
"""copy file (.desktop) to dst. Ignore exception if src and dst are equal"""
|
||||
try:
|
||||
shutil.copyfile(src, dst)
|
||||
except shutil.SameFileError:
|
||||
pass
|
||||
|
||||
def createUserDir(self):
|
||||
if not os.path.isdir(xdg_config_home):
|
||||
os.makedirs(xdg_config_home, 0o700)
|
||||
|
@ -88,10 +95,10 @@ class Autostart():
|
|||
if os.path.isfile(self.systemAutostart) and os.path.isfile(self.userAutostart):
|
||||
os.remove(self.userAutostart)
|
||||
elif os.path.isfile(self.systemDesktop):
|
||||
shutil.copyfile(self.systemDesktop, self.userAutostart)
|
||||
self._copyfile(self.systemDesktop, self.userAutostart)
|
||||
else:
|
||||
if os.path.isfile(self.systemAutostart):
|
||||
shutil.copyfile(self.systemAutostart, self.userAutostart)
|
||||
self._copyfile(self.systemAutostart, self.userAutostart)
|
||||
with open(self.userAutostart, 'a') as f:
|
||||
f.write('Hidden=true\n')
|
||||
elif os.path.isfile(self.userAutostart):
|
||||
|
|
Loading…
Add table
Reference in a new issue