LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 03-30-2004, 06:55 PM   #1
Registered: Jan 2004
Location: California
Distribution: Slackware 10.1
Posts: 190

Rep: Reputation: 30
.bashrc check if there's a display open

I don't know if this should be here due to the very basicness of it, but I added a command to my .bashrc file:

xset b off
This turns off beeps in the terminal, the trouble is if I'm in the console I get something like this message everytime I login:

xset: unable to open display.

How can I use a conditional statement to check if a display (X Window) is open:

if display is open
        xset b off;
Old 03-30-2004, 06:59 PM   #2
Registered: Mar 2004
Location: Massachusetts
Distribution: Debian
Posts: 557

Rep: Reputation: 42
There might be a better way to do this, but
if [ "$DISPLAY" ]; then
        xset b off
should work
Old 03-30-2004, 07:44 PM   #3
Registered: Jan 2004
Location: California
Distribution: Slackware 10.1
Posts: 190

Original Poster
Rep: Reputation: 30
Worked, thanks.
Old 03-31-2004, 03:43 AM   #4
Senior Member
Registered: Mar 2004
Location: england
Distribution: FreeBSD, Debian, Mint, Puppy
Posts: 3,290

Rep: Reputation: 174Reputation: 174
even better, put it in


which only gets called with X.

(man readline, inputrc)
you can make an .inputrc and
turn off all bells.



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem using screen: Cannot open your terminal '/dev/pts/0' - please check. stefaandk Linux - General 18 06-17-2014 07:52 PM
check internet connection in .bashrc mvo Linux - Newbie 2 11-26-2005 06:32 PM
How do I start ftp service and check if port open? quintan Linux - Software 1 11-24-2005 05:33 AM
How to check display card? sikandar Linux - Software 1 01-12-2004 06:56 PM
bashrc not read by root, can't open display SerfurJ Slackware 6 12-05-2003 10:54 PM

All times are GMT -5. The time now is 05:22 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration