I'm looking to raise the brightness when I maximize or foreground the Terminal window which has Vim running. I would like to reset the brightness to normal when I minimize or background that process as well.
I usually need more brightness when working with the black background of Vim than the white background of Chrome so I'd like it to happen automatically.
I use this to programatically decrease the brightness:
$ echo 1 | sudo tee /sys/class/backlight/acpi_video0/brightness
Can I somehow hook into the minimize/maximize event of a GUI window and run the above as a script if the window is Terminal with Vim running?
Best Answer
You could do something like:
Replace the
echo ...
with the actual command to set the brightness.The idea is to use
xdotool
to get notified when the window focus changes. Then, we usexprop
on the window id reported byxdotool
to see if the window that currently has the focus isgnome-terminal
and is maximised.However, it doesn't work for windows that have connected after
xdotool
has started.A more robust method could be to just check the current active window in a loop:
You can find out more details through the xdotool man page.