diff options
author | jmcneill <jmcneill> | 2008-11-27 03:32:19 +0000 |
---|---|---|
committer | jmcneill <jmcneill> | 2008-11-27 03:32:19 +0000 |
commit | 8cc44c516da14c2af4631487784a11d13f261780 (patch) | |
tree | bd04573b2d628005472823fb4eeea46225f4a592 /sysutils/hal/files | |
parent | 160c5a6fbb3d3c0417970e3e463db979e2c1ec7f (diff) | |
download | pkgsrc-8cc44c516da14c2af4631487784a11d13f261780.tar.gz |
Add reboot, shutdown, suspend support. Bump PKGREVISION.
Diffstat (limited to 'sysutils/hal/files')
5 files changed, 130 insertions, 14 deletions
diff --git a/sysutils/hal/files/hald-netbsd/devinfo_misc.c b/sysutils/hal/files/hald-netbsd/devinfo_misc.c index 7cc20e4b1ff..e7c766b4fee 100644 --- a/sysutils/hal/files/hald-netbsd/devinfo_misc.c +++ b/sysutils/hal/files/hald-netbsd/devinfo_misc.c @@ -9,13 +9,16 @@ * **************************************************************************/ +#include <sys/types.h> +#include <sys/sysctl.h> + #ifdef HAVE_CONFIG_H # include <config.h> #endif +#include <sys/utsname.h> #include <stdio.h> #include <string.h> -#include <sys/utsname.h> #include "../osspec.h" #include "../logger.h" @@ -57,8 +60,10 @@ DevinfoDevHandler devinfo_default_handler = { static HalDevice * devinfo_computer_add(HalDevice *parent, const char *devnode, char *devfs_path, char *device_type) { - HalDevice *d, *local_d; + HalDevice *d; struct utsname un; + char acpi_supported_states[20]; + size_t len = sizeof(acpi_supported_states); if (strcmp (devnode, "mainbus0") != 0) { return (NULL); @@ -82,17 +87,19 @@ devinfo_computer_add(HalDevice *parent, const char *devnode, char *devfs_path, c devinfo_add_enqueue (d, devfs_path, &devinfo_computer_handler); - /* all devinfo devices belong to the 'local' branch */ - local_d = hal_device_new (); + if (sysctlbyname ("hw.acpi.supported_states", acpi_supported_states, &len, NULL, 0) == 0) { + hal_device_property_set_string (d, "power_management.type", "acpi"); + if (strstr (acpi_supported_states, "S3") != NULL) + hal_device_property_set_bool (d, "power_management.can_suspend", TRUE); + else + hal_device_property_set_bool (d, "power_management.can_suspend", FALSE); - hal_device_property_set_string (local_d, "info.parent", hal_device_get_udi (d)); - hal_device_property_set_string (local_d, "info.subsystem", "unknown"); - hal_device_property_set_string (local_d, "info.product", "Local devices"); - hal_device_property_set_string (local_d, "netbsd.device", devnode); + hal_device_property_set_bool (d, "power_management.can_hibernate", FALSE); + } - devinfo_add_enqueue (local_d, devnode, &devinfo_default_handler); + devinfo_add_enqueue (d, devnode, &devinfo_default_handler); - return (local_d); + return d; } static HalDevice * @@ -120,21 +127,23 @@ devinfo_cpu_add(HalDevice *parent, const char *devnode, char *devfs_path, char * static void devinfo_default_apply_quirks(HalDevice *d, const char *devnode) { + HalDevice *computer = hal_device_store_match_key_value_string (hald_get_gdl (), "info.udi", "/org/freedesktop/Hal/devices/computer"); /* acpiacad(4) */ if (strncmp (devnode, "acpiacad", 8) == 0) { + HAL_INFO (("%s: applying acpiacad quirks")); hal_device_add_capability (d, "ac_adapter"); /* acpibat(4) */ } else if (strncmp (devnode, "acpibat", 7) == 0) { - HalDevice *computer; - + HAL_INFO (("%s: applying acpibat quirks")); hal_device_add_capability (d, "battery"); hal_device_property_set_string (d, "battery.type", "primary"); - computer = hal_device_store_find(hald_get_gdl (), "/org/freedesktop/Hal/devices/computer"); - if (computer) + if (computer) { + HAL_INFO (("%s: applying acpibat computer quirks")); hal_device_property_set_string (computer, "system.formfactor", "laptop"); + } } } diff --git a/sysutils/hal/files/tools-netbsd/Makefile.am b/sysutils/hal/files/tools-netbsd/Makefile.am new file mode 100644 index 00000000000..e29d6956047 --- /dev/null +++ b/sysutils/hal/files/tools-netbsd/Makefile.am @@ -0,0 +1,40 @@ +## Process this file with automake to produce Makefile.in +# $NetBSD: Makefile.am,v 1.1 2008/11/27 03:32:19 jmcneill Exp $ + +AM_CPPFLAGS = \ + -DPACKAGE_LIBEXEC_DIR=\""$(libexecdir)"\" \ + -DPACKAGE_SYSCONF_DIR=\""$(sysconfdir)"\" \ + -DPACKAGE_DATA_DIR=\""$(datadir)"\" \ + -DPACKAGE_BIN_DIR=\""$(bindir)"\" \ + -DPACKAGE_LOCALSTATEDIR=\""$(localstatedir)"\" \ + -DPACKAGE_SCRIPT_DIR=\""$(libdir)/hal/scripts"\" \ + -DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \ + -I$(top_srcdir) -I$(top_srcdir)/libhal -I$(top_srcdir)/libhal-storage \ + @DBUS_CFLAGS@ @GLIB_CFLAGS@ @POLKIT_CFLAGS@ + +scriptdir = $(libdir)/hal/scripts/netbsd + +script_SCRIPTS = \ + hal-system-power-suspend-netbsd \ + hal-system-power-shutdown-netbsd \ + hal-system-power-reboot-netbsd + +EXTRA_DIST = $(script_SCRIPTS) + +check: + for f in $(script_SCRIPTS); do \ + echo -n "Validate bash syntax in $$f : "; \ + bash -n $(srcdir)/$$f 2> bash.error;\ + if test -s bash.error; then \ + echo failed; \ + cat bash.error; \ + rm -f bash.error; \ + exit 1; \ + else \ + echo ok; \ + rm -f bash.error; \ + fi; \ + done; + +clean-local : + rm -f *~ diff --git a/sysutils/hal/files/tools-netbsd/hal-system-power-reboot-netbsd b/sysutils/hal/files/tools-netbsd/hal-system-power-reboot-netbsd new file mode 100755 index 00000000000..7d1a62d1da5 --- /dev/null +++ b/sysutils/hal/files/tools-netbsd/hal-system-power-reboot-netbsd @@ -0,0 +1,19 @@ +#!/bin/sh +# $NetBSD: hal-system-power-reboot-netbsd,v 1.1 2008/11/27 03:32:19 jmcneill Exp $ + +unsupported() { + echo "org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported" >&2 + echo "No reboot command found" >&2 + exit 1 +} + +#Try for common tools +if [ -x "/sbin/shutdown" ] ; then + /sbin/shutdown -r now + exit $? +elif [ -x "/usr/sbin/shutdown" ] ; then + /usr/sbin/shutdown -r now + exit $? +else + unsupported +fi diff --git a/sysutils/hal/files/tools-netbsd/hal-system-power-shutdown-netbsd b/sysutils/hal/files/tools-netbsd/hal-system-power-shutdown-netbsd new file mode 100755 index 00000000000..d05d8bca9b2 --- /dev/null +++ b/sysutils/hal/files/tools-netbsd/hal-system-power-shutdown-netbsd @@ -0,0 +1,19 @@ +#!/bin/sh +# $NetBSD: hal-system-power-shutdown-netbsd,v 1.1 2008/11/27 03:32:19 jmcneill Exp $ + +unsupported() { + echo "org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported" >&2 + echo "No shutdown command found" >&2 + exit 1 +} + +#Try for common tools +if [ -x "/sbin/shutdown" ] ; then + /sbin/shutdown -p now + exit $? +elif [ -x "/usr/sbin/shutdown" ] ; then + /usr/sbin/shutdown -p now + exit $? +else + unsupported +fi diff --git a/sysutils/hal/files/tools-netbsd/hal-system-power-suspend-netbsd b/sysutils/hal/files/tools-netbsd/hal-system-power-suspend-netbsd new file mode 100755 index 00000000000..21b2ed38afc --- /dev/null +++ b/sysutils/hal/files/tools-netbsd/hal-system-power-suspend-netbsd @@ -0,0 +1,29 @@ +#!/bin/sh +# $NetBSD: hal-system-power-suspend-netbsd,v 1.1 2008/11/27 03:32:19 jmcneill Exp $ + +alarm_not_supported() { + echo org.freedesktop.Hal.Device.SystemPowerManagement.AlarmNotSupported >&2 + echo Waking the system up is not supported >&2 + exit 1 +} + +unsupported() { + echo org.freedesktop.Hal.Device.SystemPowerManagement.NotSupported >&2 + echo No suspend method found >&2 + exit 1 +} + +read seconds_to_sleep + +if [ -x /usr/sbin/apm ] ; then + if [ -e /var/run/apmdev ]; then + /usr/sbin/apm -z 2>/dev/null + else + /usr/sbin/apm -z -d 2>/dev/null + fi + RET=$? +else + unsupported +fi + +exit $RET |