My dmenu build
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

117 lines
3.5 KiB

  1. From 7dc7cb96cdda9ad66e33109223c4cc297a7721d1 Mon Sep 17 00:00:00 2001
  2. From: Alex Cole <ajzcole@airmail.cc>
  3. Date: Tue, 6 Oct 2020 10:42:07 +1300
  4. Subject: [PATCH] Updated xyw for 5.0 properly
  5. ---
  6. dmenu.1 | 24 ++++++++++++++++++++++++
  7. dmenu.c | 22 ++++++++++++++++------
  8. 2 files changed, 40 insertions(+), 6 deletions(-)
  9. diff --git a/dmenu.1 b/dmenu.1
  10. index 323f93c..a4ecbbb 100644
  11. --- a/dmenu.1
  12. +++ b/dmenu.1
  13. @@ -8,6 +8,12 @@ dmenu \- dynamic menu
  14. .IR lines ]
  15. .RB [ \-m
  16. .IR monitor ]
  17. +.RB [ \-x
  18. +.IR xoffset ]
  19. +.RB [ \-y
  20. +.IR yoffset ]
  21. +.RB [ \-z
  22. +.IR width ]
  23. .RB [ \-p
  24. .IR prompt ]
  25. .RB [ \-fn
  26. @@ -54,6 +60,24 @@ dmenu lists items vertically, with the given number of lines.
  27. dmenu is displayed on the monitor number supplied. Monitor numbers are starting
  28. from 0.
  29. .TP
  30. +.BI \-x " xoffset"
  31. +dmenu is placed at this offset measured from the left side of the monitor.
  32. +Can be negative.
  33. +If option
  34. +.B \-m
  35. +is present, the measurement will use the given monitor.
  36. +.TP
  37. +.BI \-y " yoffset"
  38. +dmenu is placed at this offset measured from the top of the monitor. If the
  39. +.B \-b
  40. +option is used, the offset is measured from the bottom. Can be negative.
  41. +If option
  42. +.B \-m
  43. +is present, the measurement will use the given monitor.
  44. +.TP
  45. +.BI \-z " width"
  46. +sets the width of the dmenu window.
  47. +.TP
  48. .BI \-p " prompt"
  49. defines the prompt to be displayed to the left of the input field.
  50. .TP
  51. diff --git a/dmenu.c b/dmenu.c
  52. index 65f25ce..7be19ae 100644
  53. --- a/dmenu.c
  54. +++ b/dmenu.c
  55. @@ -37,6 +37,9 @@ struct item {
  56. static char text[BUFSIZ] = "";
  57. static char *embed;
  58. static int bh, mw, mh;
  59. +static int dmx = 0; /* put dmenu at this x offset */
  60. +static int dmy = 0; /* put dmenu at this y offset (measured from the bottom if topbar is 0) */
  61. +static unsigned int dmw = 0; /* make dmenu this wide */
  62. static int inputw = 0, promptw;
  63. static int lrpad; /* sum of left and right padding */
  64. static size_t cursor;
  65. @@ -637,9 +640,9 @@ setup(void)
  66. if (INTERSECT(x, y, 1, 1, info[i]))
  67. break;
  68. - x = info[i].x_org;
  69. - y = info[i].y_org + (topbar ? 0 : info[i].height - mh);
  70. - mw = info[i].width;
  71. + x = info[i].x_org + dmx;
  72. + y = info[i].y_org + (topbar ? dmy : info[i].height - mh - dmy);
  73. + mw = (dmw>0 ? dmw : info[i].width);
  74. XFree(info);
  75. } else
  76. #endif
  77. @@ -647,9 +650,9 @@ setup(void)
  78. if (!XGetWindowAttributes(dpy, parentwin, &wa))
  79. die("could not get embedding window attributes: 0x%lx",
  80. parentwin);
  81. - x = 0;
  82. - y = topbar ? 0 : wa.height - mh;
  83. - mw = wa.width;
  84. + x = dmx;
  85. + y = topbar ? dmy : wa.height - mh - dmy;
  86. + mw = (dmw>0 ? dmw : wa.width);
  87. }
  88. promptw = (prompt && *prompt) ? TEXTW(prompt) - lrpad / 4 : 0;
  89. inputw = MIN(inputw, mw/3);
  90. @@ -690,6 +693,7 @@ static void
  91. usage(void)
  92. {
  93. fputs("usage: dmenu [-bfiv] [-l lines] [-p prompt] [-fn font] [-m monitor]\n"
  94. + " [-x xoffset] [-y yoffset] [-z width]\n"
  95. " [-nb color] [-nf color] [-sb color] [-sf color] [-w windowid]\n", stderr);
  96. exit(1);
  97. }
  98. @@ -717,6 +721,12 @@ main(int argc, char *argv[])
  99. /* these options take one argument */
  100. else if (!strcmp(argv[i], "-l")) /* number of lines in vertical list */
  101. lines = atoi(argv[++i]);
  102. + else if (!strcmp(argv[i], "-x")) /* window x offset */
  103. + dmx = atoi(argv[++i]);
  104. + else if (!strcmp(argv[i], "-y")) /* window y offset (from bottom up if -b) */
  105. + dmy = atoi(argv[++i]);
  106. + else if (!strcmp(argv[i], "-z")) /* make dmenu this wide */
  107. + dmw = atoi(argv[++i]);
  108. else if (!strcmp(argv[i], "-m"))
  109. mon = atoi(argv[++i]);
  110. else if (!strcmp(argv[i], "-p")) /* adds prompt to left of input field */
  111. --
  112. 2.28.0