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

add systemd service #50

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Source: raspi-config
Section: unknown
Priority: extra
Maintainer: Alex Bradbury <asb@asbradbury.org>
Build-Depends: debhelper (>= 8.0.0)
Build-Depends: debhelper (>= 8.0.0), dh-systemd
Standards-Version: 3.9.2
Homepage: https://github.com/asb/raspi-config
#Vcs-Git: git://git.debian.org/collab-maint/raspi-config.git
Expand Down
22 changes: 14 additions & 8 deletions debian/raspi-config.init
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,10 @@
# Description:
### END INIT INFO

. /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"
do_start() {
timeout 1 thd --dump /dev/input/event* 2>&1 | grep -q "LEFTSHIFT\|RIGHTSHIFT"
if [ $? -eq 0 ]; then
printf " Yes. Not enabling ondemand scaling governor"
log_end_msg 0
else
printf " No. Switching to ondemand scaling governor"
SYS_CPUFREQ_GOVERNOR=/sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
Expand All @@ -27,8 +22,19 @@ case "$1" in
echo 100000 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_rate
echo 50 > /sys/devices/system/cpu/cpufreq/ondemand/sampling_down_factor
fi
log_end_msg 0
fi
}

case "$1" in
start)
. /lib/lsb/init-functions
log_daemon_msg "Checking if shift key is held down"
do_start
log_end_msg 0
;;
systemd-start)
echo "Checking if shift key is held down"
do_start
;;
*)
echo "Usage: $0 start" >&2
Expand Down
13 changes: 13 additions & 0 deletions debian/raspi-config.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Switch to ondemand cpu governor (unless shift key is pressed)
DefaultDependencies=no
Before=sysinit.target
After=udev.service mountkernfs.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/etc/init.d/raspi-config systemd-start

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@
#export DH_VERBOSE=1

%:
dh $@
dh $@ --with systemd