You are not logged in.

#1 2005-10-04 15:56:51

nightfrost
Member
From: Sweden
Registered: 2005-04-16
Posts: 647

if-question

I hope this one qualifies as a programming question...

The thing is, I've finally managed to work around the garbled-screen-in-console-after-a-resume-from-sleep problem that I've had, albeit in a rather crippled way. I use vbetool restore to acomplish this, which works fine. I've noticed, though, that after a resume, I have to restore the vbestate every time I switch from X to console. That is, every time I switch, the screen is garbled and I have to restore the VBE. What I did was to trigger a bash script that restores the VBE whenever I press my power button.

Now, to the problem:

when I do this in X, X goes nuts and I have to restart it. For this reason I want a safety-net in my script that checks if the current VT is <7, in which case it restores the VBE; otherwise, I want it to do nothing at all. How do I do this? I know that the command 'fgconsole' gives the current VT, but how do I incorporate this in the if command?

Thanks in advance smile

Offline

#2 2005-10-04 16:09:19

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

Re: if-question

something like:

vt=`fgconsole`
if [ $vt -ne 7 ]; then
   vbetool
fi

or as a one-liner:

[ `fgconsole` -ne 7 ] && vbetool

Offline

#3 2005-10-04 16:16:07

nightfrost
Member
From: Sweden
Registered: 2005-04-16
Posts: 647

Re: if-question

ah! thanks. It was the '-ne'-thing I was looking for I guess. I've come over -f and -x in other peoples' scripts. Is there a list available anywhere? I've tried man if, but that's no good...

Offline

#4 2005-10-04 16:24:16

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

Re: if-question

nightfrost wrote:

Is there a list available anywhere? I've tried man if, but that's no good...

It uses the "test" command internally - try "man test"

Offline

#5 2005-10-04 16:54:40

nightfrost
Member
From: Sweden
Registered: 2005-04-16
Posts: 647

Re: if-question

Great! Thanks a lot. That's precisely what I needed smile

Offline

#6 2005-10-04 17:24:42

bardo
Member
Registered: 2004-12-06
Posts: 96

Re: if-question

That's documented (like all other bash internals) in "man bash", too.


dreaming in digital / living in realtime / thinking in binary / talking in ip / welcome to our world

Offline

#7 2005-10-04 18:43:13

T-Dawg
Forum Fellow
From: Charlotte, NC
Registered: 2005-01-29
Posts: 2,736

Re: if-question

phrakture wrote:

man test

:shock:  :shock:  Son of a....

Offline

Board footer

Powered by FluxBB