Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to check the existence and the validity of /dev/input/event* #47

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 33 additions & 4 deletions debian/raspi-config.init
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,46 @@
# Description:
### END INIT INFO

list_valid_events() {
events=
for x in /dev/input/event*; do
if [ -c "$x" ] && dd if="$x" of=/dev/null count=0 >/dev/null 2>/dev/null; then
events="$events $x"
fi
done

if [ -n "$events" ]; then
echo $events
return 0
else
return 1
fi
}

. /lib/lsb/init-functions

case "$1" in
start)
log_daemon_msg "Checking if shift key is held down"
timeout 1 thd --dump /dev/input/event* | grep -q "LEFTSHIFT\|RIGHTSHIFT"
EVENTS=$(list_valid_events)
if [ $? -eq 0 ]; then
log_daemon_msg "Checking if shift key is held down"
timeout 1 thd --dump $EVENTS | grep -q "LEFTSHIFT\|RIGHTSHIFT"
if [ $? -eq 0 ]; then
printf " Yes."
true
else
printf " No."
false
fi
else
log_daemon_msg "Keyboard is not connected"
false
fi
if [ $? -eq 0 ]; then
printf " Yes. Not enabling ondemand scaling governor"
printf " Not enabling ondemand scaling governor"
log_end_msg 0
else
printf " No. Switching to ondemand scaling governor"
printf " Switching to ondemand scaling governor"
SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
if [ -e $SYS_CPUFREQ_GOVERNOR ]; then
echo "ondemand" > $SYS_CPUFREQ_GOVERNOR
Expand Down