diff --git a/pkg/bin/makebin b/pkg/bin/makebin index fdc4eae..a5296cb 100755 --- a/pkg/bin/makebin +++ b/pkg/bin/makebin @@ -64,6 +64,14 @@ package() { install -D -m644 "target/_surface" "$pkgdir/shell-completions/surface.zsh" install -D -m644 "target/surface.fish" "$pkgdir/shell-completions/surface.fish" + # copy service files + install -D -m644 "systemd/surface-rapl.service" "$pkgdir/usr/lib/systemd/system/surface-rapl.service" + install -D -m744 "systemd/surface-rapl.sh" "$pkgdir/usr/libexec/surface-rapl.sh" + mkdir -p "$pkgdir/usr/lib/systemd/system/multi-user.target.wants" + ln -sT "../surface-rapl.service" "$pkgdir/usr/lib/systemd/system/multi-user.target.wants/surface-rapl.service" + mkdir -p "$pkgdir/usr/lib/systemd/system/suspend.target.wants" + ln -sT "../surface-rapl.service" "$pkgdir/usr/lib/systemd/system/suspend.target.wants/surface-rapl.service" + # copy license install -D -m644 "LICENSE" "$pkgdir/LICENSE" diff --git a/pkg/deb/.gitignore b/pkg/deb/.gitignore index cbccad7..b7c5f38 100644 --- a/pkg/deb/.gitignore +++ b/pkg/deb/.gitignore @@ -3,3 +3,4 @@ src/ *.buildinfo *.changes *.deb +*.ddeb diff --git a/pkg/deb/debian/rules b/pkg/deb/debian/rules index 25af30a..3a8b4fd 100755 --- a/pkg/deb/debian/rules +++ b/pkg/deb/debian/rules @@ -20,5 +20,13 @@ override_dh_install: install -D -m644 "target/_surface" "${pkgdir}/usr/share/zsh/vendor-completions/_surface" install -D -m644 "target/surface.fish" "${pkgdir}/usr/share/fish/vendor_completions.d/surface.fish" + # service files + install -D -m644 "systemd/surface-rapl.service" "${pkgdir}/usr/lib/systemd/system/surface-rapl.service" + install -D -m744 "systemd/surface-rapl.sh" "${pkgdir}/usr/libexec/surface-rapl.sh" + mkdir -p "${pkgdir}/usr/lib/systemd/system/multi-user.target.wants" + ln -sT "../surface-rapl.service" "${pkgdir}/usr/lib/systemd/system/multi-user.target.wants/surface-rapl.service" + mkdir -p "${pkgdir}/usr/lib/systemd/system/suspend.target.wants" + ln -sT "../surface-rapl.service" "${pkgdir}/usr/lib/systemd/system/suspend.target.wants/surface-rapl.service" + %: dh $@ diff --git a/pkg/fedora/surface-control.spec b/pkg/fedora/surface-control.spec index c27adf5..2965a0a 100644 --- a/pkg/fedora/surface-control.spec +++ b/pkg/fedora/surface-control.spec @@ -31,6 +31,12 @@ install -D -m755 "target/release/surface" "%{buildroot}/usr/bin/surface" install -D -m644 "target/surface.bash" "%{buildroot}/usr/share/bash-completion/completions/surface" install -D -m644 "target/_surface" "%{buildroot}/usr/share/zsh/site-functions/_surface" install -D -m644 "target/surface.fish" "%{buildroot}/usr/share/fish/vendor_completions.d/surface.fish" +install -D -m644 "systemd/surface-rapl.service" "%{buildroot}/usr/lib/systemd/system/surface-rapl.service" +install -D -m744 "systemd/surface-rapl.sh" "%{buildroot}/usr/libexec/surface-rapl.sh" +mkdir -p "%{buildroot}/usr/lib/systemd/system/multi-user.target.wants" +ln -sT "../surface-rapl.service" "%{buildroot}/usr/lib/systemd/system/multi-user.target.wants/surface-rapl.service" +mkdir -p "%{buildroot}/usr/lib/systemd/system/suspend.target.wants" +ln -sT "../surface-rapl.service" "%{buildroot}/usr/lib/systemd/system/suspend.target.wants/surface-rapl.service" %files /usr/bin/surface diff --git a/systemd/surface-rapl.service b/systemd/surface-rapl.service new file mode 100644 index 0000000..31a415a --- /dev/null +++ b/systemd/surface-rapl.service @@ -0,0 +1,11 @@ +[Unit] +Description=Undoes firmware throttling processor after low-battery boot/resume +After=suspend.target + +[Service] +Type=oneshot +ExecStart=/usr/libexec/surface-rapl.sh + +[Install] +WantedBy=multi-user.target +WantedBy=suspend.target diff --git a/systemd/surface-rapl.sh b/systemd/surface-rapl.sh new file mode 100644 index 0000000..fce45dd --- /dev/null +++ b/systemd/surface-rapl.sh @@ -0,0 +1,3 @@ +#!/bin/sh +target=/sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/constraint_2_power_limit_uw +[ -f "$target" ] && echo 0 > "$target" || :