diff -Nru /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/module_alsamixer.c /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/module_alsamixer.c --- /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/module_alsamixer.c 2007-03-12 11:25:33.000000000 +0100 +++ /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/module_alsamixer.c 2007-03-12 11:25:34.000000000 +0100 @@ -505,6 +505,7 @@ { struct moddata_alsamixer *base = &modbase_alsamixer; int code, value, mod, step; + static int first = 0; code = (int) tagfind (taglist, TAG_KEYCODE, 0); value = (int) tagfind (taglist, TAG_KEYREPEAT, 0); @@ -520,23 +521,15 @@ } else return; /* check whether gnome-settings-daemon is running */ - pid_t killall_pid = fork(); - if (killall_pid == 0) { - execl ("/usr/bin/killall", "killall", "-q", "-s", "0", "gnome-settings-daemon", NULL); - perror("could not execute killall"); - exit (1); - } else if (killall_pid > 0) { - int status; - if (wait (&status) > 0) { - if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { - print_msg (PBB_WARN, _("Ignoring volume control key since gnome-settings-daemon is running\n")); - return; - } - } else - perror("wait on killall"); - } else - perror ("forking killall"); - + if ( daemon_running("gnome-settings-daemon")) { + if (!first) { + /* spam syslog only once */ + first = 1; + print_msg (PBB_WARN, _("Ignoring volume control key since gnome-settings-daemon is running\n")); + } + return; + } + first = 0; if ((step == 0) || (mod & MOD_SHIFT)) alsamixer_set_and_send(ALSAMIXER_REL, step); /* mute and fine tuning */ else diff -Nru /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/module_cdrom.c /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/module_cdrom.c --- /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/module_cdrom.c 2007-03-12 11:25:33.000000000 +0100 +++ /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/module_cdrom.c 2007-03-12 11:25:34.000000000 +0100 @@ -311,6 +311,12 @@ int fd, err = 0, rc = 0; unsigned int t1, t2; char *mp; + int ejectok = 0; + + /* assume that gnome shortcut is set */ + if ( daemon_running("gnome-settings-daemon")) { + return rc; + } singletag_to_clients(CHANGEVALUE, TAG_EJECTCD, 0); /* busy */ if ((mp = cdrom_getmountpoint(base->cdromdev))) @@ -318,6 +324,8 @@ err = call_script ("/usr/bin/eject %.30s", mp); if (err) err = call_script ("/bin/umount %.30s", mp); + else + ejectok = 1; } #if defined(DEBUG) && CDROM @@ -332,6 +340,10 @@ printf ("capabilities: %x\n", err); #endif err = ioctl (fd, CDROM_DRIVE_STATUS); + if (ejectok) { + /* /bin/eject already ejected the drive */ + err = 1; + } switch (err) { case 2: /* CDS_TRAY_OPEN */ default: @@ -351,7 +363,9 @@ #if defined(DEBUG) && CDROMPERF t1 = cdrom_gettime (); #endif - ioctl (fd, CDROMEJECT); + if (!ejectok) { + ioctl (fd, CDROMEJECT); + } #if defined(DEBUG) && CDROMPERF t2 = cdrom_gettime (); printf ("open Tray : %4d (%4u-%4u)\n", t2-t1, t2, t1); diff -Nru /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/module_powersave.c /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/module_powersave.c --- /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/module_powersave.c 2007-03-12 11:25:33.000000000 +0100 +++ /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/module_powersave.c 2007-03-12 11:25:34.000000000 +0100 @@ -373,20 +373,9 @@ /* check whether gnome-power-manager is running */ int gpm_running = 0; - pid_t killall_pid = fork(); - if (killall_pid == 0) { - execl ("/usr/bin/killall", "killall", "-q", "-s", "0", "gnome-power-manager", NULL); - perror("could not execute killall"); - exit (1); - } else if (killall_pid > 0) { - int status; - if (wait (&status) > 0) { - if (WIFEXITED(status) && WEXITSTATUS(status) == 0) - gpm_running = 1; - } else - perror("wait on killall"); - } else - perror ("forking killall"); + if (daemon_running("gnome-power-manager")) { + gpm_running = 1; + } while (taglist->tag != TAG_END) { switch (taglist->tag) { diff -Nru /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/support.c /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/support.c --- /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/support.c 2006-09-24 16:41:41.000000000 +0200 +++ /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/support.c 2007-03-12 11:25:34.000000000 +0100 @@ -281,3 +281,27 @@ return rc; } +/* check if another process is running as both pbbuttonsd and gnome want to deal with media keys, + power saving and so on. +*/ +int +daemon_running(char *cmd) +{ + pid_t killall_pid = fork(); + + if (killall_pid == 0) { + execl ("/usr/bin/killall", "killall", "-q", "-s", "0", cmd, NULL); + perror("could not execute killall"); + exit (1); + } else if (killall_pid > 0) { + int status; + if (wait (&status) > 0) { + if (WIFEXITED(status) && WEXITSTATUS(status) == 0) { + return 1; + } + } else + perror("wait on killall"); + } else + perror ("forking killall"); + return 0; +} diff -Nru /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/support.h /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/support.h --- /tmp/DpUq68Xkv0/pbbuttonsd-0.7.9/src/support.h 2006-01-21 19:05:53.000000000 +0100 +++ /tmp/1n5PJQ89iA/pbbuttonsd-0.7.9/src/support.h 2007-03-12 11:25:34.000000000 +0100 @@ -28,5 +28,6 @@ /* prototypes */ int copy_path (char *source, char *dest, int type, int flags); int call_script (char* template, ...); +int daemon_running(char *cmd); #endif /* INCLUDE_SUPPORT_H */