diff options
author | Stuart Langridge <sil@kryogenix.org> | 2019-06-04 15:01:33 +0100 |
---|---|---|
committer | Stuart Langridge <sil@kryogenix.org> | 2019-06-04 15:01:33 +0100 |
commit | f410e2db92ba574c80d9bd2c60ee3c384f41dd43 (patch) | |
tree | 38fdec99d4dca1e2895652676546a2052e7c745d | |
parent | Make the code clean under flake8 (diff) | |
download | magnus-f410e2db92ba574c80d9bd2c60ee3c384f41dd43.tar.gz magnus-f410e2db92ba574c80d9bd2c60ee3c384f41dd43.tar.bz2 magnus-f410e2db92ba574c80d9bd2c60ee3c384f41dd43.zip |
Allow overriding refresh interval on command line
-rwxr-xr-x | magnus | 28 |
1 files changed, 25 insertions, 3 deletions
@@ -27,16 +27,38 @@ class Main(object): self.decorations_width = 0 self.last_x = -1 self.last_y = -1 + self.refresh_interval = 250 def handle_commandline(self, app, cmdline): + args = cmdline.get_arguments() if hasattr(self, "w"): # already started - if "--about" in cmdline.get_arguments(): + if "--about" in args: self.show_about_dialog() return 0 + + if "--help" in args: + print("Options:") + print(" --about") + print(" Show about dialogue") + print(" --refresh-interval=120") + print(" Set refresh interval in milliseconds (lower is faster)") + + # Override refresh rate on command line + for arg in args: + if arg.startswith("--refresh-interval="): + parts = arg.split("=") + if len(parts) == 2: + try: + rival = int(parts[1]) + print("Refresh interval set to {}ms".format(rival)) + self.refresh_interval = rival + except ValueError: + pass + # First time startup self.start_everything_first_time() - if "--about" in cmdline.get_arguments(): + if "--about" in args: self.show_about_dialog() return 0 @@ -85,7 +107,7 @@ class Main(object): GLib.timeout_add(250, self.read_window_size) # and, poll - GLib.timeout_add(250, self.poll) + GLib.timeout_add(self.refresh_interval, self.poll) GLib.idle_add(self.load_config) |