LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Run GTK UI UDEV (http://www.linuxquestions.org/questions/programming-9/run-gtk-ui-udev-946745/)

amboxer21 05-25-2012 12:42 AM

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?

Nylex 05-25-2012 12:44 AM

Please don't double post. I've reported this thread as a duplicate of this one.

amboxer21 05-25-2012 01:05 AM

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.

amboxer21 05-25-2012 02:03 AM

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! ;)

amboxer21 05-25-2012 02:51 AM

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!?

amboxer21 05-25-2012 03:28 AM

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.

theNbomr 05-27-2012 10:24 AM

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.

amboxer21 05-27-2012 10:49 AM

Yeah, I ran into way too many problems!! More of a headache than it was worth!


All times are GMT -5. The time now is 08:55 AM.