From ecc360dba9947f0e24ffdd55b58f926513bd530e Mon Sep 17 00:00:00 2001 From: Russell Schmidt Date: Wed, 2 Apr 2025 12:16:15 -0500 Subject: [PATCH 1/7] Color favorite/ignored nodes Show favorite nodes in color node_favorite (green by default) and ignored nodes in color node_favorite (red by default). Sort ignored nodes at the bottom of the node list. --- contact/ui/curses_ui.py | 16 +++++++++++++++- contact/ui/default_config.py | 12 +++++++++--- contact/utilities/utils.py | 7 +++++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/contact/ui/curses_ui.py b/contact/ui/curses_ui.py index 379a7f3..189f048 100644 --- a/contact/ui/curses_ui.py +++ b/contact/ui/curses_ui.py @@ -459,7 +459,12 @@ def draw_node_list(): node = globals.interface.nodesByNum[node_num] secure = 'user' in node and 'publicKey' in node['user'] and node['user']['publicKey'] node_str = f"{'🔐' if secure else '🔓'} {get_name_from_database(node_num, 'long')}".ljust(box_width - 2)[:box_width - 2] - nodes_pad.addstr(i, 1, node_str, get_color("node_list", reverse=globals.selected_node == i and globals.current_window == 2)) + color = "node_list" + if 'isFavorite' in node and node['isFavorite']: + color = "node_favorite" + if 'isIgnored' in node and node['isIgnored']: + color = "node_ignored" + nodes_pad.addstr(i, 1, node_str, get_color(color, reverse=globals.selected_node == i and globals.current_window == 2)) nodes_win.attrset(get_color("window_frame_selected") if globals.current_window == 2 else get_color("window_frame")) nodes_win.box() @@ -720,9 +725,18 @@ def refresh_pad(window): def highlight_line(highlight, window, line): pad = nodes_pad + color = get_color("node_list") select_len = nodes_win.getmaxyx()[1] - 2 + if window == 2: + node_num = globals.node_list[line] + node = globals.interface.nodesByNum[node_num] + if 'isFavorite' in node and node['isFavorite']: + color = get_color("node_favorite") + if 'isIgnored' in node and node['isIgnored']: + color = get_color("node_ignored") + if(window == 0): pad = channel_pad color = get_color("channel_selected" if (line == globals.selected_channel and highlight == False) else "channel_list") diff --git a/contact/ui/default_config.py b/contact/ui/default_config.py index 4b5d331..370f5f5 100644 --- a/contact/ui/default_config.py +++ b/contact/ui/default_config.py @@ -65,7 +65,9 @@ def initialize_config(): "settings_save": ["green", "black"], "settings_breadcrumbs": ["white", "black"], "settings_warning": ["red", "black"], - "settings_note": ["green", "black"] + "settings_note": ["green", "black"], + "node_favorite": ["green", "black"], + "node_ignored": ["red", "black"] } COLOR_CONFIG_LIGHT = { "default": ["black", "white"], @@ -89,7 +91,9 @@ def initialize_config(): "settings_save": ["green", "white"], "settings_breadcrumbs": ["black", "white"], "settings_warning": ["red", "white"], - "settings_note": ["green", "white"] + "settings_note": ["green", "white"], + "node_favorite": ["green", "white"], + "node_ignored": ["red", "white"] } COLOR_CONFIG_GREEN = { "default": ["green", "black"], @@ -115,7 +119,9 @@ def initialize_config(): "settings_save": ["green", "black"], "settings_breadcrumbs": ["green", "black"], "settings_warning": ["green", "black"], - "settings_note": ["green", "black"] + "settings_note": ["green", "black"], + "node_favorite": ["cyan", "white"], + "node_ignored": ["red", "white"] } default_config_variables = { "db_file_path": db_file_path, diff --git a/contact/utilities/utils.py b/contact/utilities/utils.py index ea8d4a4..1af8f35 100644 --- a/contact/utilities/utils.py +++ b/contact/utilities/utils.py @@ -47,8 +47,15 @@ def get_node_list(): return node['hopsAway'] if 'hopsAway' in node else 100 else: return node + sorted_nodes = sorted(globals.interface.nodes.values(), key = node_sort) + + # Move favorite nodes to the beginning sorted_nodes = sorted(sorted_nodes, key = lambda node: node['isFavorite'] if 'isFavorite' in node else False, reverse = True) + + # Move ignored nodes to the end + sorted_nodes = sorted(sorted_nodes, key = lambda node: node['isIgnored'] if 'isIgnored' in node else False) + node_list = [node['num'] for node in sorted_nodes if node['num'] != my_node_num] return [my_node_num] + node_list # Ensuring your node is always first return [] From da24902bd0bed17d0ca75987ae252650ae822b6b Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Wed, 2 Apr 2025 21:24:47 -0700 Subject: [PATCH 2/7] Add Authors --- pyproject.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 96d0301..1fed0ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,6 +4,12 @@ version = "1.3.1" description = "This Python curses client for Meshtastic is a terminal-based client designed to manage device settings, enable mesh chat communication, and handle configuration backups and restores." authors = [ {name = "Ben Lipsey",email = "ben@pdxlocations.com"}, + {name = "Russell Schmidt"}, + {name = "noon92"}, + {name = "vidplace7"}, + {name = "SpudGunMan"}, + {name = "Ian McEwen"}, + {name = "Nick Maloney"} ] license = "GPL-3.0-only" readme = "README.md" From 3674afc216e92216747b3dbcfbb6feac80b36265 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Wed, 2 Apr 2025 21:27:36 -0700 Subject: [PATCH 3/7] remove version from main --- contact/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/contact/__main__.py b/contact/__main__.py index 9b861bd..8752234 100644 --- a/contact/__main__.py +++ b/contact/__main__.py @@ -3,7 +3,6 @@ ''' Contact - A Console UI for Meshtastic by http://github.com/pdxlocations Powered by Meshtastic.org -V 1.2.2 Meshtastic® is a registered trademark of Meshtastic LLC. Meshtastic software components are released under various licenses, see GitHub for details. No warranty is provided - use at your own risk. ''' From 0288a1d190e4eb21fee3808615914b1d05a8a08b Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Wed, 2 Apr 2025 22:03:28 -0700 Subject: [PATCH 4/7] add settings flag --- .vscode/launch.json | 2 +- contact/__main__.py | 8 +++++++- contact/utilities/arg_parser.py | 9 +++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index fe2dc5b..d6dff23 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -7,7 +7,7 @@ "request": "launch", "cwd": "${workspaceFolder}", "module": "contact.__main__", - "args": [] + "args": ["-c"] } ] } diff --git a/contact/__main__.py b/contact/__main__.py index 8752234..20d2159 100644 --- a/contact/__main__.py +++ b/contact/__main__.py @@ -14,6 +14,7 @@ from pubsub import pub import sys import io import logging +import subprocess import traceback import threading @@ -41,7 +42,7 @@ if os.environ.get("COLORTERM") == "gnome-terminal": # Run `tail -f client.log` in another terminal to view live logging.basicConfig( filename=config.log_file_path, - level=logging.INFO, # DEBUG, INFO, WARNING, ERROR, CRITICAL) + level=logging.DEBUG, # DEBUG, INFO, WARNING, ERROR, CRITICAL) format="%(asctime)s - %(levelname)s - %(message)s" ) @@ -57,6 +58,11 @@ def main(stdscr): parser = setup_parser() args = parser.parse_args() + # Check if --settings was passed and run settings.py as a subprocess + if getattr(args, 'settings', False): + subprocess.run([sys.executable, "-m", "contact.settings"], check=True) + return + logging.info("Initializing interface %s", args) with globals.lock: globals.interface = initialize_interface(args) diff --git a/contact/utilities/arg_parser.py b/contact/utilities/arg_parser.py index 391dc0e..f017715 100644 --- a/contact/utilities/arg_parser.py +++ b/contact/utilities/arg_parser.py @@ -33,5 +33,14 @@ def setup_parser(): default=None, const="any" ) + parser.add_argument( + "--settings", + "--set", + "--control", + "-c", + help="Launch directly into the settings", + action="store_true" + ) + return parser \ No newline at end of file From db01d241c7f70277ad0b35414ea03b5c6209adba Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Wed, 2 Apr 2025 22:04:53 -0700 Subject: [PATCH 5/7] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1fed0ec..5bef0f8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "contact" -version = "1.3.1" +version = "1.3.2" description = "This Python curses client for Meshtastic is a terminal-based client designed to manage device settings, enable mesh chat communication, and handle configuration backups and restores." authors = [ {name = "Ben Lipsey",email = "ben@pdxlocations.com"}, From 890a3b6dc433f87477f394383a3f6a0a48a4bb19 Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Wed, 2 Apr 2025 22:12:32 -0700 Subject: [PATCH 6/7] cant add multiple authors? --- pyproject.toml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 5bef0f8..77019d2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,13 +3,7 @@ name = "contact" version = "1.3.2" description = "This Python curses client for Meshtastic is a terminal-based client designed to manage device settings, enable mesh chat communication, and handle configuration backups and restores." authors = [ - {name = "Ben Lipsey",email = "ben@pdxlocations.com"}, - {name = "Russell Schmidt"}, - {name = "noon92"}, - {name = "vidplace7"}, - {name = "SpudGunMan"}, - {name = "Ian McEwen"}, - {name = "Nick Maloney"} + {name = "Ben Lipsey",email = "ben@pdxlocations.com"} ] license = "GPL-3.0-only" readme = "README.md" From 5628758de0b42b247fb61904c4cee18ee0c2815c Mon Sep 17 00:00:00 2001 From: pdxlocations Date: Wed, 2 Apr 2025 22:14:24 -0700 Subject: [PATCH 7/7] add settings to readme --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f4e2ce9..45b463b 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ Optional arguments to specify a device to connect to and how. - `--port`, `--serial`, `-s`: The port to connect to via serial, e.g. `/dev/ttyUSB0`. - `--host`, `--tcp`, `-t`: The hostname or IP address to connect to using TCP, will default to localhost if no host is passed. - `--ble`, `-b`: The BLE device MAC address or name to connect to. +- `--settings`, `--set`, `--control`, `-c`: Launch directly into the settings. If no connection arguments are specified, the client will attempt a serial connection and then a TCP connection to localhost. @@ -61,4 +62,4 @@ contact --ble BlAddressOfDevice To quickly connect to localhost, use: ```sh contact -t -``` +``` \ No newline at end of file