You are not logged in.

#1 2019-02-27 01:23:42

agrewal
Member
Registered: 2018-11-23
Posts: 20

How to execute scripts when switching between ttys?

I use redshift to change the color of my screen at night. When I change from a tty back to tty7 (where X is), the screen usually reverts back to its normal color.

I tried looking into acpid, but it seems that switching ttys isn't an acpi event.

My DE is cinnamon.

Is there a way to execute a command when switching ttys? Or is there a way not to have the gamma reset?

Offline

#2 2019-02-27 11:32:13

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,530

Re: How to execute scripts when switching between ttys?

http://jonls.dk/redshift/ wrote:

Redshift can also be applied to the Linux console by explicitly selecting the DRM driver.

Looks like you can use redshift on both console and X, try it.

------------------------

Is there a way to execute a command when switching ttys?

Check your xorg log after a switch to tty, you'll see something like this :

(II) AIGLX: Suspending AIGLX clients for VT switch

That suggests AIGLX handles/responds to the switch, someone with aiglx programming knowledge may be able to help.

Last edited by Lone_Wolf (2019-02-27 11:33:15)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2019-03-15 19:04:08

agrewal
Member
Registered: 2018-11-23
Posts: 20

Re: How to execute scripts when switching between ttys?

Thanks for the pointers.

As far as I can tell, there's no easy way to hook into the VT switch. In the meantime, I wrote a stupid little script that'll work until I find a proper solution:

#!/bin/sh

#Get the seat number to know which Xorg log to look at
NUM=$(who | grep `whoami` | sed 's/.*(:\([[:digit:]]\+\))/\1/')
FILE=/var/log/Xorg.$NUM.log

while inotifywait -e modify $FILE
do
        if tail -n 60 $FILE | grep "VT" | tail -n 1 | grep -q "\(NVEnterVT\|Resuming\)"
        then
                redshift -PO $(cat ~/.cache/colortemp)
        fi  
done

This doesn't work on the console or if you're logged in multiple times.
I've also wrapped redshift in a little script that'll update ~/.cache/colortemp

Offline

Board footer

Powered by FluxBB