2024-04-30 14:51:36 +00:00
|
|
|
Define this function in your config.py
|
|
|
|
|
|
|
|
```
|
|
|
|
import os
|
2024-04-30 15:19:15 +00:00
|
|
|
import traceback
|
|
|
|
from qutebrowser.utils import debug, log
|
|
|
|
|
2024-04-30 14:51:36 +00:00
|
|
|
sCONFIG_DIR = config.configdir
|
|
|
|
def config_load_configs(lArgs: list|None = None, sDir: str = sCONFIG_DIR) -> None:
|
|
|
|
i = 0
|
|
|
|
if not lArgs: return i
|
|
|
|
for foo in lArgs:
|
|
|
|
sFile = os.path.join(sDir, 'configs', foo)
|
|
|
|
for bar in sFile, sFile+'.py':
|
|
|
|
if not os.path.exists(bar): continue
|
|
|
|
try:
|
|
|
|
# ResourceWarning: unclosed file
|
|
|
|
oFd = open(bar, 'rt')
|
|
|
|
sCode = oFd.read()
|
|
|
|
oFd.close()
|
|
|
|
exec(sCode)
|
|
|
|
except Exception as e:
|
|
|
|
log.init.warning(f'error execing {bar}\n{e}')
|
|
|
|
log.init.debug(traceback.print_exc())
|
|
|
|
else:
|
|
|
|
log.init.info(f'execed {bar}')
|
|
|
|
i = i + 1
|
|
|
|
return i
|
|
|
|
```
|
|
|
|
Then make a list of configs you want to load:
|
|
|
|
```
|
|
|
|
lCONFIGS = ['chromium-flags',
|
|
|
|
'chrome-urls',
|
|
|
|
'privacy-settings',
|
|
|
|
'tab-manager',
|
|
|
|
'search-engines',
|
|
|
|
'user-agents',
|
|
|
|
'interceptor-cloudflare',
|
|
|
|
'interceptor-ytadds',
|
|
|
|
'init_custom_plugins',
|
|
|
|
'patch-qute3.1.0',
|
|
|
|
'atexit-cleanup',
|
|
|
|
]
|
|
|
|
```
|
|
|
|
Then load the configs:
|
|
|
|
```
|
|
|
|
i = config_load_configs(lCONFIGS)
|
|
|
|
log.init.info(f'loaded {i} configs')
|
|
|
|
```
|
2024-04-30 15:19:15 +00:00
|
|
|
|
|
|
|
I think that this should be a standard function and a standard habit
|
|
|
|
of loading code snippets from a directory like:
|
|
|
|
~/.config/qutebrowser/configs
|
|
|
|
|