Name:           tpb
Version:        0.6.4
Release:        2%{?_dist_release}
Summary:        IBM ThinkPad button support utility
Summary(ja):	IBM ThinkPad ボタンサポートユーティリティ
Group:          System Environment/Base
License:        GPL
URL:            http://www.nongnu.org/tpb/
Source0:        http://savannah.nongnu.org/download/tpb/tpb-%{version}.tar.gz
Source1:        http://savannah.nongnu.org/download/tpb/tpb-%{version}.tar.gz.sig
Patch0:         %{name}-defaultconfig.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-root

BuildRequires:  libxosd-devel >= 2.0.0
BuildRequires:  xorg-x11-devel
BuildRequires:  gettext
BuildRequires:  libXt-devel

Requires:       xorg-x11-xinit
Requires:       udev
Requires:       MAKEDEV

%description
With TPB it is possible to bind a program to the ThinkPad, Mail, Home
and Search buttons. 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 information.  Furthermore TPB supports a software mixer, as the
R series ThinkPads have no hardware mixer to change the volume.


%prep
%setup -q
%patch0 -p0

# Start tpb at X startup:
cat <<EOF > %{name}.xinit
#!/bin/sh
%{_bindir}/tpb -d
EOF

# For the initial MAKEDEV at post-install time, and possibly later:
cat <<EOF > %{name}.makedev
# Custom permissions for nvram for use with tpb(1).
c 664 root root         10 144  1   1 nvram
EOF

# Permissions fixup:
cat <<EOF > %{name}.rules
# Custom permissions for nvram for use with tpb(1).
KERNEL=="nvram", MODE="0664"
EOF

%build
%configure
make %{?_smp_mflags}


%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
install -Dm 755 %{name}.xinit \
  $RPM_BUILD_ROOT%{_sysconfdir}/X11/xinit/xinitrc.d/%{name}.sh
install -Dpm 644 %{name}.rules \
  $RPM_BUILD_ROOT%{_sysconfdir}/udev/rules.d/90-%{name}.rules
install -Dpm 644 %{name}.makedev \
  $RPM_BUILD_ROOT%{_sysconfdir}/makedev.d/zz_%{name}
%find_lang %{name}


%clean
rm -rf $RPM_BUILD_ROOT


%files -f %{name}.lang
%defattr(-,root,root,-)
%doc ChangeLog COPYING CREDITS README doc/callback_example.sh doc/nvram.txt
%config %{_sysconfdir}/X11/xinit/xinitrc.d/%{name}.sh
%config(noreplace) %{_sysconfdir}/tpbrc
%config(noreplace) %{_sysconfdir}/udev/rules.d/*-%{name}.rules
%config(noreplace) %{_sysconfdir}/makedev.d/*%{name}
%{_bindir}/tpb
%{_mandir}/man1/tpb.1*

# Note: need read access here.
#%attr(644,root,root) %dev(c,10,144) /dev/nvram


%changelog
* Wed Sep 23 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.6.4-2
- added nvram rules
- added Requires: udev, MAKEDEV

* Fri Jul 17 2009 Toshiharu Kudoh <toshi.kd2@gmail.com> 0.6.4-1vl5
- new upstream release
- changed XOrg-devel to xorg-x11-devel
- added BuildRequires: libXt-devel, Requires: xorg-x11-xinit

* Sun Oct 12 2008 Shu KONNO <owa@bg.wakwak.com> 0.6.3-3vl5
- applied new versioning policy, spec in utf-8

* Sat Sep 11 2004 Kunio Murasawa <murasawa@fa2.so-net.ne.jp> 0.6.3-2vl1
- based on Fedora
- new upstream release
- fixed BuildRoot, BuildRequires
- delete Epoch
- added summary(ja)

* Wed Jun  2 2004 Ville Skytta <ville.skytta at iki.fi> - 0:0.6.2-0.fdr.2
- Rename xinit scriptlet to tpb.sh (bug 1227, bugzilla.redhat.com/122869).

* Wed May 19 2004 Ville Skytta <ville.skytta at iki.fi> - 0:0.6.2-0.fdr.1
- Update to 0.6.2.
- Improve default configuration.
- Remove LD_ASSUME_KERNEL hack.

* Mon Jan 19 2004 Ville Skytta <ville.skytta at iki.fi> - 0:0.6.1-0.fdr.1
- Update to 0.6.1.

* Mon Nov 24 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.6.0-0.fdr.3
- Don't use MAKEDEV to create /dev/nvram.

* Wed Oct 22 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.6.0-0.fdr.2
- Add LD_ASSUME_KERNEL=2.4.1 workaround to xinit script.
  http://savannah.nongnu.org/bugs/?func=detailbug&bug_id=3260&group_id=2320

* Mon Aug 11 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.6.0-0.fdr.1
- Update to 0.6.0.

* Tue May 27 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.5.1-0.fdr.4
- Make /dev/nvram readable again (#296).

* Sun May 18 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.5.1-0.fdr.3
- Use MAKEDEV for creating the nvram device node and own it.
- Mark xinit file as config to make rpmlint happy.
- %%{buildroot} -> $RPM_BUILD_ROOT.
- Make the build honor $RPM_OPT_FLAGS.

* Sat Apr 19 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.5.1-0.fdr.2
- Don't require tpctl (#177).

* Fri Apr 11 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.5.1-0.fdr.1
- Update to 0.5.1.

* Sun Apr  6 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.5.0-0.fdr.1
- Update to 0.5.0.
- Save .spec in UTF-8.

* Sun Mar 30 2003 Ville Skytta <ville.skytta at iki.fi> - 0:0.4.2-0.fdr.1
- Rebuild according to Fedora RC3 guidelines.

* Sat Feb  8 2003 Ville Skytta <ville.skytta at iki.fi> - 0.4.2-1.fedora.1
- First Fedora release.
