reform

MNT Reform: Open Source Portable Computer
Log (Feed) | Files | Refs (Tags) | README

commit 8dd5992ae4cbc84f428585c9899a5b6e145c60f1
parent caad72debd78870f0a57de8d5e31ba05f73e4aaa
Author: mntmn <lukas@mnt.mn>
Date:   Tue, 13 Nov 2018 19:44:29 +0100

reformd installer + i3bar integration

Diffstat:
Areformd/i3status.conf | 29+++++++++++++++++++++++++++++
Areformd/install-systemd.sh | 32++++++++++++++++++++++++++++++++
Areformd/reformd.service | 12++++++++++++
Mreformd/reformd.sh | 13++++++-------
Areformd/screenshot.png | 0
Areformd/status-bar.sh | 18++++++++++++++++++
6 files changed, 97 insertions(+), 7 deletions(-)

diff --git a/reformd/i3status.conf b/reformd/i3status.conf @@ -0,0 +1,29 @@ +# + +general { + interval = 1 + colors = true + color_good = '#88b090' + color_degraded = '#ccdc90' + color_bad = '#e89393' +} + + +order += "cpu_usage" +order += "wireless wlp1s0" +order += "external_script" + +cpu_usage { + format = "CPU %usage" +} + +wireless wlp1s0 { + format_up = "WIFI %quality %essid %ip" + format_down = "" +} + +external_script { + format = " {output}" + script_path = "/bin/sh /etc/reform/status-bar.sh" +} + diff --git a/reformd/install-systemd.sh b/reformd/install-systemd.sh @@ -0,0 +1,32 @@ +#!/bin/bash + +set -x + +mkdir -p /etc/reform +cp reformd.sh /etc/reform/ +cp status-bar.sh /etc/reform/ +cp reformd.service /etc/systemd/system/ +systemctl daemon-reload +systemctl enable reformd.service +systemctl start reformd.service + +cat << EOF + +To integrate reformd into i3bar, do the following steps: + +- Install py3status (sudo apt install py3status) +- Adapt your i3 config to use py3status and /etc/reform/status-bar.sh: + +bar { + status_command py3status -c ~/.config/i3status.conf +} + +- Copy the i3status.conf from this directory to ~/.config/i3status.conf +- Take a look at that file and adapt to your needs +- Reload i3 (normally Mod+Shift+R) + +To follow reformd status output, use: +- journalctl -fu reformd.service + +EOF + diff --git a/reformd/reformd.service b/reformd/reformd.service @@ -0,0 +1,12 @@ +[Unit] +Description=Reform Battery, Fan, Lid Controller + +[Service] +Type=simple +ExecStart=/etc/reform/reformd.sh +Restart=always +User=root + +[Install] +WantedBy=multi-user.target + diff --git a/reformd/reformd.sh b/reformd/reformd.sh @@ -71,7 +71,7 @@ function system_suspend { set +e; timeout 1 head /dev/ttymxc1; set -e # zzZzzZ - systemctl suspend + # systemctl suspend } function regulate_fan { @@ -119,14 +119,13 @@ function main { # important: this works only if the kernel option no_console_suspend=1 is set! # also, requires kernel patch when using PCIe cards: https://github.com/sakaki-/novena-kernel-patches/blob/master/0017-pci-fix-suspend-on-i.MX6.patch # (workaround for erratum "PCIe does not support L2 Power Down") - if [ "$lid_state" ] && [ "$lid_state" -eq "1" ] - then - system_suspend - exit - fi + #if [ "$lid_state" ] && [ "$lid_state" -eq "1" ] + #then + # system_suspend + # exit + #fi } -brightnessctl s 5 disable_echo while true; do diff --git a/reformd/screenshot.png b/reformd/screenshot.png Binary files differ. diff --git a/reformd/status-bar.sh b/reformd/status-bar.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +read -r temp < /sys/class/thermal/thermal_zone0/temp +temp=$((temp / 1000)) +#headphone=$(amixer get 'Headphone' | grep "Left: Playback" | cut -f 7 -d ' ') + +IFS=$',\r' +read -r x y bat_capacity bat_volts bat_amps a b </var/log/reformd + +bat_capacity=$(echo $bat_capacity | tr -d Ah) +bat_amps=$(echo "-($bat_amps)" | tr -d A | bc) + +bat_percent=$(echo "scale=2;$bat_capacity/10.0*100" | bc) + +#bat_hours=$(echo "scale=1;($bat_capacity-1.0)/$bat_amps" | bc) + +echo -n "BAT $bat_percent% (${bat_amps}A ${bat_volts}V) $tempĀ°C" +