From bb69e8a2bd6117ee432e7b9ced09f200d61926b7 Mon Sep 17 00:00:00 2001 From: Kali Kaneko Date: Wed, 17 Jan 2018 21:03:48 +0100 Subject: [feat] autostart application when user logs in --- src/leap/bitmask/vpn/autostart.py | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/leap/bitmask/vpn/autostart.py (limited to 'src/leap/bitmask/vpn/autostart.py') diff --git a/src/leap/bitmask/vpn/autostart.py b/src/leap/bitmask/vpn/autostart.py new file mode 100644 index 00000000..43abfdf5 --- /dev/null +++ b/src/leap/bitmask/vpn/autostart.py @@ -0,0 +1,45 @@ +import os +import os.path + +from leap.bitmask.vpn.constants import IS_LINUX, IS_MAC +from leap.bitmask.util import STANDALONE +from leap.common.config import get_path_prefix + +if IS_LINUX: + AUTOSTART = r"""[Desktop Entry] +Name=Bitmask +Type=Application +Exec=bitmask +Terminal=false +""" + config = get_path_prefix(standalone=False) + autostart_file = os.path.join(config, 'autostart', 'bitmask.desktop') + + def autostart_app(status): + """ + Leave an autostart file in the user's autostart path. + + The bundle could in principle find its own path and add + the path to the bitmaskd binary in the Exec entry. + But for now it's simpler to do autostart only for the debian packages + or any other method that puts bitmask in the path. + On the other hand, we want to reduce the modifications that the bundle + leaves behind. + """ + if not STANDALONE: + if status == 'on': + _dir = os.path.split(autostart_file)[0] + if not os.path.isdir(_dir): + os.makedirs(_dir) + with open(autostart_file, 'w') as f: + f.write(AUTOSTART) + elif status == 'off': + os.unlink(autostart_file) + +if IS_MAC: + + def autostart_app_on(): + pass + + def autostart_app_off(): + pass -- cgit v1.2.3