From d75a9ee9d7d8ca6271390f9914ab1d4a51053be9 Mon Sep 17 00:00:00 2001 From: nicolargo Date: Sun, 10 Jan 2016 09:40:53 +0100 Subject: [PATCH] Add a new tag to disable the top menu (--disable-top and '5' shortcut) (issue #766) --- glances/main.py | 21 ++++++++++++++------- glances/outputs/glances_curses.py | 15 +++++++++++++++ glances/plugins/glances_quicklook.py | 1 + 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/glances/main.py b/glances/main.py index d06d83d6..8187a61e 100644 --- a/glances/main.py +++ b/glances/main.py @@ -128,9 +128,12 @@ Start the client browser (browser mode):\n\ dest='disable_raid', help='disable RAID module') parser.add_argument('--disable-docker', action='store_true', default=False, dest='disable_docker', help='disable Docker module') + parser.add_argument('-5', '--disable-top', action='store_true', + default=False, dest='disable_top', + help='disable top menu (QL, CPU, MEM, SWAP and LOAD)') parser.add_argument('-2', '--disable-left-sidebar', action='store_true', default=False, dest='disable_left_sidebar', - help='disable network, disk I/O, FS and sensors modules (py3sensors needed)') + help='disable network, disk I/O, FS and sensors modules') parser.add_argument('--disable-process', action='store_true', default=False, dest='disable_process', help='disable process module') parser.add_argument('--disable-log', action='store_true', default=False, @@ -276,17 +279,21 @@ Start the client browser (browser mode):\n\ # Manage full quicklook option if args.full_quicklook: + logger.info("Disable QuickLook menu") args.disable_quicklook = False args.disable_cpu = True args.disable_mem = True args.disable_swap = True args.disable_load = False - else: - args.disable_quicklook = False - args.disable_cpu = False - args.disable_mem = False - args.disable_swap = False - args.disable_load = False + + # Manage disable_top option + if args.disable_top: + logger.info("Disable top menu") + args.disable_quicklook = True + args.disable_cpu = True + args.disable_mem = True + args.disable_swap = True + args.disable_load = True # Control parameter and exit if it is not OK self.args = args diff --git a/glances/outputs/glances_curses.py b/glances/outputs/glances_curses.py index ecc44e11..314e845a 100644 --- a/glances/outputs/glances_curses.py +++ b/glances/outputs/glances_curses.py @@ -305,6 +305,21 @@ class _GlancesCurses(object): self.args.disable_cpu = False self.args.disable_mem = False self.args.disable_swap = False + elif self.pressedkey == ord('5'): + # '5' > Enable/disable top menu + self.args.disable_top = not self.args.disable_top + if self.args.disable_top: + self.args.disable_quicklook = False + self.args.disable_cpu = False + self.args.disable_mem = False + self.args.disable_swap = False + self.args.disable_load = False + else: + self.args.disable_quicklook = True + self.args.disable_cpu = True + self.args.disable_mem = True + self.args.disable_swap = True + self.args.disable_load = True elif self.pressedkey == ord('/'): # '/' > Switch between short/long name for processes self.args.process_short_name = not self.args.process_short_name diff --git a/glances/plugins/glances_quicklook.py b/glances/plugins/glances_quicklook.py index 6c7a56f9..5c9feca0 100644 --- a/glances/plugins/glances_quicklook.py +++ b/glances/plugins/glances_quicklook.py @@ -22,6 +22,7 @@ from glances.cpu_percent import cpu_percent from glances.outputs.glances_bars import Bar from glances.plugins.glances_plugin import GlancesPlugin +from glances.logger import logger import psutil