switched to python3 and virtualenv
This commit is contained in:
12
Makefile
12
Makefile
@@ -1,12 +0,0 @@
|
|||||||
all: install
|
|
||||||
|
|
||||||
install:
|
|
||||||
install -d /usr/local/sbin/
|
|
||||||
install -d /etc/systemd/system/
|
|
||||||
install -m 700 lenovo_fix.py /usr/local/sbin/
|
|
||||||
install -m 644 systemd/lenovo_fix.service /etc/systemd/system/
|
|
||||||
@if test -f /etc/lenovo_fix.conf; then \
|
|
||||||
echo "/etc/lenovo_fix.conf already exists; overwrite manually"; \
|
|
||||||
else \
|
|
||||||
install -m 644 etc/lenovo_fix.conf /etc/; \
|
|
||||||
fi
|
|
||||||
34
install.sh
Executable file
34
install.sh
Executable file
@@ -0,0 +1,34 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
INSTALL_DIR="/opt/lenovo_fix"
|
||||||
|
|
||||||
|
systemctl stop lenovo_fix.service &>/dev/null
|
||||||
|
|
||||||
|
mkdir -p "$INSTALL_DIR" &>/dev/null
|
||||||
|
set -e
|
||||||
|
|
||||||
|
cd "$(dirname "$0")"
|
||||||
|
|
||||||
|
echo "Copying config file..."
|
||||||
|
if [ ! -f /etc/lenovo_fix.conf ]; then
|
||||||
|
cp etc/lenovo_fix.conf /etc
|
||||||
|
else
|
||||||
|
echo "Config file already exists, skipping."
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Copying systemd service file..."
|
||||||
|
cp systemd/lenovo_fix.service /etc/systemd/system
|
||||||
|
|
||||||
|
echo "Building virtualenv..."
|
||||||
|
cp requirements.txt lenovo_fix.py "$INSTALL_DIR"
|
||||||
|
cd "$INSTALL_DIR"
|
||||||
|
virtualenv -p /usr/bin/python3 venv
|
||||||
|
source venv/bin/activate
|
||||||
|
pip install -r requirements.txt
|
||||||
|
|
||||||
|
echo "Enabling and starting systemd service..."
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl enable lenovo_fix.service
|
||||||
|
systemctl restart lenovo_fix.service
|
||||||
|
|
||||||
|
echo "All done."
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
import ConfigParser
|
import configparser
|
||||||
import dbus
|
import dbus
|
||||||
import glob
|
import glob
|
||||||
import os
|
import os
|
||||||
@@ -49,8 +49,8 @@ def is_on_battery():
|
|||||||
|
|
||||||
|
|
||||||
def calc_time_window_vars(t):
|
def calc_time_window_vars(t):
|
||||||
for Y in xrange(2**5):
|
for Y in range(2**5):
|
||||||
for Z in xrange(2**2):
|
for Z in range(2**2):
|
||||||
if t <= (2**Y) * (1. + Z / 4.) * 0.000977:
|
if t <= (2**Y) * (1. + Z / 4.) * 0.000977:
|
||||||
return (Y, Z)
|
return (Y, Z)
|
||||||
raise Exception('Unable to find a good combination!')
|
raise Exception('Unable to find a good combination!')
|
||||||
@@ -70,7 +70,7 @@ def calc_undervolt_msr(plane, offset):
|
|||||||
|
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
config = ConfigParser.ConfigParser()
|
config = configparser.ConfigParser()
|
||||||
config.read(CONFIG_PATH)
|
config.read(CONFIG_PATH)
|
||||||
|
|
||||||
for power_source in ('AC', 'BATTERY'):
|
for power_source in ('AC', 'BATTERY'):
|
||||||
|
|||||||
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
configparser==3.5.0
|
||||||
|
dbus-python==1.2.4
|
||||||
|
PyGObject==3.28.2
|
||||||
|
python-periphery==1.1.1
|
||||||
@@ -3,7 +3,7 @@ Description=Fix Lenovo T480/T480s/X1C6 throttling on Linux
|
|||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
ExecStart=/usr/local/sbin/lenovo_fix.py
|
ExecStart=/opt/lenovo_fix/venv/bin/python3 /opt/lenovo_fix/lenovo_fix.py
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
Reference in New Issue
Block a user