Re: [dev] [dwm] Obtain focused monitor
Hi, On Sun Jan 8, 2023 at 11:40 AM CET, A Farzat wrote: > On 23/01/08 11:32am, Hiltjo Posthuma wrote: > > On Sun, Jan 08, 2023 at 07:19:10PM +0900, A Farzat wrote: > > > Is there a way to obtain the currently focused monitor in dwm? I want to > > > use it in my script to control which monitor gets its brightness > > > modified. > > > > > > Regards, > > > Farzat > > > > selmon > > > > -- > > Kind regards, > > Hiltjo > > > > And how do I access that command? If possible I want to access it from > a shell script. > > I am open to modifying the dwm source code if necessary. > > Regards, > Farzat selmon isn't a command. It's a variable in the source code located at dwm.c:269 (upstream). You could write a function like the following to dump its value to stdout/stderr. Now you have to figure out where to call it. -- Best Regards, Tom Schwindl diff --git a/dwm.c b/dwm.c index 03baf42b3502..4fa8253c91e0 100644 --- a/dwm.c +++ b/dwm.c @@ -234,6 +234,7 @@ static int xerror(Display *dpy, XErrorEvent *ee); static int xerrordummy(Display *dpy, XErrorEvent *ee); static int xerrorstart(Display *dpy, XErrorEvent *ee); static void zoom(const Arg *arg); +static void dumpmon(void); /* variables */ static const char broken[] = "broken"; @@ -276,6 +277,13 @@ static Window root, wmcheckwin; struct NumTags { char limitexceeded[LENGTH(tags) > 31 ? -1 : 1]; }; /* function implementations */ +static void +dumpmon(void) +{ + if (selmon) + fprintf(stdout, "%d\n", selmon->num); +} + void applyrules(Client *c) {
Re: [dev] [dwm] Obtain focused monitor
On Sun, Jan 08, 2023 at 07:40:21PM +0900, A Farzat wrote: > On 23/01/08 11:32am, Hiltjo Posthuma wrote: > > On Sun, Jan 08, 2023 at 07:19:10PM +0900, A Farzat wrote: > > > Is there a way to obtain the currently focused monitor in dwm? I want to > > > use it in my script to control which monitor gets its brightness > > > modified. > > > > > > Regards, > > > Farzat > > > > selmon > > > > -- > > Kind regards, > > Hiltjo > > > > And how do I access that command? If possible I want to access it from > a shell script. > > I am open to modifying the dwm source code if necessary. > > Regards, > Farzat Hi, For example using the dmenumon variable, it is set in spawn(): http://git.suckless.org/dwm/commit/ba56fe9fea0a28d8184a727a987836a0903e2682.html Hope this helps, -- Kind regards, Hiltjo
Re: [dev] [dwm] Obtain focused monitor
On 23/01/08 11:32am, Hiltjo Posthuma wrote: > On Sun, Jan 08, 2023 at 07:19:10PM +0900, A Farzat wrote: > > Is there a way to obtain the currently focused monitor in dwm? I want to > > use it in my script to control which monitor gets its brightness > > modified. > > > > Regards, > > Farzat > > selmon > > -- > Kind regards, > Hiltjo > And how do I access that command? If possible I want to access it from a shell script. I am open to modifying the dwm source code if necessary. Regards, Farzat signature.asc Description: PGP signature
Re: [dev] [dwm] Obtain focused monitor
On Sun, Jan 08, 2023 at 07:19:10PM +0900, A Farzat wrote: > Is there a way to obtain the currently focused monitor in dwm? I want to > use it in my script to control which monitor gets its brightness > modified. > > Regards, > Farzat selmon -- Kind regards, Hiltjo
[dev] [dwm] Obtain focused monitor
Is there a way to obtain the currently focused monitor in dwm? I want to use it in my script to control which monitor gets its brightness modified. Regards, Farzat signature.asc Description: PGP signature
[dev] st: no need for scrollback patch or program by using -o option
I wrote this little wrapper script I call ost: <<< #!/bin/sh export ST_LOG_FILE=$(mktemp) || { printf '%s\n' "$0: cannot create temp file" >&2 ; exit 1; } st -o "$ST_LOG_FILE" "$@" rm "$ST_LOG_FILE" >>> If some output scrolls past that I want to go back and see, I look at its "$ST_LOG_FILE" in another terminal. This seems to obviate my need for a scrollback patch or program.