Xdialog won't work in FVWM [solved]

User avatar
TF
Moderator
Moderator
Posts: 246
Joined: Sat Sep 10, 2005 12:30 am
Location: Germany
Contact:

Xdialog won't work in FVWM [solved]

Postby TF » Thu Jul 20, 2006 12:45 am

Hi all,

I hope this post is on the right place ...

I have created a script which mounts over FvwmButton a device and change the icon if succeed. If an error occur while mounting it should open a xdialog message box but it doesn't :(

I must go with ctrl-alt-F1 to a console and kill the Xdialog process cause it blocks all working in the windowmanager.

Here are my configs:

In the FVWM config file:

Code: Select all

#########
# Mount/unmount function
#########
DestroyFunc ToggleMount
AddToFunc ToggleMount
+ I PipeRead '$[fvwm_script]/mount.sh $0 $1'


The FVWMButton config:

Code: Select all

:
# Floppy anzeigen
###########
*FvwmMount:      (3x8+1+0, ActionOnPress, \
                Id "F", \
                Icon            $[fvwm_icon]/32x32/devices/3floppy_unmount.png, \
                ActiveIcon      $[fvwm_icon]/48x48/devices/3floppy_unmount.png, \
                Action(Mouse 1) ToggleMount "/floppy" "F"), \
:

The mount.sh script:

Code: Select all

#!/bin/sh
error=""
mounted=0

# check if mounted
mounted=`grep -c "$1" /etc/mtab`
if [ $mounted -eq 0 ]
then
  #mount device
  mount $1 2>error.tmp
  error=`cat error.tmp`
  if [ -z "$error"  ]
  then
    # change the correct icon
    if [ $2 == "F" ]
    then
      FvwmCommand "SendToModule FvwmMount ChangeButton "$2" Icon /home/tf/.fvwm/img/icon/32x32/devices/3floppy_mount.png"
      FvwmCommand "SendToModule FvwmMount ChangeButton "$2" ActiveIcon /home/tf/.fvwm/img/icon/48x48/devices/3floppy_mount.png"
    fi
  #if not ok print error message
  else
   Xdialog --title "Mount Error" --wmclass error  --msgbox "$error"  0 0
  fi
# if mounted==0 then unmount device
else
  umount $1 2>error.tmp
  error=`cat error.tmp`
  # if unmount ok change icon
  if [ -z "$error"  ]
  then
    # if unmount ok change icon
    # change the correct icon
    if [ $2 == "F" ]
    then
      FvwmCommand "SendToModule FvwmMount ChangeButton "$2" Icon /home/tf/.fvwm/img/icon/32x32/devices/3floppy_unmount.png"
      FvwmCommand "SendToModule FvwmMount ChangeButton "$2" ActiveIcon /home/tf/.fvwm/img/icon/48x48/devices/3floppy_unmount.png"
    fi
  # if unmount fail print error message
  else
    Xdialog --title "Unmount Error" --wmclass error  --msgbox "$error"  0 0
  fi
fi
exit 0

If I take

Code: Select all

echo error Mount: $error >> ~/.xsession-errors
all works fine.

Also, if I execute the script over a console window it works fine too and the xdialog message appears :?

What's going wrong?

Please help, thanks.

Best Regards,

TF

edit: btw I get an error message in the xsession-errors if I restart FVWM:

Code: Select all

[FVWM][__execute_function]: <<ERROR>> No such command 'mounted:'

Why?
Last edited by TF on Thu Jul 20, 2006 9:51 pm, edited 1 time in total.

thomasadam
Administrator
Administrator
Posts: 3043
Joined: Mon Nov 08, 2004 1:12 am
Location: England
Contact:

Re: Xdialog won't work in FVWM

Postby thomasadam » Thu Jul 20, 2006 1:12 am

TF wrote:The mount.sh script:

Code: Select all

#!/bin/sh
error=""
mounted=0

# check if mounted
mounted=`grep -c "$1" /etc/mtab`
if [ $mounted -eq 0 ]
then
  #mount device
  mount $1 2>error.tmp
  error=`cat error.tmp`
  if [ -z "$error"  ]
  then
    # change the correct icon
    if [ $2 == "F" ]
    then


Let's shorten this a bit, shall we?

Code: Select all

#!/bin/sh
mount "$1" && {
  # Add stuff here if "$1" was mounted.
} || {
  # Add stuff here if "$1" was not mounted.
}


Whilst what you have is OK, the above would remove duplication.


What's going wrong?

Please help, thanks.

Best Regards,

TF

edit: btw I get an error message in the xsession-errors if I restart FVWM:

Code: Select all

[FVWM][__execute_function]: <<ERROR>> No such command 'mounted:'

Why?[/quote]

You might need to background your Xdialog calls in your script -- and most likely the reason as to why it hangs is because you're starting the script via PipeRead which will block. Since you're using FvwmCommand, I would instead try:

Code: Select all

+ I Exec exec yourscript.sh $0 $1


-- Thomas Adam

User avatar
TF
Moderator
Moderator
Posts: 246
Joined: Sat Sep 10, 2005 12:30 am
Location: Germany
Contact:

Re: Xdialog won't work in FVWM

Postby TF » Thu Jul 20, 2006 9:50 pm

Hi Thomas,

thomasadam wrote:

Code: Select all

+ I Exec exec yourscript.sh $0 $1


Yep, it works fine :D

Thanks for helping.

Cheers,

TF


Return to “Other languages”

Who is online

Users browsing this forum: No registered users and 1 guest