Re: [STUMP] Dim inactive monitor in dual head configuration

David Bjergaard <[email protected]>
Newsgroups gmane.comp.window-managers.stumpwm.devel
Message-ID <[email protected]>
Hi Dimitri,

Two notes: If collect-output-p is nil when run-shell-command is called, it will
not wait for xrandr to finish.  See:
https://stumpwm.github.io/git/stumpwm-git_10.html#index-run_002dshell_002dcommand

Another option to background the process is:
(run-shell-command "command &> /dev/null &")

I'm glad that you are enjoying the hacking experience.  All of my ideas are
beyond my technical ability to execute ;)

    David
    

Dimitri Minaev <[email protected]> writes:

> Hello again.
>
> I've configured Stumpwm to run on a dual head configuration. But I
> always forget which monitor is currently active and start typing in a
> wrong window. I found a Python script that dims the inactive monitor a
> bit (See
> http://askubuntu.com/questions/665155/how-to-highlight-current-screen-or-window). It
> runs in a loop, sleeping for a 0.5 second after every run. Feels very
> sluggish, so I thought I could write a Lisp function that would dim
> the inactive monitor every time I move focus to and fro.
>
> Here's what I've come up with:
>
> (ql:quickload "cl-utilities")
> (defun parse-xrandr ()
>   (loop for i in (split-string (run-shell-command "xrandr" t))
>      when (search " connected" i)
>      collect (car (cl-utilities:split-sequence #\Space i))))
>
> (defun dim-inactive-head (arg1 arg2)
>   (let* ((heads (parse-xrandr))
> 	 (brighthead (slot-value (current-head) 'number))
> 	 (dimhead (if (eql brighthead 0) 1 0)))
>     (run-shell-command
>      (format nil "/usr/bin/xrandr --output ~d --brightness 1.0" (nth
> brighthead heads)))
>     (run-shell-command
>      (format nil "/usr/bin/xrandr --output ~d --brightness 0.6" (nth
> dimhead heads)))))
>
> (add-hook *focus-frame-hook* 'dim-inactive-head)
> (add-hook *focus-group-hook* 'dim-inactive-head)
>
> The function uses cl-utilities:split-sequence, hence ql:quickload call
> in the beginning. Is there an alternative that doesn't have any
> dependencies?
>
> It kinda works. I'm a bit worried by the fact that on one occasion the
> call to xrandr got stuck and didn't return, effectively putting the
> whole Stumpwm to stop. Besides I'm not sure if the hook is triggered
> when window placement rules switch groups. It would be nice if someone
> helped with testing and especially with fixing this straightforward
> implementation :)
>
> In the beginning I used a wrong hook, *focus-window-hook*, but for
> some reason it didn't let me open any new window. Every time I tried
> to open xterm or anything else, Stumpwm stuck up. Strange, I thought
> that tiny function might be called any time, any place. It shouldn't
> have any harmful side effects.
>
> _______________________________________________
> Stumpwm-devel mailing list
> [email protected]
> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.