control: add toggle-logging

This commit is contained in:
FlightlessMango 2022-01-19 05:29:36 +01:00
parent d734fa1b66
commit d4ca1050ec
2 changed files with 11 additions and 7 deletions

View File

@ -170,22 +170,20 @@ def control(args):
info += "Mesa Version: {}" info += "Mesa Version: {}"
print(info.format(version, name, mesa_version)) print(info.format(version, name, mesa_version))
if args.cmd == 'start-capture':
conn.send(bytearray(':capture=1;', 'utf-8')) if args.cmd == 'toggle-logging':
elif args.cmd == 'stop-capture': conn.send(bytearray(':logging;', 'utf-8'))
conn.send(bytearray(':capture=0;', 'utf-8'))
elif args.cmd == 'toggle-hud': elif args.cmd == 'toggle-hud':
conn.send(bytearray(':hud;', 'utf-8')) conn.send(bytearray(':hud;', 'utf-8'))
def main(): def main():
parser = argparse.ArgumentParser(description='MESA_overlay control client') parser = argparse.ArgumentParser(description='MangoHud control client')
parser.add_argument('--info', action='store_true', help='Print info from socket') parser.add_argument('--info', action='store_true', help='Print info from socket')
parser.add_argument('--socket', '-s', type=str, help='Path to socket') parser.add_argument('--socket', '-s', type=str, help='Path to socket')
commands = parser.add_subparsers(help='commands to run', dest='cmd') commands = parser.add_subparsers(help='commands to run', dest='cmd')
commands.add_parser('start-capture')
commands.add_parser('stop-capture')
commands.add_parser('toggle-hud') commands.add_parser('toggle-hud')
commands.add_parser('toggle-logging')
args = parser.parse_args() args = parser.parse_args()

View File

@ -12,6 +12,12 @@ static void parse_command(struct instance_data *instance_data,
if (!strncmp(cmd, "hud", cmdlen)) { if (!strncmp(cmd, "hud", cmdlen)) {
_params->no_display = !_params->no_display; _params->no_display = !_params->no_display;
} }
if (!strncmp(cmd, "logging", cmdlen)) {
if (logger->is_active())
logger->stop_logging();
else
logger->start_logging();
}
} }
#define BUFSIZE 4096 #define BUFSIZE 4096