Index: head/deskutils/tpb/Makefile =================================================================== --- head/deskutils/tpb/Makefile (revision 425044) +++ head/deskutils/tpb/Makefile (revision 425045) @@ -1,48 +1,47 @@ # Created by: Markus Brueffer # $FreeBSD$ PORTNAME= tpb PORTVERSION= 0.6.4 PORTREVISION= 11 CATEGORIES= deskutils MASTER_SITES= SAVANNAH MAINTAINER= ports@FreeBSD.org COMMENT= On-Screen-Display for hotkeys of IBM ThinkPads -LICENSE= GPLv2 +LICENSE= GPLv2+ +LICENSE_FILE= ${WRKSRC}/COPYING LIB_DEPENDS= libxosd.so:misc/xosd -OPTIONS_DEFINE= DOCS NLS -OPTIONS_SUB= yes - ONLY_FOR_ARCHS= i386 amd64 -USES= gmake iconv pkgconfig +USES= gmake iconv localbase pkgconfig GNU_CONFIGURE= yes CONFIGURE_ARGS= ${ICONV_CONFIGURE_ARG} +USE_XORG= x11 sm ice xext -CPPFLAGS+= -I${LOCALBASE}/include -LDFLAGS+= -L${LOCALABASE}/lib +OPTIONS_DEFINE= EXAMPLES NLS +OPTIONS_SUB= yes NLS_USES= gettext NLS_CONFIGURE_OFF= --disable-nls post-patch: .for i in man/tpb.1 src/cfg.h @${REINPLACE_CMD} -e \ 's|%%PREFIX%%|${PREFIX}|g ; \ s|%%LOCALBASE%%|${LOCALBASE}|g' ${WRKSRC}/${i} .endfor @${REINPLACE_CMD} -e \ 's|void test()||' ${WRKSRC}/configure post-install: - (cd ${WRKSRC}/doc && ${INSTALL_DATA} tpbrc \ - ${STAGEDIR}${PREFIX}/etc/tpbrc.default) - @${MKDIR} ${STAGEDIR}${DOCSDIR} - (cd ${WRKSRC}/doc && ${INSTALL_DATA} callback_example.sh \ - ${STAGEDIR}${DOCSDIR}) + ${INSTALL_DATA} ${WRKSRC}/doc/tpbrc ${STAGEDIR}${PREFIX}/etc/tpbrc.default + +post-install-EXAMPLES-on: + @${MKDIR} ${STAGEDIR}${EXAMPLESDIR} + ${INSTALL_DATA} ${WRKSRC}/doc/callback_example.sh ${STAGEDIR}${EXAMPLESDIR} .include Index: head/deskutils/tpb/files/patch-Makefile.in =================================================================== --- head/deskutils/tpb/files/patch-Makefile.in (revision 425044) +++ head/deskutils/tpb/files/patch-Makefile.in (revision 425045) @@ -1,11 +1,11 @@ ---- Makefile.in.orig Thu Jun 9 01:19:36 2005 -+++ Makefile.in Thu Jun 9 01:19:52 2005 -@@ -92,7 +92,7 @@ +--- Makefile.in.orig 2005-07-25 08:55:38 UTC ++++ Makefile.in +@@ -92,7 +92,7 @@ USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIB USE_NLS = @USE_NLS@ VERSION = @VERSION@ -SUBDIRS = doc intl po src man +SUBDIRS = intl po src man ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = config.h Index: head/deskutils/tpb/files/patch-man-tpb.1 =================================================================== --- head/deskutils/tpb/files/patch-man-tpb.1 (revision 425044) +++ head/deskutils/tpb/files/patch-man-tpb.1 (revision 425045) @@ -1,50 +1,50 @@ ---- man/tpb.1.orig 2005-07-25 10:40:53.000000000 +0200 -+++ man/tpb.1 2009-11-12 23:50:29.000000000 +0100 -@@ -7,7 +7,7 @@ +--- man/tpb.1.orig 2005-07-25 08:40:53 UTC ++++ man/tpb.1 +@@ -7,7 +7,7 @@ tpb \- program to use the IBM ThinkPad ( With TPB it is possible to bind a program to the ThinkPad, Mail, Home and Search button. TPB can also run a callback program on each state change with the changed state and the new state as options. So it is possible to trigger several actions on different events. -TPB has a on-screen display (OSD) to show volume, mute, brightness and some other informations. +TPB has an on-screen display (OSD) to show volume, mute, brightness and some other informations. Furthermore TPB supports a software mixer, as the R series ThinkPads have no hardware mixer to change the volume. .SH OPTIONS .TP 8 -@@ -94,7 +94,7 @@ +@@ -94,7 +94,7 @@ The priority of the configuration option builtin defaults .TP \(bu -configuration in /etc/tpbrc +configuration in %%PREFIX%%/etc/tpbrc .TP \(bu configuration in $HOME/.tpbrc -@@ -121,7 +121,7 @@ +@@ -121,7 +121,7 @@ Keywords are: .TP 8 .B NVRAM Should define the nvram device from where the information about the key states -is read. Default is to try /dev/nvram, followed by /dev/misc/nvram. +is read. Default is to try /dev/nvram. .TP 8 .B POLLTIME Defines the delay between polls in microseconds. -@@ -332,14 +332,18 @@ +@@ -332,14 +332,18 @@ Defines the alignment of the osd. Possible values are left, center and right. Default is left. .SH "NOTES" -Requires NVRAM device /dev/nvram. +Requires NVRAM device /dev/nvram on Linux. This must be enabled in your kernel. Although the device file must exist. The device file could be created with \'mknod /dev/nvram c 10 144\' +On FreeBSD you have to load the acpi_ibm(4) driver prior to using TPB. +If ACPI and in turn acpi_ibm(4) is not available, nvram(4) and apm(4) +are being used. + This program was developed on a Thinkpad Model T21. .SH EXAMPLE -tpb \-\-osd=off \-\-verbose \-\-thinkpad="xterm \-T ntpctl \-e ntpctl" +tpb \-\-osd=off \-\-verbose \-\-thinkpad="%%LOCALBASE%%/bin/xterm" .SH COPYRIGHT Copyright 2002-2005, Markus Braun .PP Index: head/deskutils/tpb/files/patch-src-Makefile.in =================================================================== --- head/deskutils/tpb/files/patch-src-Makefile.in (revision 425044) +++ head/deskutils/tpb/files/patch-src-Makefile.in (revision 425045) @@ -1,11 +1,11 @@ ---- src/Makefile.in.orig Thu Jun 9 00:42:42 2005 -+++ src/Makefile.in Thu Jun 9 00:45:44 2005 -@@ -106,7 +106,7 @@ +--- src/Makefile.in.orig 2005-07-25 08:55:38 UTC ++++ src/Makefile.in +@@ -106,7 +106,7 @@ PROGRAMS = $(bin_PROGRAMS) CPPFLAGS = @CPPFLAGS@ LDFLAGS = @LDFLAGS@ -LIBS = @LIBS@ +LIBS = @LIBS@ $(INTLLIBS) X_CFLAGS = @X_CFLAGS@ X_LIBS = @X_LIBS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ Index: head/deskutils/tpb/files/patch-src-cfg.c =================================================================== --- head/deskutils/tpb/files/patch-src-cfg.c (revision 425044) +++ head/deskutils/tpb/files/patch-src-cfg.c (revision 425045) @@ -1,17 +1,17 @@ ---- src/cfg.c.orig 2009-11-12 09:26:15.000000000 +0100 -+++ src/cfg.c 2009-11-12 08:33:55.000000000 +0100 -@@ -1548,12 +1548,14 @@ +--- src/cfg.c.orig 2005-07-18 14:15:59 UTC ++++ src/cfg.c +@@ -1548,12 +1548,14 @@ void find_nvram(config *cfg) /* {{{ */ _exit(1); } if((fdsc=open(cfg->nvram, O_RDONLY|O_NONBLOCK) == -1) && errno == ENOENT) { +#ifndef __FreeBSD__ /* Try devfs device */ if((cfg->nvram=strdup(DEFAULT_NVRAMDEV_DEVFS)) == NULL) { fputs(_("Not enough memory"),stderr); _exit(1); } fdsc = open(cfg->nvram, O_RDONLY|O_NONBLOCK); +#endif } if(fdsc != -1) { Index: head/deskutils/tpb/files/patch-src-cfg.h =================================================================== --- head/deskutils/tpb/files/patch-src-cfg.h (revision 425044) +++ head/deskutils/tpb/files/patch-src-cfg.h (revision 425045) @@ -1,11 +1,11 @@ ---- src/cfg.h.orig Mon May 30 00:06:16 2005 -+++ src/cfg.h Mon May 30 00:06:32 2005 -@@ -67,7 +67,7 @@ +--- src/cfg.h.orig 2005-07-18 14:15:59 UTC ++++ src/cfg.h +@@ -74,7 +74,7 @@ enum mode {MODE_COMMENT, MODE_INDENT, MO #ifdef SYSCONFDIR #define GLOBAL_CONFIG_FILE SYSCONFDIR "/tpbrc" #else /* SYSCONFDIR */ -#define GLOBAL_CONFIG_FILE "/etc/tpbrc" +#define GLOBAL_CONFIG_FILE "%%PREFIX%%/etc/tpbrc" #endif /* SYSCONFDIR */ #define PRIVATE_CONFIG_FILE ".tpbrc" Index: head/deskutils/tpb/files/patch-src-tpb.c =================================================================== --- head/deskutils/tpb/files/patch-src-tpb.c (revision 425044) +++ head/deskutils/tpb/files/patch-src-tpb.c (revision 425045) @@ -1,177 +1,177 @@ ---- src/tpb.c.orig 2005-07-18 16:15:59.000000000 +0200 -+++ src/tpb.c 2009-11-13 02:18:58.000000000 +0100 +--- src/tpb.c.orig 2005-07-18 14:15:59 UTC ++++ src/tpb.c @@ -34,6 +34,16 @@ #include #include "config.h" +#ifdef __FreeBSD__ +#include +#include +#include +#include +#ifdef __i386__ +#include +#endif +#endif + #if ENABLE_NLS #include #endif /* ENABLE_NLS */ -@@ -161,6 +171,9 @@ +@@ -161,6 +171,9 @@ int main(int argc, char **argv) /* {{{ * /* to initialize struct */ memset(&last_thinkpad_state, 0x00, sizeof(t_thinkpad_state)); if(get_nvram_state(&thinkpad_state) != 0) { +#ifdef __FreeBSD__ + fprintf(stderr, _("Neither acpi_ibm(4) nor nvram(4) driver loaded. Exiting...")); +#endif _exit(1); } if(cfg.apm == STATE_ON) { -@@ -449,6 +462,25 @@ +@@ -449,6 +462,25 @@ int main(int argc, char **argv) /* {{{ * #endif /* HAVE_LIBXOSD */ } /* }}} */ + /* determine the state of Bluetooth {{{ */ + if(thinkpad_state.bluetooth_toggle != last_thinkpad_state.bluetooth_toggle) { + if(cfg.verbose == STATE_ON) { + printf(_("Bluetooth is %s\n"), thinkpad_state.bluetooth_toggle == 1 ? _("on") : _("off")); + } + if(cfg.callback != NULL) { + snprintf(callback_cmd, sizeof(callback_cmd), "%s bluetooth %s", cfg.callback, thinkpad_state.bluetooth_toggle == 1 ? "on" : "off"); + if(fork_app(callback_cmd) != 0) { + _exit(0); + } + } +#ifdef HAVE_LIBXOSD + if(osd_ptr != NULL) { + xosd_display(osd_ptr, 0, XOSD_string, thinkpad_state.bluetooth_toggle == 1 ? _("Bluetooth enabled") : _("Bluetooth disabled")); + xosd_display(osd_ptr, 1, XOSD_string, ""); + } +#endif /* HAVE_LIBXOSD */ + } /* }}} */ + /* determine the state of display {{{ */ if((thinkpad_state.display_toggle != last_thinkpad_state.display_toggle || thinkpad_state.display_state != last_thinkpad_state.display_state) && -@@ -981,6 +1013,11 @@ +@@ -981,6 +1013,11 @@ Display *init_xgrabkey(void) /* {{{ */ int get_nvram_state(t_thinkpad_state *thinkpad_state) /* {{{ */ { static int fdsc = -1; /* -1 -> file not opened */ +#ifdef __FreeBSD__ + u_int n = 0; + size_t len = sizeof(n); + if ( fdsc != -1 || sysctlbyname("dev.acpi_ibm.0.hotkey", &n, &len, NULL, 0) == -1 ) { +#endif unsigned char buffer[114]; struct { int pos; -@@ -1040,13 +1077,51 @@ +@@ -1040,13 +1077,51 @@ int get_nvram_state(t_thinkpad_state *th thinkpad_state->powermgt_battery = (( buffer[0x39] & 0x38) >> 3); return 0; +#ifdef __FreeBSD__ + } + thinkpad_state->thinkpad_toggle = (thinkpad_state->thinkpad_toggle & ~0x01) | (( n & (1<<3)) >> 3); + thinkpad_state->zoom_toggle = (thinkpad_state->zoom_toggle & ~0x01) | (( n & (1<<4)) >> 4); + thinkpad_state->display_toggle = (thinkpad_state->display_toggle & ~0x01) | (( n & (1<<6)) >> 6); + thinkpad_state->home_toggle = (thinkpad_state->home_toggle & ~0x01) | (( n & (1<<0)) ); + thinkpad_state->search_toggle = (thinkpad_state->search_toggle & ~0x01) | (( n & (1<<1)) >> 1); + thinkpad_state->mail_toggle = (thinkpad_state->mail_toggle & ~0x01) | (( n & (1<<2)) >> 2); + thinkpad_state->hibernate_toggle = (thinkpad_state->hibernate_toggle & ~0x01) | (( n & (1<<7)) >> 7); + thinkpad_state->expand_toggle = (thinkpad_state->expand_toggle & ~0x01) | (( n & (1<<9)) >> 9); + thinkpad_state->brightness_toggle = (thinkpad_state->brightness_toggle & ~0x01) | (( n & (1<<10)) >> 10); + thinkpad_state->volume_toggle = (thinkpad_state->volume_toggle & ~0x01) | (( n & (1<<11)) >> 11); + + /* Don't fail if the wlan, bluetooth or thinklight sysctls are not present. They are generated dynamically */ + if ( sysctlbyname("dev.acpi_ibm.0.wlan", &n, &len, NULL, 0) != -1 ) + thinkpad_state->wireless_toggle = n; + + if ( sysctlbyname("dev.acpi_ibm.0.bluetooth", &n, &len, NULL, 0) != -1 ) + thinkpad_state->bluetooth_toggle = n; + + if ( sysctlbyname("dev.acpi_ibm.0.thinklight", &n, &len, NULL, 0) != -1 ) + thinkpad_state->thinklight_toggle = n; + + if ( sysctlbyname("dev.acpi_ibm.0.lcd_brightness", &n, &len, NULL, 0) == -1 ) + return -1; + thinkpad_state->brightness_level = n; + + if ( sysctlbyname("dev.acpi_ibm.0.volume", &n, &len, NULL, 0) == -1 ) + return -1; + thinkpad_state->volume_level = n; + + if ( sysctlbyname("dev.acpi_ibm.0.mute", &n, &len, NULL, 0) == -1 ) + return -1; + thinkpad_state->mute_toggle = n; + + return 0; +#endif } /* }}} */ /* get the current state from the apm subsystem */ int get_apm_state(t_thinkpad_state *thinkpad_state) /* {{{ */ { - unsigned int i; static int fdsc = -1; /* -1 -> file not opened */ +#ifndef __FreeBSD__ + unsigned int i; char buffer[38]; char *tokens[9]; -@@ -1122,7 +1197,30 @@ +@@ -1122,7 +1197,30 @@ int get_apm_state(t_thinkpad_state *thin thinkpad_state->ac_state = STATE_ON; break; } +#else + u_long addr; + size_t len = sizeof(addr); -+ + + if ( fdsc != -1 || sysctlbyname("hw.acpi.acline", &addr, &len, NULL, 0) == -1 ) { +#ifdef __i386__ + // Try APM + if(fdsc == -1) { /* if not already opened, open apm */ + if((fdsc = open("/dev/apm", O_RDONLY)) == -1) + return -1; + } - ++ + struct apm_info info; + if (ioctl(fdsc, APMIO_GETINFO, &info) == -1) + return -1; + + if (info.ai_acline > 2) + return -1; + + addr = info.ai_acline; +#endif + } + thinkpad_state->ac_state = (addr == 1) ? STATE_ON : STATE_OFF; +#endif return 0; } /* }}} */ -@@ -1285,6 +1383,13 @@ +@@ -1285,6 +1383,13 @@ void set_nvram_volume_level(t_thinkpad_s /* only use writeback to nvram when cfg.mixersteps is different from DEFAULT_MIXERSTEPS */ if(cfg.mixersteps != DEFAULT_MIXERSTEPS) { +#ifdef __FreeBSD__ + u_int n = thinkpad_state->volume_level; + + if (sysctlbyname("dec.acpi_ibm.0.volume", NULL, NULL, &n, sizeof(n)) != 0) + fprintf(stderr, _("Unable to set volume sysctl")); + else { +#endif /* open nvram */ if((fdsc = open(cfg.nvram, O_RDWR|O_NONBLOCK)) == -1) { fprintf(stderr, _("Unable to open device %s: "), cfg.nvram); -@@ -1326,8 +1431,10 @@ +@@ -1326,8 +1431,10 @@ void set_nvram_volume_level(t_thinkpad_s } close(fdsc); +#ifdef __FreeBSD__ + } +#endif } - return; } /* }}} */ Index: head/deskutils/tpb/files/patch-src-tpb.h =================================================================== --- head/deskutils/tpb/files/patch-src-tpb.h (revision 425044) +++ head/deskutils/tpb/files/patch-src-tpb.h (revision 425045) @@ -1,10 +1,10 @@ ---- src/tpb.h.orig Mon Jun 13 14:32:31 2005 -+++ src/tpb.h Mon Jun 13 14:44:47 2005 -@@ -70,6 +70,7 @@ +--- src/tpb.h.orig 2005-07-18 14:15:59 UTC ++++ src/tpb.h +@@ -70,6 +70,7 @@ typedef struct { unsigned int ac_state; /* ac connected */ unsigned int powermgt_ac; /* power management mode ac */ unsigned int powermgt_battery; /* power management mode battery */ + unsigned int bluetooth_toggle; /* bluetooth toggle */ } t_thinkpad_state; #endif /* __TPB_H__*/ Index: head/deskutils/tpb/pkg-plist =================================================================== --- head/deskutils/tpb/pkg-plist (revision 425044) +++ head/deskutils/tpb/pkg-plist (revision 425045) @@ -1,7 +1,7 @@ bin/tpb etc/tpbrc.default man/man1/tpb.1.gz -%%PORTDOCS%%%%DOCSDIR%%/callback_example.sh +%%PORTEXAMPLES%%%%EXAMPLESDIR%%/callback_example.sh %%NLS%%share/locale/da/LC_MESSAGES/tpb.mo %%NLS%%share/locale/de/LC_MESSAGES/tpb.mo %%NLS%%share/locale/ru/LC_MESSAGES/tpb.mo