Переглянути джерело

Use systemd for Surface Go touch power management

Signed-off-by: Dorian Stoll <dorian.stoll@tmsp.io>
Dorian Stoll 5 роки тому
батько
коміт
daf69af19c
2 змінених файлів з 14 додано та 14 видалено
  1. 11 0
      root/etc/systemd/system/surfacego-touchscreen.service
  2. 3 14
      setup.sh

+ 11 - 0
root/etc/systemd/system/surfacego-touchscreen.service

@@ -0,0 +1,11 @@
+[Unit]
+Description=Surface Go Touchscreen Power Management
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+ConditionPathExists=/sys/devices/pci0000:00/0000:00:15.1/i2c_designware.1/power/control
+Exec=/bin/sh -c "echo on > /sys/devices/pci0000:00/0000:00:15.1/i2c_designware.1/power/control"
+
+[Install]
+WantedBy=multi-user.target

+ 3 - 14
setup.sh

@@ -37,8 +37,6 @@ ask() {
     done
 }
 
-SUR_MODEL="$(dmidecode | grep "Product Name" -m 1 | xargs | sed -e 's/Product Name: //g')"
-
 echo "==> Copying the config files under root to where they belong..."
 for dir in $(ls root/); do
     cp -Rbv "root/$dir/"* "/$dir/"
@@ -50,6 +48,9 @@ cp -rv firmware/* /lib/firmware/
 echo "==> Making /lib/systemd/system-sleep/sleep executable..."
 chmod -v a+x /lib/systemd/system-sleep/sleep
 
+echo "==> Enabling power management for Surface Go touchscreen..."
+systemctl enable -q surfacego-touchscreen
+
 echo
 
 echo "Suspend is recommended over hibernate. If you chose to use"
@@ -72,18 +73,6 @@ fi
 
 echo
 
-if [ "$SUR_MODEL" = "Surface Go" ]; then
-    if [ ! -f "/etc/init.d/surfacego-touchscreen" ]; then
-        echo "==> Patching power control for Surface Go touchscreen..."
-        echo "echo \"on\" > /sys/devices/pci0000:00/0000:00:15.1/i2c_designware.1/power/control" \
-            > /etc/init.d/surfacego-touchscreen
-        chmod -v 755 /etc/init.d/surfacego-touchscreen
-        update-rc.d surfacego-touchscreen defaults
-    fi
-fi
-
-echo
-
 echo "Setting your clock to local time can fix issues with Windows dualboot."
 if ask "Do you want to set your clock to local time instead of UTC?" N; then
     echo "==> Setting clock to local time..."