File: callback_example.sh

package info (click to toggle)
tpb 0.6.4-8
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 2,228 kB
  • ctags: 751
  • sloc: ansic: 6,789; sh: 3,719; yacc: 318; makefile: 305
file content (162 lines) | stat: -rwxr-xr-x 3,692 bytes parent folder | download | duplicates (6)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/bin/sh
# This script is a skeleton for callback script to use with tpb.
# tpb can call a program on each button press and state change. It passes an
# identifier as first argument and the new state as second argument to the
# callback. So you can do fancy things :)
# Supported identifiers and states are:
#
# IDENTIFIER        STATES/VALUE
# thinkpad          pressed
# home              pressed
# search            pressed
# mail              pressed
# favorites         pressed
# reload            pressed
# abort             pressed
# backward          pressed
# forward           pressed
# wireless          pressed
# fn                pressed
# zoom              on, off
# thinklight        on, off
# display           lcd, crt, both
# expand            on, off
# brightness        PERCENT
# volume            PERCENT
# mute              on, off
# ac_power          connected, disconnected
# powermgt_ac       high, auto, manual
# powermgt_battery  high, auto, manual
case $1 in
  (thinkpad)
		echo "CALLBACK: $0 $1 $2 (should be thinkpad pressed)"
		;;
  (home)
		echo "CALLBACK: $0 $1 $2 (should be home pressed)"
		;;
  (search)
		echo "CALLBACK: $0 $1 $2 (should be search pressed)"
		;;
  (mail)
		echo "CALLBACK: $0 $1 $2 (should be mail pressed)"
		;;
  (favorites)
		echo "CALLBACK: $0 $1 $2 (should be favorites pressed)"
		;;
  (reload)
		echo "CALLBACK: $0 $1 $2 (should be reload pressed)"
		;;
  (abort)
		echo "CALLBACK: $0 $1 $2 (should be abort pressed)"
		;;
  (backward)
		echo "CALLBACK: $0 $1 $2 (should be backward pressed)"
		;;
  (forward)
		echo "CALLBACK: $0 $1 $2 (should be forward pressed)"
		;;
  (wireless)
		echo "CALLBACK: $0 $1 $2 (should be wireless pressed)"
		;;
  (fn)
		echo "CALLBACK: $0 $1 $2 (should be fn pressed)"
		;;
  (zoom)
		case $2 in
			(on)
				echo "CALLBACK: $0 $1 $2 (should be zoom on)"
				;;
			(off)
				echo "CALLBACK: $0 $1 $2 (should be zoom off)"
				;;
		esac
		;;
  (thinklight)
		case $2 in
			(on)
				echo "CALLBACK: $0 $1 $2 (should be thinklight on)"
				;;
			(off)
				echo "CALLBACK: $0 $1 $2 (should be thinklight off)"
				;;
		esac
		;;
  (display)
		case $2 in
			(lcd)
				echo "CALLBACK: $0 $1 $2 (should be display lcd)"
				;;
			(crt)
				echo "CALLBACK: $0 $1 $2 (should be display crt)"
				;;
			(both)
				echo "CALLBACK: $0 $1 $2 (should be display both)"
				;;
		esac
		;;
  (expand)
		case $2 in
			(on)
				echo "CALLBACK: $0 $1 $2 (should be expand on)"
				;;
			(off)
				echo "CALLBACK: $0 $1 $2 (should be expand off)"
				;;
		esac
		;;
  (brightness)
		echo "CALLBACK: $0 $1 $2 (should be brightness PERCENT)"
		;;
  (volume)
		echo "CALLBACK: $0 $1 $2 (should be volume PERCENT)"
		;;
  (mute)
		case $2 in
			(on)
				echo "CALLBACK: $0 $1 $2 (should be mute on)"
				;;
			(off)
				echo "CALLBACK: $0 $1 $2 (should be mute off)"
				;;
		esac
		;;
  (ac_power)
		case $2 in
			(connected)
				echo "CALLBACK: $0 $1 $2 (should be ac_power connected)"
				;;
			(disconnected)
				echo "CALLBACK: $0 $1 $2 (should be ac_power disconnected)"
				;;
		esac
		;;
  (powermgt_ac)
		case $2 in
			(high)
				echo "CALLBACK: $0 $1 $2 (should be powermgt_ac high)"
				;;
			(auto)
				echo "CALLBACK: $0 $1 $2 (should be powermgt_ac auto)"
				;;
			(manual)
				echo "CALLBACK: $0 $1 $2 (should be powermgt_ac manual)"
				;;
		esac
		;;
  (powermgt_battery)
		case $2 in
			(high)
				echo "CALLBACK: $0 $1 $2 (should be powermgt_battery high)"
				;;
			(auto)
				echo "CALLBACK: $0 $1 $2 (should be powermgt_battery auto)"
				;;
			(manual)
				echo "CALLBACK: $0 $1 $2 (should be powermgt_battery manual)"
				;;
		esac
		;;
	(*)
		echo "CALLBACK: $0 $1 $2 (TYPE UNKNOWN)"
		;;
esac