remove unnecessary key; set default value to 500
This commit is contained in:
@@ -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")
|
cs_file = os.path.join(config_dir, "common-settings.json")
|
||||||
if not os.path.isfile(cs_file):
|
if not os.path.isfile(cs_file):
|
||||||
common_settings = {
|
common_settings = {
|
||||||
"restart-on-displays": True,
|
"restart-delay": 500
|
||||||
"restart-delay": 0
|
|
||||||
}
|
}
|
||||||
save_json(common_settings, cs_file)
|
save_json(common_settings, cs_file)
|
||||||
else:
|
else:
|
||||||
@@ -237,7 +236,6 @@ def handle_keyboard(window, event):
|
|||||||
|
|
||||||
def build_common_settings_window():
|
def build_common_settings_window():
|
||||||
global common_settings
|
global common_settings
|
||||||
check_key(common_settings, "restart-on-displays", True)
|
|
||||||
check_key(common_settings, "restart-delay", 0)
|
check_key(common_settings, "restart-delay", 0)
|
||||||
|
|
||||||
win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
|
win = Gtk.Window.new(Gtk.WindowType.TOPLEVEL)
|
||||||
@@ -258,22 +256,16 @@ def build_common_settings_window():
|
|||||||
grid.set_row_spacing(6)
|
grid.set_row_spacing(6)
|
||||||
grid.set_property("margin", 12)
|
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 = Gtk.Label.new("Restart delay [ms]:")
|
||||||
lbl.set_property("halign", Gtk.Align.END)
|
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 = Gtk.SpinButton.new_with_range(0, 30000, 100)
|
||||||
sb.set_value(common_settings["restart-delay"])
|
sb.set_value(common_settings["restart-delay"])
|
||||||
sb.connect("value-changed", on_restart_delay_changed)
|
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"
|
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"
|
"the display responds too slowly (e.g. if turned via HDMI). Try increasing this value.")
|
||||||
"Starting from 2000 ms may be a good idea.")
|
grid.attach(sb, 1, 0, 1, 1)
|
||||||
grid.attach(sb, 1, 1, 1, 1)
|
|
||||||
|
|
||||||
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6)
|
hbox = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 6)
|
||||||
vbox.pack_start(hbox, False, False, 6)
|
vbox.pack_start(hbox, False, False, 6)
|
||||||
@@ -293,11 +285,6 @@ def build_common_settings_window():
|
|||||||
return win
|
return win
|
||||||
|
|
||||||
|
|
||||||
def on_restart_checkbutton(cb):
|
|
||||||
global common_settings
|
|
||||||
common_settings["restart-on-displays"] = cb.get_active()
|
|
||||||
|
|
||||||
|
|
||||||
def on_restart_delay_changed(sb):
|
def on_restart_delay_changed(sb):
|
||||||
global common_settings
|
global common_settings
|
||||||
common_settings["restart-delay"] = int(sb.get_value())
|
common_settings["restart-delay"] = int(sb.get_value())
|
||||||
|
@@ -114,7 +114,7 @@ def check_tree():
|
|||||||
# Do if tree changed
|
# Do if tree changed
|
||||||
if tree.ipc_data != common.ipc_data:
|
if tree.ipc_data != common.ipc_data:
|
||||||
num = num_active_outputs()
|
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))
|
print("Number of active outputs changed: {}".format(num))
|
||||||
Gdk.threads_add_timeout(GLib.PRIORITY_DEFAULT_IDLE, common_settings["restart-delay"], restart)
|
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")
|
cs_file = os.path.join(common.config_dir, "common-settings.json")
|
||||||
if not os.path.isfile(cs_file):
|
if not os.path.isfile(cs_file):
|
||||||
common_settings = {
|
common_settings = {
|
||||||
"restart-on-displays": True,
|
"restart-delay": 500
|
||||||
"restart-delay": 0
|
|
||||||
}
|
}
|
||||||
save_json(common_settings, cs_file)
|
save_json(common_settings, cs_file)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user