From 220064441ce09f126dd71bb66f6a759ed9100bce Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 14 Apr 2016 08:12:25 +0530 Subject: [PATCH] Add an environment variable (CALIBRE_NO_DEFAULT_PROGRAMS) to prevent calibre from automatically registering with the Open With subsystem on windows --- manual/customize.rst | 3 ++- src/calibre/utils/winreg/default_programs.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/manual/customize.rst b/manual/customize.rst index 2ad43e93e0..5dd361adab 100644 --- a/manual/customize.rst +++ b/manual/customize.rst @@ -30,10 +30,11 @@ Environment variables * ``CALIBRE_DEVELOP_FROM`` - Used to run from a calibre development environment. See :ref:`develop`. * ``CALIBRE_OVERRIDE_LANG`` - Used to force the language used by the interface (ISO 639 language code) * ``CALIBRE_TEST_TRANSLATION`` - Used to test a translation .po file (should be the path to the .po file) - * ``CALIBRE_NO_NATIVE_FILEDIALOGS`` - Causes calibre to not use native file dialogs for selecting files/directories. Set it to 1 to enable. + * ``CALIBRE_NO_NATIVE_FILEDIALOGS`` - Causes calibre to not use native file dialogs for selecting files/directories. * ``CALIBRE_NO_NATIVE_MENUBAR`` - Causes calibre to not create a native (global) menu on Ubuntu Unity and similar linux desktop environments. The menu is instead placed inside the window, as traditional. * ``CALIBRE_IGNORE_SYSTEM_THEME`` - Causes calibre to ignore any system Qt style plugins and use its builtin style plugin instead. Useful to workaround crashes caused by the system Qt plugin being incompatible with the version of Qt shipped with calibre. * ``CALIBRE_SHOW_DEPRECATION_WARNINGS`` - Causes calibre to print deprecation warnings to stdout. Useful for calibre developers. + * ``CALIBRE_NO_DEFAULT_PROGRAMS`` - Prevent calibre from automatically registering the filetypes it is capable of handling with windows. * ``SYSFS_PATH`` - Use if sysfs is mounted somewhere other than /sys * ``http_proxy`` - Used on linux to specify an HTTP proxy diff --git a/src/calibre/utils/winreg/default_programs.py b/src/calibre/utils/winreg/default_programs.py index 86ca25ec8a..076fa04fa7 100644 --- a/src/calibre/utils/winreg/default_programs.py +++ b/src/calibre/utils/winreg/default_programs.py @@ -69,6 +69,8 @@ def check_allowed(): raise NotAllowed('Not allowed to create associations for portable installs') if sys.getwindowsversion()[:2] < (6, 2): raise NotAllowed('Not allowed to create associations for windows versions older than Windows 8') + if b'CALIBRE_NO_DEFAULT_PROGRAMS' in os.environ: + raise NotAllowed('Disabled by the CALIBRE_NO_DEFAULT_PROGRAMS environment variable') def create_prog_id(ext, prog_id, ext_map, exe): with Key(r'Software\Classes\%s' % prog_id) as key: