From 704aaf3fc65eb8d5795224eca2a33459337914cb Mon Sep 17 00:00:00 2001
From: "Lukas F. Hartmann" <lukas@mntre.com>
Date: Tue, 2 Mar 2021 20:41:26 +0100
Subject: [PATCH] move reform-specific scripts and tools to reform-tools debian
 package

---
 reform2-imx8mq/mkreform-tools.sh              |  4 ++++
 .../reform-tools_1.0-3/DEBIAN/control         |  9 +++++++++
 .../etc}/reform-desktop-help                  |  0
 .../etc}/reform-help                          |  0
 .../etc}/reform-root-help                     |  0
 .../sbin}/reform-init                         |  0
 .../usr}/bin/reform-chat                      |  0
 .../usr/bin/reform-compstat.py}               |  0
 .../usr/bin/reform-compstat.sh}               |  2 +-
 .../usr/bin/reform-connman-gtk.sh}            |  0
 .../usr}/bin/reform-desktop-help              |  0
 .../usr}/bin/reform-help                      |  0
 .../usr/bin/reform-pavucontrol.sh}            |  0
 .../usr/sbin}/reform-boot-config              |  0
 .../usr/sbin}/reform-config                   |  0
 .../usr/sbin}/reform-display-config           |  0
 .../usr/sbin/reform-hw-setup.sh               | 10 ++++++++++
 .../usr/sbin}/reform-migrate                  |  0
 .../usr/sbin}/reform-standby                  |  0
 reform2-imx8mq/template-etc/motd              |  2 +-
 reform2-imx8mq/template-etc/motd-reform       |  6 +++---
 ...isplay.service => reform-hw-setup.service} |  4 ++--
 .../template-etc/reform-toggle-display.sh     | 20 -------------------
 .../template-skel/.config/waybar/config       |  6 +++---
 24 files changed, 33 insertions(+), 30 deletions(-)
 create mode 100755 reform2-imx8mq/mkreform-tools.sh
 create mode 100644 reform2-imx8mq/reform-tools_1.0-3/DEBIAN/control
 rename reform2-imx8mq/{template-etc => reform-tools_1.0-3/etc}/reform-desktop-help (100%)
 rename reform2-imx8mq/{template-etc => reform-tools_1.0-3/etc}/reform-help (100%)
 rename reform2-imx8mq/{template-etc => reform-tools_1.0-3/etc}/reform-root-help (100%)
 rename reform2-imx8mq/{template-etc => reform-tools_1.0-3/sbin}/reform-init (100%)
 rename reform2-imx8mq/{template-skel => reform-tools_1.0-3/usr}/bin/reform-chat (100%)
 rename reform2-imx8mq/{template-skel/bin/compstat => reform-tools_1.0-3/usr/bin/reform-compstat.py} (100%)
 rename reform2-imx8mq/{template-skel/bin/compstat.sh => reform-tools_1.0-3/usr/bin/reform-compstat.sh} (57%)
 rename reform2-imx8mq/{template-skel/bin/connman-gtk.sh => reform-tools_1.0-3/usr/bin/reform-connman-gtk.sh} (100%)
 rename reform2-imx8mq/{template-skel => reform-tools_1.0-3/usr}/bin/reform-desktop-help (100%)
 rename reform2-imx8mq/{template-skel => reform-tools_1.0-3/usr}/bin/reform-help (100%)
 rename reform2-imx8mq/{template-skel/bin/pavucontrol.sh => reform-tools_1.0-3/usr/bin/reform-pavucontrol.sh} (100%)
 rename reform2-imx8mq/{template-skel/bin => reform-tools_1.0-3/usr/sbin}/reform-boot-config (100%)
 rename reform2-imx8mq/{template-skel/bin => reform-tools_1.0-3/usr/sbin}/reform-config (100%)
 rename reform2-imx8mq/{template-skel/bin => reform-tools_1.0-3/usr/sbin}/reform-display-config (100%)
 create mode 100755 reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-hw-setup.sh
 rename reform2-imx8mq/{template-skel/bin => reform-tools_1.0-3/usr/sbin}/reform-migrate (100%)
 rename reform2-imx8mq/{template-skel/bin => reform-tools_1.0-3/usr/sbin}/reform-standby (100%)
 rename reform2-imx8mq/template-etc/{reform-display.service => reform-hw-setup.service} (51%)
 delete mode 100755 reform2-imx8mq/template-etc/reform-toggle-display.sh

diff --git a/reform2-imx8mq/mkreform-tools.sh b/reform2-imx8mq/mkreform-tools.sh
new file mode 100755
index 0000000..a4500b1
--- /dev/null
+++ b/reform2-imx8mq/mkreform-tools.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+
+dpkg-deb --build reform-tools_*
+
diff --git a/reform2-imx8mq/reform-tools_1.0-3/DEBIAN/control b/reform2-imx8mq/reform-tools_1.0-3/DEBIAN/control
new file mode 100644
index 0000000..532aebe
--- /dev/null
+++ b/reform2-imx8mq/reform-tools_1.0-3/DEBIAN/control
@@ -0,0 +1,9 @@
+Package: reform-tools
+Version: 1.0-3
+Section: base
+Priority: optional
+Architecture: arm64
+Depends: bash
+Maintainer: Lukas F. Hartmann <lukas@mntre.com>
+Description: MNT Reform System Tools
+ A number of scripts for managing boot media, displays, standby, plus a few help texts and gadgets for the customized sway desktop. Also contains /sbin/reform-init, a boot manager script that gets loaded by u-boot and which in turn launches the real /sbin/init after mounting an (encrypted) boot medium.
diff --git a/reform2-imx8mq/template-etc/reform-desktop-help b/reform2-imx8mq/reform-tools_1.0-3/etc/reform-desktop-help
similarity index 100%
rename from reform2-imx8mq/template-etc/reform-desktop-help
rename to reform2-imx8mq/reform-tools_1.0-3/etc/reform-desktop-help
diff --git a/reform2-imx8mq/template-etc/reform-help b/reform2-imx8mq/reform-tools_1.0-3/etc/reform-help
similarity index 100%
rename from reform2-imx8mq/template-etc/reform-help
rename to reform2-imx8mq/reform-tools_1.0-3/etc/reform-help
diff --git a/reform2-imx8mq/template-etc/reform-root-help b/reform2-imx8mq/reform-tools_1.0-3/etc/reform-root-help
similarity index 100%
rename from reform2-imx8mq/template-etc/reform-root-help
rename to reform2-imx8mq/reform-tools_1.0-3/etc/reform-root-help
diff --git a/reform2-imx8mq/template-etc/reform-init b/reform2-imx8mq/reform-tools_1.0-3/sbin/reform-init
similarity index 100%
rename from reform2-imx8mq/template-etc/reform-init
rename to reform2-imx8mq/reform-tools_1.0-3/sbin/reform-init
diff --git a/reform2-imx8mq/template-skel/bin/reform-chat b/reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-chat
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/reform-chat
rename to reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-chat
diff --git a/reform2-imx8mq/template-skel/bin/compstat b/reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-compstat.py
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/compstat
rename to reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-compstat.py
diff --git a/reform2-imx8mq/template-skel/bin/compstat.sh b/reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-compstat.sh
similarity index 57%
rename from reform2-imx8mq/template-skel/bin/compstat.sh
rename to reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-compstat.sh
index 79e47cc..eafcc73 100755
--- a/reform2-imx8mq/template-skel/bin/compstat.sh
+++ b/reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-compstat.sh
@@ -3,5 +3,5 @@
 # clean up any existing processes
 pkill -f 'python3.*compstat'
 
-/usr/bin/python3 ~/bin/compstat -d 1 -i 0.3
+/usr/bin/python3 /usr/bin/reform-compstat.py -d 1 -i 0.3
 
diff --git a/reform2-imx8mq/template-skel/bin/connman-gtk.sh b/reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-connman-gtk.sh
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/connman-gtk.sh
rename to reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-connman-gtk.sh
diff --git a/reform2-imx8mq/template-skel/bin/reform-desktop-help b/reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-desktop-help
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/reform-desktop-help
rename to reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-desktop-help
diff --git a/reform2-imx8mq/template-skel/bin/reform-help b/reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-help
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/reform-help
rename to reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-help
diff --git a/reform2-imx8mq/template-skel/bin/pavucontrol.sh b/reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-pavucontrol.sh
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/pavucontrol.sh
rename to reform2-imx8mq/reform-tools_1.0-3/usr/bin/reform-pavucontrol.sh
diff --git a/reform2-imx8mq/template-skel/bin/reform-boot-config b/reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-boot-config
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/reform-boot-config
rename to reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-boot-config
diff --git a/reform2-imx8mq/template-skel/bin/reform-config b/reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-config
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/reform-config
rename to reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-config
diff --git a/reform2-imx8mq/template-skel/bin/reform-display-config b/reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-display-config
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/reform-display-config
rename to reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-display-config
diff --git a/reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-hw-setup.sh b/reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-hw-setup.sh
new file mode 100755
index 0000000..b2dbc29
--- /dev/null
+++ b/reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-hw-setup.sh
@@ -0,0 +1,10 @@
+#!/bin/bash
+
+# This switch in WM8960 needs to be on for the headset mic input to work
+amixer -c 0 sset 'Left Input Mixer Boost' on
+
+# Enable wakeup from suspend on all UARTS
+echo enabled > /sys/devices/platform/soc@0/30800000.bus/30860000.serial/tty/ttymxc0/power/wakeup
+echo enabled > /sys/devices/platform/soc@0/30800000.bus/30890000.serial/tty/ttymxc1/power/wakeup
+echo enabled > /sys/devices/platform/soc@0/30800000.bus/30880000.serial/tty/ttymxc2/power/wakeup
+
diff --git a/reform2-imx8mq/template-skel/bin/reform-migrate b/reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-migrate
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/reform-migrate
rename to reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-migrate
diff --git a/reform2-imx8mq/template-skel/bin/reform-standby b/reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-standby
similarity index 100%
rename from reform2-imx8mq/template-skel/bin/reform-standby
rename to reform2-imx8mq/reform-tools_1.0-3/usr/sbin/reform-standby
diff --git a/reform2-imx8mq/template-etc/motd b/reform2-imx8mq/template-etc/motd
index 6aa8d30..329c807 100644
--- a/reform2-imx8mq/template-etc/motd
+++ b/reform2-imx8mq/template-etc/motd
@@ -1,7 +1,7 @@
 
                      [?25h[?1;5;2004lWelcome to Debian GNU/Linux
                      on MNT Reform
+                     System Image: 2021-03-02
                      
                      https://mntre.com/reform
                      https://www.debian.org
-
diff --git a/reform2-imx8mq/template-etc/motd-reform b/reform2-imx8mq/template-etc/motd-reform
index d59997d..329c807 100644
--- a/reform2-imx8mq/template-etc/motd-reform
+++ b/reform2-imx8mq/template-etc/motd-reform
@@ -1,7 +1,7 @@
 
                      [?25h[?1;5;2004lWelcome to Debian GNU/Linux
-                     on the MNT Reform 2.0
-                     System Build: 2020-06-05
+                     on MNT Reform
+                     System Image: 2021-03-02
                      
-                     https://mntmn.com/reform
+                     https://mntre.com/reform
                      https://www.debian.org
diff --git a/reform2-imx8mq/template-etc/reform-display.service b/reform2-imx8mq/template-etc/reform-hw-setup.service
similarity index 51%
rename from reform2-imx8mq/template-etc/reform-display.service
rename to reform2-imx8mq/template-etc/reform-hw-setup.service
index 2824a93..e355c4f 100644
--- a/reform2-imx8mq/template-etc/reform-display.service
+++ b/reform2-imx8mq/template-etc/reform-hw-setup.service
@@ -1,9 +1,9 @@
 [Unit]
-Description=Reform2 internal display
+Description=MNT Reform Hardware Defaults Setup
 
 [Service]
 Type=oneshot
-ExecStart=/etc/reform-toggle-display.sh edp
+ExecStart=/usr/sbin/reform-hw-setup.sh
 StandardOutput=journal
 
 [Install]
diff --git a/reform2-imx8mq/template-etc/reform-toggle-display.sh b/reform2-imx8mq/template-etc/reform-toggle-display.sh
deleted file mode 100755
index 21f864b..0000000
--- a/reform2-imx8mq/template-etc/reform-toggle-display.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/bin/bash
-
-cd /lib/modules/
-
-rmmod imx_dcss
-rmmod cdns_mhdp_imx
-rmmod nwl_dsi
-
-if [ $1 == "hdmi" ]
-then
-	insmod cdns_mhdp_imx.ko
-	insmod imx-dcss.ko dcss_use_hdmi=1
-fi
-
-if [ $1 == "edp" ]
-then
-	insmod nwl-dsi.ko
-	insmod imx-dcss.ko dcss_use_hdmi=0
-fi
-
diff --git a/reform2-imx8mq/template-skel/.config/waybar/config b/reform2-imx8mq/template-skel/.config/waybar/config
index c7a88c9..67f097f 100644
--- a/reform2-imx8mq/template-skel/.config/waybar/config
+++ b/reform2-imx8mq/template-skel/.config/waybar/config
@@ -44,7 +44,7 @@
         "format-linked": "NET {ifname} NO IP",
         "format-disconnected": "OFFLINE",
         //"format-alt": "NET {ifname}: {ipaddr}/{cidr}"
-        "on-click": "~/bin/connman-gtk.sh"
+        "on-click": "reform-connman-gtk.sh"
     },
     "pulseaudio": {
         // "scroll-step": 1,
@@ -54,13 +54,13 @@
         "format-muted": "MUTED {format_source}",
         "format-source": "{volume}%",
         "format-source-muted": "MUTE",
-        "on-click": "pavucontrol"
+        "on-click": "reform-pavucontrol.sh"
     },
     "custom/stat": {
         "format": "{}",
         "max-length": 20,
         "interval": 0,
-        "exec": "~/bin/compstat.sh",
+        "exec": "reform-compstat.sh",
         "on-click": "gnome-system-monitor"
     }
 }
-- 
GitLab