You are not logged in.

#1 2012-03-14 14:23:41

untitaker
Member
Registered: 2011-11-07
Posts: 18

Writing a rc.d script involving dbus and Xorg

I am trying to make a new rc.d script for the HDMI drivers of the chrontel-wetab-rpm package in the AUR: https://bbs.archlinux.org/post.php?fid=33

#!/bin/bash
# Copypasta from the ArchWiki and the wicd daemon script

. /etc/rc.conf
. /etc/rc.d/functions

DAEMON=tiitoo-hdmi
COMMAND=$DAEMON-wrapper
PROCESS=$DAEMON-daemon
LOGFILE=/tmp/$DAEMON-daemon.log
tiitoo-hdmi-wrapper() {
  if [ -z $1 ]; then
    echo "Parameter missing. Please edit /etc/conf.d/tiitoo-hdmi if you are using the daemon."
    exit 1
  else
    echo > $LOGFILE
    modprobe i2c-dev
    mv "$1" /dev/i2c-2

    # ensure that the SPDIF audio is on 
    amixer -c0 set "IEC958" on &>> $LOGFILE
    amixer -c0 set "IEC958 Default PCM" on &>> $LOGFILE
    dbus-launch $PROCESS &>> $LOGFILE # the daemon requires a dbus session, meh
  fi
}

[ -r /etc/conf.d/$DAEMON ] && . /etc/conf.d/$DAEMON


case "$1" in
 start)
   stat_busy "Starting $DAEMON"
   pkill -f $PROCESS
   $COMMAND $DEVICE &
   if [ $? = 0 ]; then
     add_daemon $DAEMON
     stat_done
   else
     cat $LOGFILE
     stat_fail
     exit 1
   fi
   ;;
 stop)
   stat_busy "Stopping $DAEMON"
   pkill -f $PROCESS
   if [ $? = 0 ]; then
     rm_daemon $DAEMON
     stat_done
   else
     stat_fail
     exit 1
   fi
   ;;
 restart)
   $0 stop
   sleep 1
   $0 start
   ;;
 *)
   echo "usage: $0 {start|stop|restart}"
   ;;
esac

However, when i run the daemon, the tiitoo-hdmi-daemon command keeps aborting with the following errors:

Simple mixer control 'IEC958',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [on]
Simple mixer control 'IEC958 Default PCM',0
  Capabilities: pswitch pswitch-joined penum
  Playback channels: Mono
  Mono: Playback [on]
Found device ID 0x56
Found revision ID 0x81
No protocol specified
No protocol specified
Can't open display :0.0

When i run the daemon script with /etc/rc.d/tiitoo-hdmi start instead of rc.d start tiitoo-hdmi, it works, so i think it somehow has something to do with my environment variables...

Offline

#2 2012-03-14 23:52:09

aking9
Member
Registered: 2009-03-30
Posts: 65

Re: Writing a rc.d script involving dbus and Xorg

please post the output of
env | grep -i iec

Offline

#3 2012-03-15 10:09:23

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Writing a rc.d script involving dbus and Xorg

untitaker wrote:

When i run the daemon script with /etc/rc.d/tiitoo-hdmi start instead of rc.d start tiitoo-hdmi, it works, so i think it somehow has something to do with my environment variables...

Yes. It does.  A simple look at /usr/sbin/rc.d would tell you that we nuke the environment before running control scripts. You should not be trying to run a user specific process this way.

Offline

#4 2012-03-15 12:35:03

untitaker
Member
Registered: 2011-11-07
Posts: 18

Re: Writing a rc.d script involving dbus and Xorg

The grep search didn't return anything (exit with code 1)

I know that i shouldn't make it environment specific (i've looked at the /usr/sbin/rc.d script too), but i somehow need a way to allow tiitoo-hdmi-daemon "open display :0.0" (whatever that is)

Offline

Board footer

Powered by FluxBB