File: qtb

package info (click to toggle)
qtile 0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,004 kB
  • sloc: python: 49,959; ansic: 4,371; xml: 324; sh: 260; makefile: 218
file content (42 lines) | stat: -rwxr-xr-x 1,298 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env python3
"""
Command-line interaction with Qtile TextBox widgets.
"""

import sys
from argparse import ArgumentParser

from libqtile import command


def main():
    parser = ArgumentParser()
    parser.add_argument("--version", action="version", version="%(prog)s 0.2")
    parser.add_argument("-l", "--list", action="store_true", help="List addressable widgets")
    parser.add_argument(
        "-s", "--socket", type=str, default=None, help="Use specified communication socket"
    )
    # in order for the -l option to work, we can't require these args, so we
    # check for them later
    parser.add_argument("name", type=str, required=False, help="Name of widget to change")
    parser.add_argument("text", type=str, required=False, help="Text to to place in widget")

    args = parser.parse_args()

    client = command.Client(args.socket)

    if args.list:
        for i in client.list_widgets():
            print(i)
    else:
        if args.name is None or args.text is None:
            parser.error("Please specify widget name and argument.")
        try:
            client.widget.__getitem__(args.name).update(args.text)
        except command.CommandError as v:
            print(v, file=sys.stderr)
            sys.exit(1)


if __name__ == "__main__":
    main()