Skip to content

Instantly share code, notes, and snippets.

@tbart
Created December 4, 2018 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbart/1c34657b3c19fb02f819ea020787af83 to your computer and use it in GitHub Desktop.
Save tbart/1c34657b3c19fb02f819ea020787af83 to your computer and use it in GitHub Desktop.
ebuild and accompanying openrc initscript for lenovo-throttling-fix
# Copyright 2018 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit systemd
DESCRIPTION="Workaround for Linux throttling issues on Lenovo notebooks"
HOMEPAGE="https://github.com/erpalma/lenovo-throttling-fix"
SRC_URI="https://github.com/erpalma/lenovo-throttling-fix/archive/v${PV}.tar.gz"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""
DEPEND="dev-python/configparser
dev-python/dbus-python
dev-python/pygobject:3"
RDEPEND="${DEPEND}"
BDEPEND=""
pkg_setup() {
CHECK_CONFIG="X86_MSR DEVMEM"
}
src_install() {
insinto /etc/lenovo-throttling-fix
newins etc/lenovo_fix.conf lenovo_throttling_fix.conf
newsbin lenovo_fix.py lenovo_throttling_fix.py
dosbin mmio.py #ugly!
systemd_dounit "${S}/systemd/lenovo_fix.service"
doinitd "${FILESDIR}/lenovo_throttling_fix"
}
# Copyright 2018 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
inherit systemd git-r3
DESCRIPTION="Workaround for Linux throttling issues on Lenovo notebooks"
HOMEPAGE="https://github.com/erpalma/lenovo-throttling-fix"
EGIT_REPO_URI="https://github.com/erpalma/${PN}.git"
LICENSE="MIT"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""
DEPEND="dev-python/configparser
dev-python/dbus-python
dev-python/pygobject:3"
RDEPEND="${DEPEND}"
BDEPEND=""
pkg_setup() {
CHECK_CONFIG="X86_MSR DEVMEM"
}
src_install() {
insinto /etc/lenovo-throttling-fix
newins etc/lenovo_fix.conf lenovo_throttling_fix.conf
newsbin lenovo_fix.py lenovo_throttling_fix.py
dosbin mmio.py #ugly!
systemd_dounit "${S}/systemd/lenovo_fix.service"
doinitd "${FILESDIR}/lenovo_throttling_fix"
}
#!/sbin/openrc-run
# Copyright 2018 tbart
# Distributed under the terms of the GNU General Purpose License v2
#depend() {
#}
start() {
ebegin "Fixing CPU throttling with lenovo-throttling-fix.."
/usr/sbin/lenovo-throttling-fix --config /etc/lenovo-throttling-fix/lenovo-throttling-fix.conf
eend $?
}
#stop() {
# XXX How can we undo?
#eend $?
#}
# vim: set ft=gentoo-init-d ts=3 sw=3 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment