LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 01-08-2005, 06:59 PM   #1
tiagomadeira
LQ Newbie
 
Registered: Jan 2005
Location: Itajaí, SC, Brasil
Distribution: Slackware 10
Posts: 12

Rep: Reputation: 0
Starting an application on X by console


Hey...

I did a program (my automatic e-mail verify) and I'm running it in console (starting in rc.local):
Code:
#!/bin/sh
        while : ; do
                if fetchmail -a --fetchmailrc /etc/fetchmailrc 2> /dev/null | grep flushed > /dev/null
                then
                        play /home/tiago/bin/notify.wav &
                        chown tiago.users /home/tiago/Mail/inbox/new/* &
                        chmod 777 /home/tiago/Mail/inbox/new/* &
                        su 'tiago' -c graphic-dialog.sh # THIS IS THE POINT
                fi
        done
graphic-dialog.sh
Code:
#!/bin/bash
if [ -z "$DISPLAY" ]; then
        dialog=dialog
else
        dialog=kdialog
fi
$dialog --yesno "`date`\nYou got `ls /home/tiago/Mail/inbox/new/ | wc -l` new mail(s).\n\nWant to open mutt?"

if [ $? = 0 ]; then
                aterm +sb -T "Mutt for Tiago Madeira" -fn nada -e mutt
        fi
fi
I'm using KDE (and DISPLAY=:0). The graphics programs (kdialog, aterm) doesn't work because I'm not connecting X. When I receive a mail it just play the sound.

How I do that?

PS: tiago <- my user
root <- who runs the program

Thanks...
 
Old 01-08-2005, 07:30 PM   #2
zoiks
LQ Newbie
 
Registered: Dec 2004
Distribution: SuSE 9.1 Pro on Intel 2.4GHz (Dell Optiplex GX260)
Posts: 20

Rep: Reputation: 0
I'm not sure but my guess is you need to add local users to x. The command is something like "xhost +local:". This will get X to accept connections from local users.
 
Old 01-09-2005, 05:36 AM   #3
tiagomadeira
LQ Newbie
 
Registered: Jan 2005
Location: Itajaí, SC, Brasil
Distribution: Slackware 10
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks! Now it's working...

~/.kde/Autostart/xhost.sh
Code:
xhost +local:
~/bin/up_fetchmail.sh
Code:
#!/bin/sh
        while : ; do
                if fetchmail -a --fetchmailrc /etc/fetchmailrc 2> /dev/null | grep flushed > /dev/null
                then
                        play /home/tiago/bin/notify.wav &
                        chown tiago.users /home/tiago/Mail/inbox/new/* &
                        chmod 777 /home/tiago/Mail/inbox/new/* &
                        su tiago -c /home/tiago/bin/dialogo-mutt.sh
                fi
        done
~/bin/dialogo-mutt.sh
Code:
#!/bin/bash
if [ -z "$DISPLAY" ]; then
        dialog=/bin/dialog
else
        dialog=/opt/kde/bin/kdialog
fi
$dialog --yesno "`date`\nVocê tem `ls /home/tiago/Mail/inbox/new/ | wc -l` novo(s) e-mail(s).\n\nDeseja abrir o Mutt?" 0 0

if [ $? = 0 ]; then
        if [ "$dialog" = "/bin/dialog" ]; then
                mutt
        else
                aterm +sb -T "Mutt for Tiago Madeira" -fn nada -e mutt
        fi
fi
Now I got only another problem... if I'm not in graphic mode, I want that /bin/dialog does the dialogs (line 2-4, dialogo-mutt.sh) and mutt opens without terminal (line 10-12, dialogo-mutt.sh). Can I do that?

Thanks...
 
Old 01-09-2005, 06:35 AM   #4
tiagomadeira
LQ Newbie
 
Registered: Jan 2005
Location: Itajaí, SC, Brasil
Distribution: Slackware 10
Posts: 12

Original Poster
Rep: Reputation: 0
Ooops... It continues not working. I did the test with up_fetchmail running on KDE and it worked, but I rebooted and it's not working.

Some idea?

Thanks...
 
Old 01-09-2005, 07:53 AM   #5
tiagomadeira
LQ Newbie
 
Registered: Jan 2005
Location: Itajaí, SC, Brasil
Distribution: Slackware 10
Posts: 12

Original Poster
Rep: Reputation: 0
Yeah! Now it's working. I put a "export DISPLAY=":0"" in the start of my dialogo-mutt.sh. The problem was because only for user tiago the var DISPLAY had the right value.

Thanks for all and if somebody can help me now with openning non-graphic dialog in my user's console, it will be great.
 
  


Reply


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
Starting an application on X by console tiagomadeira Programming 1 01-09-2005 08:20 AM
rc.local not starting my application Greenman Linux - Newbie 11 08-17-2004 04:35 PM
Starting an application at boot ftwomey Linux - Newbie 3 04-25-2004 08:07 AM
console exclusivity to application byronm Programming 1 08-21-2003 12:56 PM
Auto starting an application bbereg Linux - Newbie 7 11-21-2002 05:40 PM


All times are GMT -5. The time now is 11:09 PM.

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