Improve powerline-lemonbar documentation
Changes: - Usage determination transferred back to argparse (it wraps). - Added complete description of lemonbar script to wm-widgets.rst. - --interval and --height got their arguments clarified by metavar: it was not clear what units they use. - --bar-command got its metavar because it is better then default BAR_COMMAND. - --bar-command short variant is now -C.
This commit is contained in:
parent
8168ad1428
commit
646b0ea5ea
|
@ -73,6 +73,12 @@ Running the binding in i3-mode will require `i3ipc <https://github.com/acrisci/i
|
|||
See the `lemonbar documentation <https://github.com/LemonBoy/bar>`_ for more
|
||||
information and options.
|
||||
|
||||
All ``powerline-lemonbar.py`` arguments:
|
||||
|
||||
.. automan:: powerline.commands.lemonbar
|
||||
:prog: powerline-lemonbar.py
|
||||
:minimal: true
|
||||
|
||||
I3 bar
|
||||
======
|
||||
|
||||
|
|
|
@ -7,39 +7,14 @@ import re
|
|||
import subprocess
|
||||
|
||||
from threading import Lock, Timer
|
||||
from argparse import ArgumentParser, REMAINDER
|
||||
|
||||
from powerline.lemonbar import LemonbarPowerline
|
||||
from powerline.lib.shell import run_cmd
|
||||
from powerline.commands.lemonbar import get_argparser
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = ArgumentParser(
|
||||
description='Powerline BAR bindings.',
|
||||
usage='%(prog)s [-h] [--i3] [--height HEIGHT] [--interval INTERVAL] [--bar-command CMD] -- args'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--i3', action='store_true',
|
||||
help='Subscribe for i3 events.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--height', default='',
|
||||
help='Bar height.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--interval', '-i',
|
||||
type=float, default=0.5,
|
||||
help='Refresh interval.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--bar-command', '-c',
|
||||
default='lemonbar',
|
||||
help='Name of the lemonbar executable to use.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'args', nargs=REMAINDER,
|
||||
help='Extra arguments for lemonbar.'
|
||||
)
|
||||
parser = get_argparser()
|
||||
args = parser.parse_args()
|
||||
|
||||
powerline = LemonbarPowerline()
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
# vim:fileencoding=utf-8:noet
|
||||
# WARNING: using unicode_literals causes errors in argparse
|
||||
from __future__ import (division, absolute_import, print_function)
|
||||
|
||||
import argparse
|
||||
|
||||
|
||||
def get_argparser(ArgumentParser=argparse.ArgumentParser):
|
||||
parser = ArgumentParser(
|
||||
description='Powerline BAR bindings.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--i3', action='store_true',
|
||||
help='Subscribe for i3 events.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--height', default='',
|
||||
metavar='PIXELS', help='Bar height.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--interval', '-i',
|
||||
type=float, default=0.5,
|
||||
metavar='SECONDS', help='Refresh interval.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'--bar-command', '-C',
|
||||
default='lemonbar',
|
||||
metavar='CMD', help='Name of the lemonbar executable to use.'
|
||||
)
|
||||
parser.add_argument(
|
||||
'args', nargs=argparse.REMAINDER,
|
||||
help='Extra arguments for lemonbar. Should be preceded with ``--`` '
|
||||
'argument in order not to be confused with script own arguments.'
|
||||
)
|
||||
return parser
|
|
@ -117,7 +117,7 @@ if ! test -e "$LEMONBAR_SCRIPT" ; then
|
|||
:
|
||||
else
|
||||
enter_suite "lemonbar"
|
||||
for args in "" "-i0.5" "--interval=0.5" "-- test args" "-c bar-aint-recursive" "--height=10"; do
|
||||
for args in "" "-i0.5" "--interval=0.5" "-- test args" "--bar-command bar-aint-recursive" "--height=10"; do
|
||||
rm -rf "$TEST_ROOT/results"
|
||||
run python "$LEMONBAR_SCRIPT" $args > "$TEST_ROOT/lemonbar.log" 2>&1 &
|
||||
SPID=$!
|
||||
|
@ -158,8 +158,8 @@ else
|
|||
height="${height%% *}"
|
||||
fi
|
||||
command="lemonbar"
|
||||
if test "x${args#-c}" != "x$args" ; then
|
||||
command="${args#-c}"
|
||||
if test "x${args#--bar-command}" != "x$args" ; then
|
||||
command="${args#--bar-command}"
|
||||
command="${command# }"
|
||||
command="${command#=}"
|
||||
command="${command%% *}"
|
||||
|
|
Loading…
Reference in New Issue