Argon One Up - unboxing and Alpine Linux setup

I thought it may be useful to put in a mini-tutorial how I get conky working. Conky is a great tool for monitoring stuff - I come from a generation where we had a wall full of neon indicators that showed the complete register set of the computer I was operating! I need to know what is going on :thinking: You can see my effect in post 17 above (and my entire desktop in post 2), and @spanspek desktop with conky in post 20 above.

Normally conky has built-in variables for retrieving battery status: however at launch there was no linux driver for the ONE UP battery and so those conky methods did not work. However the battery is connected to the i2c bus and so it is relatively simple to query that to obtain the status.

This first part of this tutorial is getting the battery status in Alpine via standard linux i2c tools. The process for other flavours of linux should be similar - in RaspberryPi OS steps 1, 2 & 3 may happen auto-magically when you add i2c support in raspi-setup? Part 2 will be a later post in this thread!

  1. Install the required package:

doas apk add i2c-tools

  1. Activate the i2c bus - in /boot/usercfg.txt we need (otherwise /boot/config.txt)

dtparam=i2c_arm=on

  1. And at startup - we need the module loaded

doas echo β€˜i2c-dev’ > /etc/modules-load.d/i2c.conf

If we reboot now then we should be able to verify we can see the battery at address 0x64 on the i2c bus

$ doas i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: – – – – – – – –
10: – – – – – – – – – – – – – – – –
20: – – – – – – – – – – – – – – – –
30: – – – – – – – – – – – – – – – –
40: – – – – – – – – – – – – – – – –
50: – – – – – – – – – – – – – – – –
60: – – – – 64 – – – – – – – – – – –
70: – – – – – – – –

  1. We can now build a small script that retrieves the battery % and whether it is (dis)charging - first allow the program to be run by mere mortals

doas chmod u+s /usr/sbin/i2cget

then create the script

$ cat bin/battery.sh
#!/bin/sh

cstat=$(printf β€œ%d” β€œ$(i2cget -y 1 0x64 0x0e)”)

printf "Battery: %d%% " $(i2cget -y 1 0x64 0x04)

if [ $cstat -lt 128 ]; then echo β€œβ†—β€; else echo β€œβ†˜β€; fi

Note by default Alpine does not have bash - and make it executable

chmod + x bin/battery.sh

  1. Now we can see simply our battery status

$ ./bin/battery.sh
Battery: 100% β†˜