You are not logged in.

#1 2005-05-03 21:57:20

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,378
Website

monitor as an ambient light source

today, a colleague showed me this dvd:

http://www.thinkgeek.com/gadgets/lights/7427/

it's mainly a cycling trough the colour palette

what's the shortest script to do the same (written in a language that has a wrapper/bindings to xlibs) ... anyone?


The impossible missions are the only ones which succeed.

Offline

#2 2005-05-03 22:42:47

iphitus
Forum Fellow
From: Melbourne, Australia
Registered: 2004-10-09
Posts: 4,927

Re: monitor as an ambient light source

you could write a shell script that cycles through the colours and passes each of them to xsetroot or bsetroot.

Offline

#3 2005-05-03 22:59:02

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: monitor as an ambient light source

Like this:

#!/bin/sh
step=7;

r=0; b=0; g=0;

while true; do
    while [ $r -le 256 ]; do
        while [ $g -le 256 ]; do
            while [ $b -le 256 ]; do
                c=`printf "rgb:%x/%x/%x" $r $g $b`;
                xsetroot -solid $c;
                b=$(( $b + $step ));
            done
            g=$(( $g + $step ));
            b=0;
        done
        r=$(( $r + $step ));
        g=0;
    done
    r=0;
done

Offline

#4 2005-05-03 23:07:16

IceRAM
Member
From: Bucharest, Romania
Registered: 2004-03-04
Posts: 772
Website

Re: monitor as an ambient light source

Hmm.. why do I have the feeling a TV doesn't come with fans...

Later edit: I've added a "sleep 0.01" in the 3rd level for and.. after some seconds of running... the computer rebooted... twilight zone... can't find a good reason for this. The sleep period was probably a bit too short... anyway... weird.

Offline

#5 2005-05-03 23:28:33

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,378
Website

Re: monitor as an ambient light source

cool! i totally forgot about xsetroot ;-)


The impossible missions are the only ones which succeed.

Offline

#6 2005-05-03 23:54:05

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,378
Website

Re: monitor as an ambient light source

i3839, nice codelet ... only the flickering is not so nice ... we need to keep the sum of r+g+b gradient or constant to have a nice smooth change of colour

does bash support trigonometry functions? (sinus cosinus)


The impossible missions are the only ones which succeed.

Offline

#7 2005-05-04 01:49:52

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: monitor as an ambient light source

Of course it doesn't, don't be silly. It doesn't even support floating points (or I'd used the 'rgbi:' syntax instead).

Offline

#8 2005-05-04 01:54:48

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: monitor as an ambient light source

for something like that... if you're serious about this - just tear apart xsetroot and double (triple? overkill...) buffer it... shouldn't be hard....

Offline

#9 2005-05-04 07:14:15

shadowhand
Member
From: MN, USA
Registered: 2004-02-19
Posts: 1,142
Website

Re: monitor as an ambient light source

This would be sweet to have. I'd totally use it instead of a screensaver. Or maybe it could be coded as a screen saver? O.O


·¬»· i am shadowhand, powered by webfaction

Offline

#10 2005-05-04 11:02:46

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: monitor as an ambient light source

I use my keyboard attached to the server as an addtional source of blue light :-) (it's a vivanco keyboard with nice blue backlight).

Offline

#11 2005-05-04 11:17:51

lanrat
Member
From: Poland
Registered: 2003-10-28
Posts: 1,274

Re: monitor as an ambient light source

Offline

#12 2005-05-11 23:40:48

droog
Member
Registered: 2004-11-18
Posts: 877

Re: monitor as an ambient light source

doing it with aalib could be fun, there are a few small example programs with it like colored ascii flames. It would probably be pretty easy to make short colored ascii animations.

Offline

#13 2005-05-12 08:27:35

mico
Member
From: Slovenia
Registered: 2004-02-08
Posts: 247

Re: monitor as an ambient light source

i3839 wrote:

Like this:

#!/bin/sh
step=7;

r=0; b=0; g=0;

while true; do
    while [ $r -le 256 ]; do
        while [ $g -le 256 ]; do
            while [ $b -le 256 ]; do
                c=`printf "rgb:%x/%x/%x" $r $g $b`;
                xsetroot -solid $c;
                b=$(( $b + $step ));
            done
            g=$(( $g + $step ));
            b=0;
        done
        r=$(( $r + $step ));
        g=0;
    done
    r=0;
done

Shouldn't the loops go only till 255 (or replace -le with -lt)?

One more question - how do I get this working? When I run xsetroot -solid rgb:200/0/0, it exits immediately with no output, no errors, but nothing happens. I tried to protect the rgb argument with double quotes and/or escape sequences, still nothing.

Offline

#14 2005-05-12 10:27:23

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: monitor as an ambient light source

Yes, it must be 255, I changed it in a later version, but I couldn't get rid of the flickering, so never posted it.

I use the printf because the values are in hex, so rgb:200/0/0 is wrong.

Offline

#15 2005-05-12 10:33:42

dp
Member
From: Zürich, Switzerland
Registered: 2003-05-27
Posts: 3,378
Website

Re: monitor as an ambient light source

i3839 wrote:

... but I couldn't get rid of the flickering, so never posted it.

the flickering happens, becuase it jumps from 255 to 0. the best way would be to alternate r b g but keep the sum of these 3 values constant or at least equicontinuously changing. that's also why i asked if trigonometry functions are available in bash (but they are not, unfortunately). maybe something similar can be coded in perl


The impossible missions are the only ones which succeed.

Offline

#16 2005-05-12 11:15:31

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: monitor as an ambient light source

I let it move from 0 to 255 and then back to 0 again. Also tried keeping the sum the same, but the flickering didn't went away, although it was slightly less.

Offline

Board footer

Powered by FluxBB