-
Notifications
You must be signed in to change notification settings - Fork 0
/
ubuntu-tp-smapi-install
executable file
·67 lines (55 loc) · 1.59 KB
/
ubuntu-tp-smapi-install
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/perl
use strict;
use warnings;
die "run as root, please\n" if not `whoami` eq "root\n";
#installs tp-smapi from source, compiles it, and patches it to sorta work on
# w520, w510, t520, etc.
# {it aborts loading the module unless its in the whitelist}
system "apt-get install tp-smapi-source";
system
"echo 'options thinkpad_ec force_io=1' > " .
"/etc/modprobe.d/tp_smapi.conf";
system "modprobe -a tp_smapi hdaps";
my $w520_patch = '
462a463
> TP_DMI_MATCH("LENOVO", "ThinkPad"),
';
open FH, "> /tmp/tp_smapi-w520.patch";
print FH $w520_patch;
close FH;
my $srcDir = '/usr/src/modules/tp-smapi';
if(not -e $srcDir){
$srcDir = '/usr/src/tp-smapi-0.40';
}
print "\n\n";
my $ecFile = "$srcDir/thinkpad_ec.c";
if(-e "$ecFile"){
system "patch $ecFile /tmp/tp_smapi-w520.patch";
}else{
print "Could not find tp-smapi-source to patch the " .
"whitelist for newer Thinkpads, e.g.: W520";
}
print "\n\n";
system "module-assistant prepare tp-smapi";
system "module-assistant auto-install tp-smapi -f -O";
system "modprobe tp-smapi";
open FH, '< /etc/modules';
my @lines = <FH>;
my @newlines;
for my $line(@lines){
push @newlines, $line if $line !~ /^(tp-smapi|hdaps)\n?$/;
}
push @newlines, "tp-smapi\n";
push @newlines, "hdaps\n";
close FH;
open FH, '> /etc/modules';
print FH @newlines;
close FH;
system "chmod o+w /etc/modules";
system
"echo 'KERNEL==\"event[0-9]*\", " .
"ATTRS{phys}==\"hdaps/input1\"," .
"ATTRS{modalias}==\"input:b0019v1014p5054e4801-*\",".
"SYMLINK+=\"input/hdaps/accelerometer-event\"'".
" | sudo tee /etc/udev/rules.d/51-hdaps.rules";
system "update-initramfs -u";