From 95ac72d3050ada53419222b9ce79a545f3eb13ee Mon Sep 17 00:00:00 2001 From: Tobias Witek Date: Fri, 14 Feb 2020 21:54:06 +0100 Subject: [PATCH] [core] Add bumblebee-ctl to trigger remote commands see #547 --- bumblebee-ctl | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100755 bumblebee-ctl diff --git a/bumblebee-ctl b/bumblebee-ctl new file mode 100755 index 0000000..e08d45c --- /dev/null +++ b/bumblebee-ctl @@ -0,0 +1,37 @@ +#!/usr/bin/env python + +import argparse +import json +import glob +import socket + +button = { + 'left-mouse': 1, + 'middle-mouse': 2, + 'right-mouse': 3, + 'wheel-up': 4, + 'wheel-down': 5, +} + +def main(): + parser = argparse.ArgumentParser(description='send commands to bumblebee-status') + parser.add_argument('-b', '--button', choices=['left-mouse', 'right-mouse', 'middle-mouse', 'wheel-up', 'wheel-down'], help='button to emulate', default='left-mouse') + parser.add_argument('-i', '--id', help='ID of widget to trigger', required=True) + parser.add_argument('-n', '--name', help='name of the module to trigger', required=True) + + args = parser.parse_args() + + for f in glob.glob('/tmp/.bumblebee-status.*'): + print('accessing {}'.format(f)) + s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + s.connect(f) + s.sendall(json.dumps({ + 'name': args.name, + 'instance': args.id, + 'button': button[args.button], + }).encode('ascii')) + +if __name__ == "__main__": + main() + +# vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4