LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices



Reply
 
Search this Thread
Old 05-25-2012, 12:42 AM   #1
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Rep: Reputation: Disabled
Run GTK UI UDEV


I can run a bash script no problem with udev, but how do I run a GTK UI? I tried the PROGRAM+="/path/to/prog/" and nothing.

I tried calling the program from within a script, still no luck.

So, does anyone know how to do this?
 
Old 05-25-2012, 12:44 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
Please don't double post. I've reported this thread as a duplicate of this one.
 
Old 05-25-2012, 01:05 AM   #3
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Original Poster
Rep: Reputation: Disabled
Dude relax, it was an accident. My computer's connection was hanging on load. So, I stopped it, and refreshed. Then clicked post again and it apparently double posted. It's not the end of the world.

Thanks for the help though.

Last edited by amboxer21; 05-25-2012 at 01:06 AM.
 
Old 05-25-2012, 02:03 AM   #4
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Original Poster
Rep: Reputation: Disabled
Anyhow, here is what I have so far:
Code:
#!/bin/bash
echo "HELLO WORLD" > /home/amboxer/Desktop/hello.txt; 
export DISPLAY=:0.0 
#su amboxer21 -c 'xhost local:amboxer21; 
#PASSWORD=$(zenity --title='Password' --password | sudo -S /home/amboxer21/Documents/warning)
PASSWORD=$(zenity --title='Password' --password)

echo $PASSWORD

if [ $PASSWORD == "password" ]; then
mount /media/Lexar;

        else 
        umount -l /media/Lexar;
fi
I am able to run a C or gtk program with:
Code:
sudo -S /home/annonymous/Documents/warning

I Know that it is extremely sloppy at the moment but it will get fixed up as I go along. Thanks

BTW, Couldn't have done it without you @Nylex!

Last edited by amboxer21; 05-25-2012 at 02:18 AM.
 
Old 05-25-2012, 02:51 AM   #5
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Original Poster
Rep: Reputation: Disabled
Anyone, I have
Code:
#!/bin/bash
echo "HELLO WORLD" > /home/amboxer21/Desktop/hello.txt;
export DISPLAY=:0.0
#su amboxer21 -c 'xhost local:amboxer21;
#sudo -S /home/amboxer21/Documents/warning
PASSWORD=$(zenity --title='Password' --password)
echo $PASSWORD;

if [ $PASSWORD == "password" ]; then
sudo -S mount /media/Lexar;
exit 0;

        else
        PASSWORD=$(zenity --title='Password' --password)
        echo $PASSWORD;
fi
It will run properly at first. For example: If I plug in a usb device, a password prompt will pop up. If I enter the correct passwod the first time, it will mount the FS. If I enter the wrong password the first time, then the right password the second time, it will do nothing. How can I fix this?

I feel like I should have something in between my if and else!?
 
Old 05-25-2012, 03:28 AM   #6
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Original Poster
Rep: Reputation: Disabled
Im trying to run it through a loop
Code:
#!/bin/bash
echo "HELLO WORLD" > /home/amboxer21/Desktop/hello.txt;
export DISPLAY=:0.0
#su amboxer21 -c 'xhost local:amboxer21;
#sudo -S /home/amboxer21/Documents/warning
PASSWORD=$(zenity --title='Password' --password)
echo $PASSWORD;

while true; do

if [ $PASSWORD == "password" ]; then
su -S mount /media/Lexar;
exit 0;

        else
        PASSWORD=$(zenity --title='Password' --password)
        echo $PASSWORD;
fi

done
will infinitely run if password is wrong. If password is right, it exits and does not mount. Unless I type the correct password on the first try.

Last edited by amboxer21; 05-25-2012 at 04:18 AM.
 
Old 05-27-2012, 10:24 AM   #7
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,396
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
What you are attempting to do is a poor idea, since udev rules are invoked early in the boot process. At boot time, there is probably no X server running to support your GUI. You could possibly run the GUI on another X server (i.e. on a different host), but there is no guarantee that that server would be available, and it isn't even a sure thing that the network will be alive when some udev rules are invoked.
--- rod.
 
Old 05-27-2012, 10:49 AM   #8
amboxer21
Member
 
Registered: Mar 2012
Location: New Jersey
Distribution: Gentoo
Posts: 285

Original Poster
Rep: Reputation: Disabled
Yeah, I ran into way too many problems!! More of a headache than it was worth!
 
  


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
Run GTK UI UDEV amboxer21 Programming 1 05-25-2012 03:20 AM
[SOLVED] udev to run script not behaves like when run in terminal matiasar Linux - Software 6 04-17-2012 08:56 AM
UDEV: Unable to run a command line interface script after USB automount using udev mohamr2 Linux - Embedded & Single-board computer 8 08-16-2011 11:39 AM
Trying to run X without udev rtmistler Linux - Embedded & Single-board computer 2 03-04-2011 04:08 PM
udev RUN+= doesn't seem to work PlancksCnst Linux - General 18 05-15-2007 07:44 PM


All times are GMT -5. The time now is 02:44 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