You are not logged in.

#1 2010-05-01 23:17:52

vigohe
Member
From: Concepción, Chile
Registered: 2009-03-24
Posts: 9

How to execute something when my screen resolution changes?

Sup!

I want to know if it's possible to execute a command or a script when my screen resolution change....

any ideas...

smile

Last edited by vigohe (2010-05-03 08:08:57)

Offline

#2 2010-05-02 10:55:41

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to execute something when my screen resolution changes?

It should be possible but I can't think of an elegant way atm. You could periodically check if a certain string is still

1440x900       59.9*+   59.9*

, if not then ...
Happy parsing.

Offline

#3 2010-05-03 00:02:02

vigohe
Member
From: Concepción, Chile
Registered: 2009-03-24
Posts: 9

Re: How to execute something when my screen resolution changes?

k! that string it is from ???????? xrandr?

Offline

#4 2010-05-03 07:21:33

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: How to execute something when my screen resolution changes?

Yeah, it's the output of 'xrandr'.

Offline

#5 2010-05-03 08:05:17

vigohe
Member
From: Concepción, Chile
Registered: 2009-03-24
Posts: 9

Re: How to execute something when my screen resolution changes?

I did something else smile

I use inotifywait from inotify-tools to watch the Xorg log if something modifies the log.

#!/bin/sh

path="/var/log/Xorg.0.log"
OldRes=$( xrandr | grep '*' | awk '{print $1}' )

while [ 1 ]
   do
      EVENT=$(inotifywait -e modify $path)
      NewRes=$(cat $path | tail -n 1 | grep -i "Allocate new frame buffer" | awk '{printf $7}') 
      if [ -n "$NewRes" -a "$NewRes"="$OldRes" ] ; then
         echo "The Screen Resolution has changed " "$NewRes"
         OldRes=$NewRes
      fi
   done

So now I can resize some stuff when I change the resolution xd ....
someone knows another way?

Last edited by vigohe (2010-05-03 08:07:40)

Offline

Board footer

Powered by FluxBB