Results 1 to 6 of 6

Thread: Running a script in kde?

  1. #1
    Join Date
    Jun 2008
    Location
    Norwich, UK
    Posts
    222

    Default Running a script in kde?

    There must be a simple answer...

    I want to write a bash script which could be run from a terminal or within KDE - how can I find out within the script where it's running?

    Basically I want to switch between a simple echo statement on the terminal or kdialog if I'm in KDE

  2. #2
    ab@novell.com NNTP User

    Default Re: Running a script in kde?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    You could always try the kdialog command and perhaps check the
    errorlevel if it fails.

    textToBePrinted='put your text for the message here';
    kdialog -msgbox "$textToBePrinted" 2>/dev/null
    if [ $? != 0 ]; then echo '$textToBePrinted'; fi

    Good luck.





    In theory that checks to see if kdialog fails and, if it does, prints
    text to the screen.

    fudokai wrote:
    | There must be a simple answer...
    |
    | I want to write a bash script which could be run from a terminal or
    | within KDE - how can I find out within the script where it's running?
    |
    | Basically I want to switch between a simple echo statement on the
    | terminal or kdialog if I'm in KDE
    |
    |
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIb3Xx3s42bA80+9kRApqOAJ9ZcsiAxuZqrrz4zNoKnnHh6fxs/gCdGJAr
    E2/jYCjD0JCA9TxbeN+bjLM=
    =IrB2
    -----END PGP SIGNATURE-----

  3. #3
    ajp NNTP User

    Default Re: Running a script in kde?

    ab@novell.com wrote:

    > -----BEGIN PGP SIGNED MESSAGE-----
    > Hash: SHA1
    >
    > You could always try the kdialog command and perhaps check the
    > errorlevel if it fails.
    >
    > textToBePrinted='put your text for the message here';
    > kdialog -msgbox "$textToBePrinted" 2>/dev/null
    > if [ $? != 0 ]; then echo '$textToBePrinted'; fi
    >
    > Good luck.
    >
    >
    >
    >
    >
    > In theory that checks to see if kdialog fails and, if it does, prints
    > text to the screen.
    >
    > fudokai wrote:
    > | There must be a simple answer...
    > |
    > | I want to write a bash script which could be run from a terminal or
    > | within KDE - how can I find out within the script where it's running?
    > |
    > | Basically I want to switch between a simple echo statement on the
    > | terminal or kdialog if I'm in KDE
    > |
    > |
    > -----BEGIN PGP SIGNATURE-----
    > Version: GnuPG v1.4.2 (GNU/Linux)
    > Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
    >
    > iD8DBQFIb3Xx3s42bA80+9kRApqOAJ9ZcsiAxuZqrrz4zNoKnnHh6fxs/gCdGJAr
    > E2/jYCjD0JCA9TxbeN+bjLM=
    > =IrB2
    > -----END PGP SIGNATURE-----


    That works but it's a bit messy - I was hoping I could set a variable at the
    start of the script and then test for that wherever I need it.

    Alan

    --
    email =~ s/nospam/fudokai/

  4. #4
    Join Date
    Jun 2008
    Location
    Norwich, UK
    Posts
    222

    Default Re: Running a script in kde?

    It works but it's a bit messy - I'd rather set a variable at the start of the script and test for it whenever I need to.

    Alan

  5. #5
    ab@novell.com NNTP User

    Default Re: Running a script in kde?

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    That's fine. Do the test and instead of having the 'echo' command for
    the command line set a variable instead to be used from then on.

    textToBePrinted='put your text for the message here';
    kdialog -msgbox "$textToBePrinted" 2>/dev/null
    if [ $? != 0 ]; then export NOGUI=1; fi

    #From then on:

    if [ $NOGUI ]; then
    echo "$textToBePrinted
    else
    kdialog -msgbox "$textToBePrinted" 2>/dev/null
    fi

    Still not perfect. You may be able to semi-reliably test the existing
    environment for variables like XAUTHORITY. There are probably better
    ways as well.

    Good luck.






    ajp wrote:
    | ab@novell.com wrote:
    |
    | You could always try the kdialog command and perhaps check the
    | errorlevel if it fails.
    |
    | textToBePrinted='put your text for the message here';
    | kdialog -msgbox "$textToBePrinted" 2>/dev/null
    | if [ $? != 0 ]; then echo '$textToBePrinted'; fi
    |
    | Good luck.
    |
    |
    |
    |
    |
    | In theory that checks to see if kdialog fails and, if it does, prints
    | text to the screen.
    |
    | fudokai wrote:
    | | There must be a simple answer...
    | |
    | | I want to write a bash script which could be run from a terminal or
    | | within KDE - how can I find out within the script where it's running?
    | |
    | | Basically I want to switch between a simple echo statement on the
    | | terminal or kdialog if I'm in KDE
    | |
    | |

    | That works but it's a bit messy - I was hoping I could set a variable
    at the
    | start of the script and then test for that wherever I need it.

    | Alan

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

    iD8DBQFIcMA/3s42bA80+9kRAvQYAJ9tmuzlfK6wPeBXAxzjKGlHZ1zTkACghKBz
    w2bvLYLFMTFmdMDb0/Q6j/w=
    =6ji4
    -----END PGP SIGNATURE-----

  6. #6
    Join Date
    Jun 2008
    Location
    Norwich, UK
    Posts
    222

    Smile Re: Running a script in kde?

    Ok - using
    [[ -n $KDE_SESSION_UID ]] && kdialog ...
    [[ -n $KDE_SESSION_UID ]] || echo ...
    seems to work

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •