summaryrefslogtreecommitdiff
path: root/src/leap
diff options
context:
space:
mode:
authorRuben Pollan <meskio@sindominio.net>2018-03-27 19:12:39 +0200
committerKali Kaneko <kali@leap.se>2018-03-28 23:51:28 +0200
commit8462f36cdb9dbab00d5025ac6d7e4f8581951340 (patch)
tree846db6dcea3ae1e312a1cd9fd49b48fbcf39c2bd /src/leap
parent65ae3b5349eb02f938c3987a1e91d2641b0f94bc (diff)
[feat] make autostart app name and exec path configurable
Use sys.argv[0] as exec path instead of hardcode 'bitmask', and let anonvpn be called RiseupVPN. - Resolves: bitmask-systray#19
Diffstat (limited to 'src/leap')
-rw-r--r--src/leap/bitmask/chrome/chromeapp.py4
-rw-r--r--src/leap/bitmask/core/autostart.py61
-rw-r--r--src/leap/bitmask/core/flags.py2
-rw-r--r--src/leap/bitmask/core/launcher.py5
-rw-r--r--src/leap/bitmask/gui/anonvpn.py5
-rw-r--r--src/leap/bitmask/gui/app.py4
-rw-r--r--src/leap/bitmask/gui/app2.py4
7 files changed, 63 insertions, 22 deletions
diff --git a/src/leap/bitmask/chrome/chromeapp.py b/src/leap/bitmask/chrome/chromeapp.py
index b1de0990..b6769804 100644
--- a/src/leap/bitmask/chrome/chromeapp.py
+++ b/src/leap/bitmask/chrome/chromeapp.py
@@ -64,7 +64,9 @@ def start_app():
print('[!] Cannot find chromium installed in the system!')
sys.exit(1)
delete_old_authtoken()
- bitmaskd = Process(target=run_bitmaskd)
+ bitmaskd = Process(target=run_bitmaskd,
+ kwargs={'app_name': 'Bitmask',
+ 'exec_path': sys.argv[0]})
bitmaskd.start()
cmd = 'chromium -app=%s' % get_url()
diff --git a/src/leap/bitmask/core/autostart.py b/src/leap/bitmask/core/autostart.py
index 1c361d82..c53b8197 100644
--- a/src/leap/bitmask/core/autostart.py
+++ b/src/leap/bitmask/core/autostart.py
@@ -1,19 +1,37 @@
+# -*- coding: utf-8 -*-
+# autostart.py
+# Copyright (C) 2018 LEAP
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Autostart bitmask on user login
+"""
import os
import os.path
from leap.bitmask.system import IS_LINUX, IS_MAC
-from leap.bitmask.util import STANDALONE
from leap.common.config import get_path_prefix
+from leap.bitmask.core import flags
if IS_LINUX:
AUTOSTART = r"""[Desktop Entry]
-Name=Bitmask
+Name=%(name)s
Type=Application
-Exec=bitmask
+Exec=%(exec)s
+Path=%(path)s
Terminal=false
"""
- config = get_path_prefix(standalone=False)
- autostart_file = os.path.join(config, 'autostart', 'bitmask.desktop')
def autostart_app(status):
"""
@@ -26,18 +44,27 @@ Terminal=false
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':
- try:
- os.unlink(autostart_file)
- except OSError:
- pass
+ if not flags.APP_NAME or not flags.EXEC_PATH:
+ return
+
+ config = get_path_prefix(standalone=False)
+ autostart_file = os.path.join(config, 'autostart',
+ '%s.desktop' % flags.APP_NAME)
+ 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 % {
+ 'name': flags.APP_NAME,
+ 'exec': flags.EXEC_PATH,
+ 'path': os.getcwd()
+ })
+ elif status == 'off':
+ try:
+ os.unlink(autostart_file)
+ except OSError:
+ pass
if IS_MAC:
diff --git a/src/leap/bitmask/core/flags.py b/src/leap/bitmask/core/flags.py
index 12905d3d..9547df02 100644
--- a/src/leap/bitmask/core/flags.py
+++ b/src/leap/bitmask/core/flags.py
@@ -1,2 +1,4 @@
BACKEND = 'default'
VERBOSE = False
+APP_NAME = None
+EXEC_PATH = None
diff --git a/src/leap/bitmask/core/launcher.py b/src/leap/bitmask/core/launcher.py
index 14d8e607..b1d5dabd 100644
--- a/src/leap/bitmask/core/launcher.py
+++ b/src/leap/bitmask/core/launcher.py
@@ -44,7 +44,7 @@ def here(module=None):
return dirname(__file__)
-def run_bitmaskd():
+def run_bitmaskd(app_name=None, exec_path=None):
# TODO --- configure where to put the logs... (get --logfile, --logdir
# from bitmaskctl
@@ -55,6 +55,9 @@ def run_bitmaskd():
flags.VERBOSE = True
if STANDALONE:
flags.VERBOSE = True
+ flags.APP_NAME = app_name
+ flags.EXEC_PATH = exec_path
+
args = [
'-y', join(here(core), "bitmaskd.tac"),
'--logfile', getLogPath(),
diff --git a/src/leap/bitmask/gui/anonvpn.py b/src/leap/bitmask/gui/anonvpn.py
index 51aefc2b..4269459c 100644
--- a/src/leap/bitmask/gui/anonvpn.py
+++ b/src/leap/bitmask/gui/anonvpn.py
@@ -22,6 +22,7 @@ Launches bitmaskd and then launches the systray.
"""
import subprocess
+import sys
import os
from multiprocessing import Process
@@ -60,7 +61,9 @@ def start_app():
global bitmaskd
check_stale_pidfile()
- bitmaskd = Process(target=run_bitmaskd)
+ bitmaskd = Process(target=run_bitmaskd,
+ kwargs={'app_name': 'RiseupVPN',
+ 'exec_path': sys.argv[0]})
bitmaskd.start()
reset_authtoken()
launch_gui()
diff --git a/src/leap/bitmask/gui/app.py b/src/leap/bitmask/gui/app.py
index 70c0051f..02600420 100644
--- a/src/leap/bitmask/gui/app.py
+++ b/src/leap/bitmask/gui/app.py
@@ -197,7 +197,9 @@ def _handle_kill(*args, **kw):
def launch_backend():
global bitmaskd
check_stale_pidfile()
- bitmaskd = Process(target=run_bitmaskd)
+ bitmaskd = Process(target=run_bitmaskd,
+ kwargs={'app_name': 'Bitmask',
+ 'exec_path': sys.argv[0]})
bitmaskd.start()
diff --git a/src/leap/bitmask/gui/app2.py b/src/leap/bitmask/gui/app2.py
index 5ec76b7b..8eadf1b4 100644
--- a/src/leap/bitmask/gui/app2.py
+++ b/src/leap/bitmask/gui/app2.py
@@ -118,7 +118,9 @@ def launch_backend():
global bitmaskd
check_stale_pidfile()
- bitmaskd = Process(target=run_bitmaskd)
+ bitmaskd = Process(target=run_bitmaskd,
+ kwargs={'app_name': 'Bitmask',
+ 'exec_path': sys.argv[0]})
bitmaskd.start()