Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfaf8f23

Browse files
authored
Merge pull request#157 from Dusk-afk/feat/env-file
feat(config): add support for environment file loading
2 parents7af3314 +914bf20 commitfaf8f23

File tree

5 files changed

+27
-1
lines changed

5 files changed

+27
-1
lines changed

‎docs/Configuration.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ All valid options for the widgets are listed on the widgets page.
1616
|`watch_config`| boolean|`true`| Reload bar when config is changed.|
1717
|`debug`| boolean|`false`| Enable debug mode to see more logs|
1818
|`hide_taskbar`| boolean|`false`| Hide Windows taskbar from all screens. Note: for better performance set taskbar auto-hide.|
19+
|`env_file`| string|`None`| Load environment variables from file.|
1920

2021

2122
##Komorebi settings for tray menu

‎requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ requests
1717
obs-websocket-py
1818
pyvda
1919
win11toast
20+
python-dotenv
2021
git+https://github.com/amnweb/screen_brightness_control.git

‎src/core/config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ def get_stylesheet(show_error_dialog=False) -> Union[str, None]:
126126
logging.error(f"The file '{styles_path}' could not be read. Do you have read/write permissions?")
127127
returnNone
128128

129+
defget_resolved_env_file_path(env_file:str)->str:
130+
ifpath.isabs(env_file):
131+
returnenv_file
132+
133+
config_path=get_config_path()
134+
config_dir=path.dirname(config_path)
135+
env_file_path=path.join(config_dir,env_file)
136+
137+
returnenv_file_path
129138

130139
defget_config_and_stylesheet()->tuple[dict,str]:
131140
config=get_config()

‎src/core/validation/config.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@
1414
'default':False,
1515
'required':False,
1616
},
17+
'env_file': {
18+
'type':'string',
19+
'nullable':True,
20+
'required':False,
21+
'default':None,
22+
},
1723
'hide_taskbar': {
1824
'type':'boolean',
1925
'default':False,

‎src/main.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
importqasync
66
fromPyQt6.QtWidgetsimportQApplication
77
fromcore.bar_managerimportBarManager
8-
fromcore.configimportget_config_and_stylesheet
8+
fromcore.configimportget_config_and_stylesheet,get_resolved_env_file_path
99
fromcore.logimportinit_logger
1010
fromcore.trayimportTrayIcon
1111
fromcore.watcherimportcreate_observer
@@ -14,6 +14,7 @@
1414
importctypes
1515
importctypes.wintypes
1616
fromcore.utils.win32.windowsimportWindowsTaskbar
17+
fromdotenvimportload_dotenv
1718

1819
logging.getLogger('asyncio').setLevel(logging.WARNING)
1920

@@ -28,6 +29,14 @@ def main():
2829
app=QApplication(argv)
2930
app.setQuitOnLastWindowClosed(False)
3031

32+
env_file=config.get('env_file')
33+
ifenv_file:
34+
env_file=get_resolved_env_file_path(env_file)
35+
ifload_dotenv(env_file):
36+
logging.info(f"Loaded environment variables from{env_file}")
37+
else:
38+
logging.warning(f"Failed to load environment variables from{env_file}")
39+
3140
# Need qasync event loop to make async calls work properly with PyQt6
3241
loop=qasync.QEventLoop(app)
3342
asyncio.set_event_loop(loop)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp