csync-git
[mirrors/ArchLinux-Packages.git] / laptop-init-script / PKGBUILD
1 # Contributor: Thomas Mudrunka <harvie@@email..cz>
2 # You can also contact me on http://blog.harvie.cz/
3
4 # TODO:
5 # - sdparm + hdparm support
6
7 pkgname=laptop-init-script
8 pkgver=1.1
9 pkgrel=1
10 pkgdesc="Small rc.d script for enabling/disabling cpufrequtils, pm-utils, laptop-mode-tools and hdparm optimalizations from init (rc.conf)"
11 arch=('any')
12 license=('GPL')
13 url="http://wiki.archlinux.org/index.php/Laptop-init-script"
14 depends=('cpufrequtils' 'pm-utils' 'laptop-mode-tools' 'hdparm' 'sdparm')
15
16 build() {
17 mkdir -p ${pkgdir}/etc/rc.d
18
19 cat > ${pkgdir}/etc/rc.d/laptop-init <<"EOF"
20 #!/bin/bash
21 #universal daemon controller
22 # general config
23 . /etc/rc.conf
24 . /etc/rc.d/functions
25
26 cpufreq-set-all() {
27 cpus=$(sed -ne 's/^processor.* \([0-9]\+\)$/\1/p' /proc/cpuinfo)
28 for cpu in $cpus
29 do
30 cpufreq-set -c $cpu -g $1
31 done
32 }
33
34 case "$1" in
35 start)
36 stat_busy "Enabling cpufreq CPU scaling"
37 #cpufreq-set-all conservative #less dynamic (saving more power, but slooooow)
38 cpufreq-set-all ondemand #more dynamic (saving power, when speed is not needed)
39 stat_done
40 stat_busy "Entering laptop mode"
41 echo 1 > /proc/sys/vm/laptop_mode
42 stat_done
43 stat_busy "Launching pm-powersave true"
44 pm-powersave true
45 stat_done
46 ;;
47 stop)
48 stat_busy "Disabling cpufreq CPU scaling"
49 cpufreq-set-all performance
50 stat_done
51 stat_busy "Leaving laptop mode"
52 echo 0 > /proc/sys/vm/laptop_mode
53 stat_done
54 stat_busy "Launching pm-powersave false"
55 pm-powersave false
56 stat_done
57 ;;
58 restart)
59 $0 stop
60 sleep 1
61 $0 start
62 ;;
63 *)
64 echo "usage: $0 {start|stop|restart}"
65 esac
66
67 EOF
68
69 chmod -R 755 ${pkgdir}/
70 }
This page took 0.252904 seconds and 4 git commands to generate.