Announcement

Collapse
No announcement yet.

Newbie kdialog question

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • whitepine
    replied
    Yes! Finally! This worked perfectly. Thank you James and Andy for being patient with me, I really thought the solution would be simpler, but I'm happy.

    Leave a comment:


  • james147
    replied
    It works for me ^^

    What I did was:

    Modified the script to just contain:
    Code:
    #!/bin/sh
    export DISPLAY=:0
    kdialog --title "Mythtv" --msgbox "Transcode of recording for tablet complete"
    (ie the important lines, I changed --pasviepopup to --msgbox so I didn't miss the notification but it works for both)

    Switch to a virtual terminal and run the script as the normal user: the msgbox is displayed on the desktop with the given message

    Run it as root: Fails with unable to connect to display :0

    Run
    Code:
    xhost +si:localuser:root # replace root with your mythtv-user, I only used root as I don't have any other users
    in a terminal as the normal user

    Run the script as root on the virtual terminal: the msgbox is displayed on the desktop with the given message

    To make this work automatically you need to add the xhost line to run when kde starts (Autostart in system settings)

    Leave a comment:


  • whitepine
    replied
    Here is the latest thing I tried with no success:

    #!/bin/sh
    export DISPLAY=:0
    xhost +local:

    VIDEOIN=$1
    FILENAME=$2
    OUTDIR=$3

    # Now we'll convert the new temp file to mpg using avconv
    cp $VIDEOIN "$OUTDIR/$FILENAME.tmp"
    avconv -i "$OUTDIR/$FILENAME.tmp" -acodec libmp3lame -ac 2 -vcodec mpeg2video -q 8 -vf scale=-1:480 "$OUTDIR/$FILENAME.avi"

    # Now, we'll remove the temp file
    rm -f "$OUTDIR/$FILENAME.tmp"
    kdialog --title "Mythtv" --passivepopup "Transcode of recording for tablet complete" 10
    xhost -local:

    Leave a comment:


  • james147
    replied
    Did you run it with the DISPLAY variable set? And you are not really wasting anyone's time, if people think it is a waste of time then they will not respond to the thread, since people are then they do not think this

    Leave a comment:


  • whitepine
    replied
    James, I ran a test script from terminal and got my kdialog popup, then I ran it from a TTY logged in as my username and received "Kdialog: cannot connect to X server", then I logged in as mythtv and ran the script and again received "Kdialog: cannot connect to X server".
    I tried adding the xhost line and variations on it such as "xhost +local:" but no luck. I think I,m wasting every ones time with this since it's not very important, it just bothers me that I can't find a solution.

    Leave a comment:


  • andystmartin
    replied
    Yes, it probably is a permissions problem.

    I think the mythbackend runs as the "mythtv" user. In a start up script for the KDE environment, you should allow windows from another user to be displayed. The command is xhost and would go something like this:
    xhost +si:localuser:mythtv-user

    This allows the "mythtv-user" (or whatever the exact user name is) to create windows on your display.

    Leave a comment:


  • james147
    replied
    Originally posted by whitepine View Post
    James, I'm not sure how to do that. The script is designed to be invoked from mythbackend. Running it from a terminal, virtual or otherwise, it would not understand VIDEOIN or OUTDIR.
    You can modify the script to only run the parts that matter (ie the kdialog part, this would make it quicker to test). Or you can supply the arguments to the script manually like you did during testing:
    I did try running the script using a real file name and kdialog worked as it's supposed to.
    (I assume thats what you did given this statement at least).

    I also checked mythbackend.log and it tells me that the script has failed, but no indication as to why. Since this is run from mythbackend could it be a permissions problem?
    Scripts return the exit status from the last command executed ie, kdialog in your case, which is failing for some unknown reason so the script is counted to have failed. Best way to debug it is to try running the script in a headless environment (ie from a tty display (aka virtual terminal) you can switch to one by pressing alt+ctrl+F1, and alt+ctrl+F7 to switch back to the gui).

    If it runs as expected try running it form a headless environment as the user mythtv runs it as.

    Leave a comment:


  • whitepine
    replied
    James, I'm not sure how to do that. The script is designed to be invoked from mythbackend. Running it from a terminal, virtual or otherwise, it would not understand VIDEOIN or OUTDIR. I did try running the script using a real file name and kdialog worked as it's supposed to. I also checked mythbackend.log and it tells me that the script has failed, but no indication as to why. Since this is run from mythbackend could it be a permissions problem?

    Leave a comment:


  • james147
    replied
    Switch to a virtual terminal (alt+ctrl+F1, use F7 to get back to the GUI) and try running it there, see if it spits out any useful output.

    Leave a comment:


  • whitepine
    replied
    Thank you Andy and James, but neither "env DISPLAY=:0 /path/to/script" nor adding "export DISPLAY=:0" to the script worked. Right now I simply watch the system monitor to see when the cpu load drops - not a very elegant way of doing it, but it works.

    Leave a comment:


  • whitepine
    replied
    Thanks for the replies. I'll try setting the $DISPLAY variable tomorrow when I have more time. I would never have thought of this on my own.

    Leave a comment:


  • james147
    replied
    Originally posted by oshunluvr View Post
    Stutter much, James?
    I really should reread my posts when I edit what I first wrote down but that would require me to have a brain.

    Leave a comment:


  • oshunluvr
    replied
    Originally posted by james147 View Post
    ...to the script the script.
    Stutter much, James?

    Leave a comment:


  • james147
    replied
    To set the $DISPLAY variable either run the script with "env DISPLAY=:0 /path/to/script" or add "export DISPLAY=:0" to the script.
    Last edited by james147; Nov 07, 2012, 05:12 PM.

    Leave a comment:


  • andystmartin
    replied
    This could be an consequence of X11 DISPLAY not being set. When running from a konsole window, $DISPLAY is set -- typically to ":0". When running from cron or started outside of the KDE environment, $DISPLAY is probably not set.

    Leave a comment:

Working...
X