remove unnecessary key; set default value to 500

This commit is contained in:
piotr
2023-01-04 01:58:50 +01:00
parent 5c4e62c9fd
commit bbaf083e39
2 changed files with 6 additions and 20 deletions

View File

@@ -26,8 +26,7 @@ data_home = os.getenv('XDG_DATA_HOME') if os.getenv('XDG_DATA_HOME') else os.pat
cs_file = os.path.join(config_dir, "common-settings.json")
if not os.path.isfile(cs_file):
common_settings = {
"restart-on-displays": True,
"restart-delay": 0
"restart-delay": 500
}
save_json(common_settings, cs_file)
else:
@@ -237,7 +236,6 @@ def handle_keyboard(window, event):
def build_common_settings_window():
global common_settings
check_key(common_settings, "restart-on-displays", True)
check_key(common_settings, "restart-delay", 0)
win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
@@ -258,22 +256,16 @@ def build_common_settings_window():
grid.set_row_spacing(6)
grid.set_property("margin", 12)
cb = Gtk.CheckButton.new_with_label("Restart on output number changed")
cb.set_active(common_settings["restart-on-displays"])
cb.connect("toggled", on_restart_checkbutton)
grid.attach(cb, 0, 0, 3, 1)
lbl = Gtk.Label.new("Restart delay [ms]:")
lbl.set_property("halign", Gtk.Align.END)
grid.attach(lbl, 0, 1, 1, 1)
grid.attach(lbl, 0, 0, 1, 1)
sb = Gtk.SpinButton.new_with_range(0, 30000, 100)
sb.set_value(common_settings["restart-delay"])
sb.connect("value-changed", on_restart_delay_changed)
sb.set_tooltip_text("If, after turning a display off and back on, panels don't appear on it, it may mean\n"
"the display responds too slowly (e.g. if turned via HDMI). Try adding some delay.\n"
"Starting from 2000 ms may be a good idea.")
grid.attach(sb, 1, 1, 1, 1)
"the display responds too slowly (e.g. if turned via HDMI). Try increasing this value.")
grid.attach(sb, 1, 0, 1, 1)
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6)
vbox.pack_start(hbox, False, False, 6)
@@ -293,11 +285,6 @@ def build_common_settings_window():
return win
def on_restart_checkbutton(cb):
global common_settings
common_settings["restart-on-displays"] = cb.get_active()
def on_restart_delay_changed(sb):
global common_settings
common_settings["restart-delay"] = int(sb.get_value())

View File

@@ -114,7 +114,7 @@ def check_tree():
# Do if tree changed
if tree.ipc_data != common.ipc_data:
num = num_active_outputs()
if common_settings["restart-on-displays"] and num != common.outputs_num:
if num != common.outputs_num:
print("Number of active outputs changed: {}".format(num))
Gdk.threads_add_timeout(GLib.PRIORITY_DEFAULT_IDLE, common_settings["restart-delay"], restart)
@@ -346,8 +346,7 @@ def main():
cs_file = os.path.join(common.config_dir, "common-settings.json")
if not os.path.isfile(cs_file):
common_settings = {
"restart-on-displays": True,
"restart-delay": 0
"restart-delay": 500
}
save_json(common_settings, cs_file)
else: