diff --git a/guake/data/org.guake.gschema.xml b/guake/data/org.guake.gschema.xml
index f6656fd93..15e6a2936 100644
--- a/guake/data/org.guake.gschema.xml
+++ b/guake/data/org.guake.gschema.xml
@@ -46,6 +46,11 @@
Automatically save tabs session when changed
If true, when tabs has changed (add / delete ...etc.), it will automatically saved the tabs session
+
+ true
+ Load settings from guake.yml
+ If true, when a change in the cwd is detected settings are changed based on the content of the file `cwd`/.guake.yml
+
false
Login shell
diff --git a/guake/data/prefs.glade b/guake/data/prefs.glade
index 2a34ee67d..952725106 100644
--- a/guake/data/prefs.glade
+++ b/guake/data/prefs.glade
@@ -271,7 +271,18 @@
-
+
+
+ 0
+ 3
+
diff --git a/guake/guake_app.py b/guake/guake_app.py
index c9012d736..893b54d7b 100644
--- a/guake/guake_app.py
+++ b/guake/guake_app.py
@@ -257,6 +257,10 @@ def window_event(*args):
Keybinder.init()
self.hotkeys = Keybinder
Keybindings(self)
+
+ # Hold a copy of guake_yaml
+ self._guake_yml = {}
+ self._guake_yml_load_monotonic = {}
self.load_config()
if self.settings.general.get_boolean("start-fullscreen"):
@@ -1105,18 +1109,32 @@ def recompute_tabs_titles(self):
def load_cwd_guake_yaml(self, vte) -> dict:
# Read the content of .guake.yml in cwd
+ if not self.settings.general.get_boolean("load-guake-yml"):
+ return {}
+
cwd = Path(vte.get_current_directory())
- guake_yaml = cwd.joinpath(".guake.yml")
+ guake_yml = cwd.joinpath(".guake.yml")
content = {}
- try:
- if guake_yaml.is_file():
- with guake_yaml.open(encoding="utf-8") as fd:
- content = yaml.safe_load(fd)
- except PermissionError:
- log.debug("PermissionError on accessing .guake.yml")
+
+ reload_guake_yml = True
+ if guake_yml in self._guake_yml_load_monotonic:
+ if pytime.monotonic() < self._guake_yml_load_monotonic[guake_yml] + 1.0:
+ reload_guake_yml = False
+
+ if not reload_guake_yml:
+ content = self._guake_yml.get(guake_yml, {})
+ else:
+ try:
+ if guake_yml.is_file():
+ with guake_yml.open(encoding="utf-8") as fd:
+ content = yaml.safe_load(fd)
+ self._guake_yml[guake_yml] = content
+ self._guake_yml_load_monotonic[guake_yml] = pytime.monotonic()
+ except PermissionError:
+ log.debug("PermissionError on accessing .guake.yml")
if not isinstance(content, dict):
- conent = {}
+ content = {}
return content
def compute_tab_title(self, vte):
diff --git a/guake/prefs.py b/guake/prefs.py
index f407395a5..c7515cbfd 100644
--- a/guake/prefs.py
+++ b/guake/prefs.py
@@ -251,6 +251,10 @@ def on_save_tabs_when_changed_toggled(self, chk):
"""Changes the activity of save-tabs-when-changed in dconf"""
self.settings.general.set_boolean("save-tabs-when-changed", chk.get_active())
+ def on_load_guake_yml_toggled(self, chk):
+ """Changes the activity of load-guake-yml"""
+ self.settings.general.set_boolean("load-guake-yml", chk.get_active())
+
def on_default_shell_changed(self, combo):
"""Changes the activity of default_shell in dconf"""
citer = combo.get_active_iter()
@@ -1012,6 +1016,10 @@ def load_configs(self):
value = self.settings.general.get_boolean("save-tabs-when-changed")
self.get_widget("save-tabs-when-changed").set_active(value)
+ # save tabs when changed
+ value = self.settings.general.get_boolean("load-guake-yml")
+ self.get_widget("load-guake-yml").set_active(value)
+
# login shell
value = self.settings.general.get_boolean("use-login-shell")
self.get_widget("use_login_shell").set_active(value)