stumpwm-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Joram Schrijver
Subject: Re: [STUMP] Dim inactive monitor in dual head configuration
Date: Thu, 02 Jun 2016 20:59:43 +0200

Hi Dimitri,

On Thu, Jun 2, 2016, at 03:02 PM, Dimitri Minaev wrote:
> 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?

The alternative provided by StumpWM is right above it in your code:
`SPLIT-STRING`. By default it splits on a number of different whitespace
characters, but you can tell it what to split on. `(split-string i "
")`.

> 
> 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 :)

There is also the problem that there is absolutely no guarantee that
xrandr and StumpWM will list heads in the same order. In fact, for me,
it's the other way around right now.

> 
> 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
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/stumpwm-devel

--
  Joram



reply via email to

[Prev in Thread] Current Thread [Next in Thread]