#!/usr/bin/env perl # dbus-launch.wrapper - Wrapper for "dbus-launch" # License: BSD-style (for this file only) # Revision: 111112 #--------------------------------------------------------------------- # module setup #--------------------------------------------------------------------- require 5.6.1; use strict; use Carp; use warnings; # Trap warnings $SIG {__WARN__} = sub { die @_; }; #--------------------------------------------------------------------- # basic constants #--------------------------------------------------------------------- use constant ZERO => 0; # Zero use constant ONE => 1; # One use constant FALSE => 0; # Boolean FALSE use constant TRUE => 1; # Boolean TRUE #--------------------------------------------------------------------- # program parameters #--------------------------------------------------------------------- # $EXEFILE = Absolute path for target executable # $PIDFILE = Absolute path for PID file # $EVSETUP_SCRIPT = Absolute path for environment-variables script my $CFGFILE = '__META_PREFIX__/share/dbus-1/session.conf'; my $EXEFILE = '__META_PREFIX__/bin/dbus-launch.bin'; my $PIDFILE = '/var/run/dbus/pid'; my $EVSETUP_DIR = '/var/dbus'; my $EVSETUP_SCRIPT = '/var/dbus/dbusenv.sh'; #--------------------------------------------------------------------- # main routine #--------------------------------------------------------------------- sub Main { my $str; # Scratch system ("mkdir -p $EVSETUP_DIR"); $str = `/bin/ps ax 2>&1`; # Get "/bin/ps ax" output # Safety measure $str = "" unless defined $str; if ($str !~ m@\bdbus-daemon\b@) { unlink $PIDFILE; unlink $EVSETUP_SCRIPT; } my $has_syntax = FALSE; $str = ""; for (@ARGV) { $has_syntax = TRUE if m@^--\w+-syntax\b@; $str .= " \"$_\""; } $str .= ' --sh-syntax' unless $has_syntax; $str .= " --config-file=$CFGFILE"; $str = `$EXEFILE $str`; $str = "" unless defined $str; my $ExitStatus = $?; my ($DBUS_SESSION_BUS_ADDRESS ) = $str =~ m@DBUS_SESSION_BUS_ADDRESS\W+'([^']+)'@; my ($DBUS_SESSION_BUS_PID ) = $str =~ m@DBUS_SESSION_BUS_PID=(\d+)@; my ($DBUS_SESSION_BUS_WINDOWID ) = $str =~ m@DBUS_SESSION_BUS_WINDOWID=(\d+)@; if (!defined ($DBUS_SESSION_BUS_ADDRESS)) { exit $ExitStatus; } $str =~ s@\s*\z@\n@s; print $str; open (OFD, ">$EVSETUP_SCRIPT") || die "Error: Couldn't open for writing: $!\n$EVSETUP_SCRIPT"; print OFD << "END"; DBUS_SESSION_BUS_ADDRESS='$DBUS_SESSION_BUS_ADDRESS'; export DBUS_SESSION_BUS_ADDRESS; END print OFD << "END" if defined $DBUS_SESSION_BUS_PID; DBUS_SESSION_BUS_PID=$DBUS_SESSION_BUS_PID; END print OFD << "END" if defined $DBUS_SESSION_BUS_WINDOWID; DBUS_SESSION_BUS_WINDOWID=$DBUS_SESSION_BUS_WINDOWID; END close OFD; #--------------------------------------------------------------------- $ENV {'DBUS_SESSION_BUS_ADDRESS'} = $DBUS_SESSION_BUS_ADDRESS; if (defined ($DBUS_SESSION_BUS_PID)) { $ENV {'DBUS_SESSION_BUS_PID'} = $DBUS_SESSION_BUS_PID; } if (defined ($DBUS_SESSION_BUS_WINDOWID)) { $ENV {'DBUS_SESSION_BUS_WINDOWID'} = $DBUS_SESSION_BUS_WINDOWID; } system << "END"; __META_PRODTREE__/xfconf/lib/xfce4/xfconf/xfconfd >& /tmp/xfconfd.log & END #--------------------------------------------------------------------- exit $ExitStatus; } #--------------------------------------------------------------------- # main program #--------------------------------------------------------------------- &Main(); # Call the main routine exit ONE; # Shouldn't be reached