Browse Source

added flag --quiet/silent

Fabian Peter Hammerle 7 năm trước cách đây
mục cha
commit
6d851a1b94
2 tập tin đã thay đổi với 12 bổ sung2 xóa
  1. 4 0
      README.md
  2. 8 2
      scripts/xrandrl

+ 4 - 0
README.md

@@ -29,6 +29,7 @@ optional arguments:
   -e, --enabled    enabled only (does not imply --connected)
   -b, --backlight  outputs with backlight configurable via randr only
   -B, --no-backlight  outputs without backlight configurable via randr only
+  -q, --quiet, --silent  do not print names of outputs
   -h, --help       show help message and exit
 ```
 
@@ -57,6 +58,9 @@ DP2-2
 $ xrandrl --disabled --backlight || echo none
 none
 
+$ xrandrl --enabled --backlight --quiet && echo found
+found
+
 $ xrandrl
 eDP2
 DP1

+ 8 - 2
scripts/xrandrl

@@ -196,7 +196,7 @@ class RandrOutputInfo:
             return False
 
 
-def process(connected, disabled, enabled, backlight, no_backlight):
+def process(connected, disabled, enabled, backlight, no_backlight, quiet):
     xdisplay = X11.XOpenDisplay(None)
     screen_resrcs = RandrScreenResources(
         xdisplay,
@@ -210,7 +210,8 @@ def process(connected, disabled, enabled, backlight, no_backlight):
                 and (not backlight or output_info.has_backlight())
                 and (not no_backlight or not output_info.has_backlight())):
             found = True
-            print(output_info.name)
+            if not quiet:
+                print(output_info.name)
     X11.XCloseDisplay(xdisplay)
     return found
 
@@ -247,6 +248,11 @@ def _init_argparser():
         action='store_true',
         help='outputs without backlight configurable via randr only',
     )
+    argparser.add_argument(
+        '-q', '--quiet', '--silent',
+        action='store_true',
+        help='do not print names of outputs',
+    )
     return argparser