stumpwm-devel
[Top][All Lists]
Advanced

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

[STUMP] Dim inactive monitor in dual head configuration


From: Dimitri Minaev
Subject: [STUMP] Dim inactive monitor in dual head configuration
Date: Thu, 2 Jun 2016 17:02:53 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.8.0

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.



reply via email to

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