Browse Source

added flag --enabled to show enabled only

Fabian Peter Hammerle 7 years ago
parent
commit
1d2a7e3053
2 changed files with 16 additions and 2 deletions
  1. 4 0
      README.md
  2. 12 2
      scripts/xrandrl

+ 4 - 0
README.md

@@ -14,6 +14,10 @@ eDP2
 DP2-1
 DP2-2
 
+$ xrandrl --enabled 
+eDP2
+DP2-2
+
 $ xrandrl --connected --disabled
 DP2-1
 

+ 12 - 2
scripts/xrandrl

@@ -132,11 +132,16 @@ def get_xrandr_output_infos(xdisplay):
             for o in range(screen_resrcs.contents.noutput)]
 
 
-def process(connected, disabled):
+def get_xrandr_output_enabled(output_info):
+    return output_info.contents.crtc != 0
+
+
+def process(connected, disabled, enabled):
     xdisplay = X11.XOpenDisplay(None)
     for output_info in get_xrandr_output_infos(xdisplay):
         if ((not connected or output_info.contents.connection == RR_Connected)
-                and (not disabled or output_info.contents.crtc == 0)):
+                and (not disabled or not get_xrandr_output_enabled(output_info))
+                and (not enabled or get_xrandr_output_enabled(output_info))):
             output_name = output_info.contents.name \
                 .decode(sys.getfilesystemencoding())
             print(output_name)
@@ -156,6 +161,11 @@ def _init_argparser():
         action='store_true',
         help='disabled only (does not imply --connected)',
     )
+    argparser.add_argument(
+        '--enabled',
+        action='store_true',
+        help='enabled only (does not imply --connected)',
+    )
     return argparser