Skip to content

Default X screen / screen selection #24

@mkoskar

Description

@mkoskar

Now there is an option -screens that translates into variable screen_mask and is used like this:

  unsigned long screen_mask = ~0;
  for (/* global */ screen = 0; screen < ScreenCount(display); screen++) {
    if ((screen_mask & (1 << screen)) == 0)
      continue;

So if I would like to operate on a single screen say 0, I would have to pass -screens 1, for 1 it would be -screens 2, for 2 it would be -screens 4 etc.

Moreover (and this is my use case), it's impossible to operate on default (preferred in XCB lingo) screen, i.e., if DISPLAY=:1.1 I would like hsetroot just to manipulate root window of X screen 1.

I have hardcoded following quick & dirty solution to do so:

diff --git a/hsetroot.c b/hsetroot.c
index 79e5c7b..4c23393 100644
--- a/hsetroot.c
+++ b/hsetroot.c
@@ -284,9 +284,15 @@ main(int argc, char **argv)
     outputs = XineramaQueryScreens(display, &noutputs);
   }
 
+  int screen_def = DefaultScreen(display);
+  printf("screen_def = %d\n", screen_def);
+
   for (/* global */ screen = 0; screen < ScreenCount(display); screen++) {
-    if ((screen_mask & (1 << screen)) == 0)
-      continue;
+    //if ((screen_mask & (1 << screen)) == 0)
+    //  continue;
+
+    if (screen != screen_def)
+        continue;
 
     Imlib_Context *context = imlib_context_new();
     imlib_context_push(context);

Because I feel like operating on multiple X screens might be useful for somebody I would suggest leaving -screens be and creating new option e.g., -screen <int>, which would take a preference before -screens and specify single X screen to work on, or -1 for the DefaultScreen(display).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions