You are not logged in.

#1 2010-01-17 16:33:53

johanbcn
Member
Registered: 2010-01-03
Posts: 20

[SOLVED] notify-send from a daemon

Hi,

I have configured halevt (a HAL device manager) to run notify-send so I get a notification every time I insert or remove a drive. The thing is, since halevt runs as a daemon at boot, every time it runs notify-send I get this error:

libnotify-Message: Unable to get session bus: /usr/bin/dbus-launch terminated abnormally with the following error: Autolaunch error: X11 initialization failed.

What I don't really understand is why if I restart de daemon from my Xorg session (with sudo) it works fine. Any ideas?

Thanks smile

UPDATE
I resolved the issue with a different approach.
The solution, for those interested, is in post #8.

Last edited by johanbcn (2010-07-12 22:27:14)

Offline

#2 2010-01-17 17:38:53

Knute
Member
From: Minot, ND
Registered: 2009-03-17
Posts: 604

Re: [SOLVED] notify-send from a daemon

How are you starting your wm/de?

I use

exec dbus-launch --exit-with-session [/i]start command for wm[/i]

The other option is to maybe start the daemon after you start your X-session.  That's easy enough to included in ur ~/.xsession or ~/.xinitrc  or in your wm/de startup scripts.


Knute

Offline

#3 2010-01-17 21:21:30

HashBox
Member
Registered: 2009-01-22
Posts: 271

Re: [SOLVED] notify-send from a daemon

I'm not sure if this is it but the "X11 initialization failed" might be caused by a missing DISPLAY environment variable, in which case you would probably need to modify the halevt init script to include

export DISPLAY=:0

or something similar

Offline

#4 2010-01-18 17:56:16

Berseker
Member
From: Near Lecco, Italy
Registered: 2008-04-24
Posts: 258

Re: [SOLVED] notify-send from a daemon

please remember to share how you managed to set halevt to send these messages to notify-osd!

Offline

#5 2010-01-19 22:24:39

johanbcn
Member
Registered: 2010-01-03
Posts: 20

Re: [SOLVED] notify-send from a daemon

Knute wrote:

How are you starting your wm/de?

I just launch compiz, and other apps I want (don't like any of the desktop environments).

.xinitrc

export GTK2_RC_FILES="$HOME/.gtkrc-2.0"
compiz ccp &
cairo-dock -c &
tint2 &
stjerm

By the way, I use SLiM as login manager.

HashBox wrote:

I'm not sure if this is it but the "X11 initialization failed" might be caused by a missing DISPLAY environment variable, in which case you would probably need to modify the halevt init script to include

export DISPLAY=:0

or something similar

That didn't do the trick sad

Berseker wrote:

please remember to share how you managed to set halevt to send these messages to notify-osd!

There you go:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE halevt:Configuration [
    <!ENTITY HAS-LABEL "hal.volume.label & !hal.volume.label = ">
    <!ENTITY DEVICE "hal.block.device & hal.volume.is_disc = false">
    <!ENTITY CDROM "hal.block.device & hal.volume.is_disc & hal.volume.disc.is_blank = false & hal.volume.disc.has_data & hal.volume.disc.is_videodvd = false">
    <!ENTITY CDROM.SIGNAL "hal.block.device & hal.storage.drive_type = cdrom">
    <!ENTITY DVD "hal.block.device & hal.volume.is_disc & hal.volume.disc.is_blank = false & hal.volume.disc.has_data & hal.volume.disc.is_videodvd = true">
]>
<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">
    <!-- Mount CDRom devices -->
    <halevt:Device match="&CDROM; & hal.volume.is_mounted = false;">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p cdrom$hal.block.minor$ -o sync"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p cdrom$hal.block.minor$ -o sync"/>
    </halevt:Device>    
    
    <!-- Mount non-CDRom labeled devices -->
    <halevt:Device match="&DEVICE; & &HAS-LABEL; & hal.volume.is_mounted = false;">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p $hal.volume.label$ -o sync"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p $hal.volume.label$ -o sync"/>
    </halevt:Device>    
    
    <!-- Mount non-CDRom non-labeled devices -->
    <halevt:Device match="&DEVICE; & hal.volume.is_mounted = false; & hal.volume.label = ">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p disk$hal.block.minor$ -o sync"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p disk$hal.block.minor$ -o sync"/>
    </halevt:Device>        
    
    <!-- Handle CDRom eject button signal -->
    <halevt:Device match="&CDROM.SIGNAL;">     
        <halevt:Condition name="EjectPressed" exec="halevt-umount $hal.block.device$ -o sync; eject $hal.block.device$"/>
    </halevt:Device>    
    
    <!-- Notify CDRom labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.is_disc = true & !hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-cdrom --expire-time=3000 'Device mounted' '$hal.volume.label$ has been mounted in $hal.volume.mount_point$.' &>> /tmp/halevt.log"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-cdrom --expire-time=3000 'Device unmounted' '$hal.volume.label$ has been unmounted.' &>> /tmp/halevt.log"/>
        </halevt:Property>
    </halevt:Device>    
    
    <!-- Notify non-CDRom labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.is_disc = false & !hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Device mounted' '$hal.volume.label$ has been mounted in $hal.volume.mount_point$.' &>> /tmp/halevt.log"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Device unmounted' '$hal.volume.label$ has been unmounted.' &>> /tmp/halevt.log"/>
        </halevt:Property>
    </halevt:Device>
    
    <!-- Notify non-CDRom non-labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Device mounted' '$hal.block.device$ has been  mounted in $hal.volume.mount_point$.' &>> /tmp/halevt.log"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Device unmounted' '$hal.block.device$ has been unmounted.' &>> /tmp/halevt.log"/>
        </halevt:Property>
    </halevt:Device>
</halevt:Configuration>

I think that finally I will just disable the daemon and just launch it from my .xinitrc (I think that should work). I don't really like it, but at least it's functional.

Thank you all big_smile

Last edited by johanbcn (2010-01-19 22:27:07)

Offline

#6 2010-01-29 07:59:30

Berseker
Member
From: Near Lecco, Italy
Registered: 2008-04-24
Posts: 258

Re: [SOLVED] notify-send from a daemon

I've seen only now your post.. great job, this is very useful and pretty for those that doesn't use a complete DE.
It would be great to translate your file in different languages (I'll try to translate this in italian if I find some spare time)

Offline

#7 2010-02-24 06:57:58

Berseker
Member
From: Near Lecco, Italy
Registered: 2008-04-24
Posts: 258

Re: [SOLVED] notify-send from a daemon

The italian version of the config file (it was only a 2 mins editing..!)
/usr/share/halevt/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE halevt:Configuration [
    <!ENTITY HAS-LABEL "hal.volume.label & !hal.volume.label = ">
    <!ENTITY DEVICE "hal.block.device & hal.volume.is_disc = false">
    <!ENTITY CDROM "hal.block.device & hal.volume.is_disc & hal.volume.disc.is_blank = false & hal.volume.disc.has_data & hal.volume.disc.is_videodvd = false">
    <!ENTITY CDROM.SIGNAL "hal.block.device & hal.storage.drive_type = cdrom">
    <!ENTITY DVD "hal.block.device & hal.volume.is_disc & hal.volume.disc.is_blank = false & hal.volume.disc.has_data & hal.volume.disc.is_videodvd = true">
]>


<!-- Italian Translation by Berseker (berseker86 at gmail dot com)-->

<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">
    <!-- Mount CDRom devices -->
    <halevt:Device match="&CDROM; & hal.volume.is_mounted = false;">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p cdrom$hal.block.minor$ -o sync"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p cdrom$hal.block.minor$ -o sync"/>
    </halevt:Device>    
    
    <!-- Mount non-CDRom labeled devices -->
    <halevt:Device match="&DEVICE; & &HAS-LABEL; & hal.volume.is_mounted = false;">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p $hal.volume.label$ -o sync"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p $hal.volume.label$ -o sync"/>
    </halevt:Device>    
    
    <!-- Mount non-CDRom non-labeled devices -->
    <halevt:Device match="&DEVICE; & hal.volume.is_mounted = false; & hal.volume.label = ">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p disk$hal.block.minor$ -o sync"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p disk$hal.block.minor$ -o sync"/>
    </halevt:Device>        
    
    <!-- Handle CDRom eject button signal -->
    <halevt:Device match="&CDROM.SIGNAL;">     
        <halevt:Condition name="EjectPressed" exec="halevt-umount $hal.block.device$ -o sync; eject $hal.block.device$"/>
    </halevt:Device>    
    
    <!-- Notify CDRom labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.is_disc = true & !hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-cdrom --expire-time=3000 'Volume Inserito' '$hal.volume.label$ è stato montato in $hal.volume.mount_point$.' &>> /tmp/halevt.log"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-cdrom --expire-time=3000 'Volume Disinserito' '$hal.volume.label$ è stato smontato.' &>> /tmp/halevt.log"/>
        </halevt:Property>
    </halevt:Device>    
    
    <!-- Notify non-CDRom labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.is_disc = false & !hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Volume Inserito' '$hal.volume.label$ è stato montato in $hal.volume.mount_point$.' &>> /tmp/halevt.log"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Volume Disinserito' '$hal.volume.label$ è stato smontato.' &>> /tmp/halevt.log"/>
        </halevt:Property>
    </halevt:Device>
    
    <!-- Notify non-CDRom non-labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Volume Inserito' '$hal.block.device$ è stato montato in $hal.volume.mount_point$.' &>> /tmp/halevt.log"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Volume Disinserito' '$hal.block.device$ è stato smontato.' &>> /tmp/halevt.log"/>
        </halevt:Property>
    </halevt:Device>
</halevt:Configuration>

Offline

#8 2010-07-12 22:19:21

johanbcn
Member
Registered: 2010-01-03
Posts: 20

Re: [SOLVED] notify-send from a daemon

Berseker wrote:

I've seen only now your post.. great job, this is very useful and pretty for those that doesn't use a complete DE.
It would be great to translate your file in different languages (I'll try to translate this in italian if I find some spare time)

Thank you smile
If you are interested I have an updated version of the config file that more or less accomplishes what I wanted at the beginning.

First, there is the daemon config (only mounts the filesystems): /etc/halevt/halevt.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE halevt:Configuration [
    <!ENTITY HAS-LABEL "hal.volume.label & !hal.volume.label = ">
    <!ENTITY DEVICE "hal.block.device & hal.volume.is_disc = false">
    <!ENTITY CDROM "hal.block.device & hal.volume.is_disc & hal.volume.disc.is_blank = false & hal.volume.disc.has_data & hal.volume.disc.is_videodvd = false">
    <!ENTITY CDROM.SIGNAL "hal.block.device & hal.storage.drive_type = cdrom">
    <!ENTITY DVD "hal.block.device & hal.volume.is_disc & hal.volume.disc.is_blank = false & hal.volume.disc.has_data & hal.volume.disc.is_videodvd = true">
]>
<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">
    <!-- Mount CDRom devices -->
    <halevt:Device match="&CDROM; & hal.volume.is_mounted = false;">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p cdrom$hal.block.minor$"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p cdrom$hal.block.minor$"/>
    </halevt:Device>    
    
    <!-- Mount non-CDRom labeled devices -->
    <halevt:Device match="&DEVICE; & &HAS-LABEL; & hal.volume.is_mounted = false;">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p $hal.volume.label$"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p $hal.volume.label$"/>
    </halevt:Device>    
    
    <!-- Mount non-CDRom non-labeled devices -->
    <halevt:Device match="&DEVICE; & hal.volume.is_mounted = false; & hal.volume.label = ">
        <halevt:OnInit exec="halevt-mount -u $hal.udi$ -p disk$hal.block.minor$"/>
        <halevt:Insertion exec="halevt-mount -u $hal.udi$ -p disk$hal.block.minor$"/>
    </halevt:Device>        
    
    <!-- Handle CDRom eject button signal -->
    <halevt:Device match="&CDROM.SIGNAL;">     
        <halevt:Condition name="EjectPressed" exec="halevt-umount $hal.block.device$; eject $hal.block.device$"/>
    </halevt:Device>        
</halevt:Configuration>

(Notice that I have removed the -o sync parameter from the mount commands. Writing operations in automounted devices were ridiculously slower)

And then, there is the user config file (only manages the notify-send commands): $HOME/.halevt/halevt.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE halevt:Configuration [
    <!ENTITY HAS-LABEL "hal.volume.label & !hal.volume.label = ">
    <!ENTITY DEVICE "hal.block.device & hal.volume.is_disc = false">
    <!ENTITY CDROM "hal.block.device & hal.volume.is_disc & hal.volume.disc.is_blank = false & hal.volume.disc.has_data & hal.volume.disc.is_videodvd = false">
    <!ENTITY CDROM.SIGNAL "hal.block.device & hal.storage.drive_type = cdrom">
    <!ENTITY DVD "hal.block.device & hal.volume.is_disc & hal.volume.disc.is_blank = false & hal.volume.disc.has_data & hal.volume.disc.is_videodvd = true">
]>
<halevt:Configuration version="0.1" xmlns:halevt="http://www.environnement.ens.fr/perso/dumas/halevt.html">
    <!-- Notify CDRom labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.is_disc = true & !hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-cdrom --expire-time=3000 'Device mounted' '$hal.volume.label$ has been mounted in $hal.volume.mount_point$.'"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-cdrom --expire-time=3000 'Device unmounted' '$hal.volume.label$ has been unmounted.'"/>
        </halevt:Property>
    </halevt:Device>    
    
    <!-- Notify non-CDRom labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.is_disc = false & !hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Device mounted' '$hal.volume.label$ has been mounted in $hal.volume.mount_point$.'"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Device unmounted' '$hal.volume.label$ has been unmounted.'"/>
        </halevt:Property>
    </halevt:Device>
    
    <!-- Notify non-CDRom non-labeled mounts/umounts -->
    <halevt:Device match="hal.block.device & hal.volume.label = ">
        <halevt:Property name="hal.volume.is_mounted">
            <halevt:Action value="true" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Device mounted' '$hal.block.device$ has been  mounted in $hal.volume.mount_point$.'"/>
            <halevt:Action value="false" exec="notify-send --icon=gtk-harddisk --expire-time=3000 'Device unmounted' '$hal.block.device$ has been unmounted.'"/>
        </halevt:Property>
    </halevt:Device>
</halevt:Configuration>

This way, you have the daemon automounting at boot, without needing an X session, and a second instance of the daemon that only executes the notify-send messages once you enter xorg big_smile

Last edited by johanbcn (2010-07-12 22:37:43)

Offline

Board footer

Powered by FluxBB