def main() -> None: "Runs tool according to specified arguments." description = 'Simple tool to expose qtile.command functionality to shell.' epilog = textwrap.dedent('''\ Examples: qtile-cmd qtile-cmd -o cmd qtile-cmd -o cmd -f prev_layout -i qtile-cmd -o cmd -f prev_layout -a 3 # prev_layout on group 3 qtile-cmd -o group 3 -f focus_back''') fmt = argparse.RawDescriptionHelpFormatter parser = argparse.ArgumentParser(description=description, epilog=epilog, formatter_class=fmt) parser.add_argument('--object', '-o', dest='obj_spec', nargs='+', help='Specify path to object (space separated). ' 'If no --function flag display available commands. ' 'Use `cmd` to specify root command.') parser.add_argument('--function', '-f', default="help", help='Select function to execute.') parser.add_argument('--args', '-a', nargs='+', default=[], help='Set arguments supplied to function.') parser.add_argument( '--info', '-i', action='store_true', help= 'With both --object and --function args prints documentation for function.' ) parser.add_argument("--socket", "-s", help='Path of the Qtile IPC socket.') args = parser.parse_args() if args.obj_spec: sock_file = args.socket or find_sockfile() ipc_client = Client(sock_file) cmd_object = IPCCommandInterface(ipc_client) cmd_client = InteractiveCommandClient(cmd_object) obj = get_object(cmd_client, args.obj_spec) if args.function == "help": print_commands("-o " + " ".join(args.obj_spec), obj) elif args.info: print(get_formated_info(obj, args.function, args=True, short=False)) else: ret = run_function(obj, args.function, args.args) if ret is not None: pprint.pprint(ret) else: print_base_objects() sys.exit(1)
def __init__(self, command: CommandInterface = None, *, current_node: CommandGraphNode | None = None) -> None: """A client that resolves calls through the command object interface Exposes a similar API to the command graph, but performs resolution of objects. Any navigation done on the command graph is resolved at the point it is invoked. This command resolution is done via the command interface. Parameters ---------- command: CommandInterface The object that is used to resolve command graph calls, as well as navigate the command graph. current_node: CommandGraphNode The current node that is pointed to in the command graph. If not specified, the command graph root is used. """ if command is None: command = IPCCommandInterface(Client(find_sockfile())) self._command = command self._current_node = current_node if current_node is not None else CommandGraphRoot( )
def __init__(self, command: CommandInterface = None, *, current_node: GraphType = None) -> None: """An interactive client that resolves calls through the gives client Exposes the command graph API in such a way that it can be traversed directly on this object. The command resolution for this object is done via the command interface. Parameters ---------- command: CommandInterface The object that is used to resolve command graph calls, as well as navigate the command graph. current_node: CommandGraphNode The current node that is pointed to in the command graph. If not specified, the command graph root is used. """ if command is None: command = IPCCommandInterface(Client(find_sockfile())) self._command = command if current_node is None: self._current_node = CommandGraphRoot() # type: GraphType else: self._current_node = current_node
def cmd_obj(args) -> None: "Runs tool according to specified arguments." if args.obj_spec: sock_file = args.socket or find_sockfile() ipc_client = Client(sock_file) cmd_object = IPCCommandInterface(ipc_client) cmd_client = CommandClient(cmd_object) obj = get_object(cmd_client, args.obj_spec) if args.function == "help": try: print_commands("-o " + " ".join(args.obj_spec), obj) except CommandError: if len(args.obj_spec) == 1: print( f"{args.obj_spec} object needs a specified identifier e.g. '-o bar top'." ) sys.exit(1) else: raise elif args.info: print( args.function + get_formated_info(obj, args.function, args=True, short=False)) else: ret = run_function(obj, args.function, args.args) if ret is not None: pprint.pprint(ret) else: print_base_objects() sys.exit(1)
def cmd_obj(args) -> None: "Runs tool according to specified arguments." if args.obj_spec: sock_file = args.socket or find_sockfile() ipc_client = Client(sock_file) cmd_object = IPCCommandInterface(ipc_client) cmd_client = InteractiveCommandClient(cmd_object) obj = get_object(cmd_client, args.obj_spec) if args.function == "help": print_commands("-o " + " ".join(args.obj_spec), obj) elif args.info: print(get_formated_info(obj, args.function, args=True, short=False)) else: ret = run_function(obj, args.function, args.args) if ret is not None: pprint.pprint(ret) else: print_base_objects() sys.exit(1)
def qtile(self): if self._qtile is None and qtile_support is True: self._qtile = CommandClient( command=IPCCommandInterface(Client(find_sockfile()))) return self._qtile
# SOFTWARE. import nest_asyncio nest_asyncio.apply() from typing import List # noqa: F401 import os import sys import subprocess from libqtile.config import Key, Screen, Group, Drag, Click, Match from libqtile.lazy import lazy from libqtile import layout, hook, bar, widget from libqtile.ipc import find_sockfile, Client from libqtile.command_client import InteractiveCommandClient from libqtile.command_interface import IPCCommandInterface client = InteractiveCommandClient(IPCCommandInterface(Client(find_sockfile()))) from helper import run from controls import next_keyboard from apperance import widget_defaults, extension_defaults from apperance import top_bar, bottom_bar from debug_logging import logger # This has to be run this before screens are defined, so that it correctly picks up the order and resulotion # run("xrandr --output DVI-D-1 --mode 1600x1200 --left-of HDMI-2 --output HDMI-2 --mode 2560x1080 --output HDMI-1 --mode 1920x1080 --right-of HDMI-2") mod = "mod4" alt = 'mod1' username = "******" def bring_group_to_front(group_name):