September 30th 2015

linux, archlinux

Minilaptop


How to make best use of a 2010 Acer Aspire One

acer


introduction: why i like this machine

acer aspire one zg5

i wanted something to carry around with me, but i wanted a real keyboard as well. one can actually buy tablets that are pretty much the same size as this machine (although lighter and thinner), and attach some sort of keyboard. but they usually run on android/google and it's not easily possible to install "real" linux onto them. plus, they are much more expensive.

it has a 160gb hard drive, which i find pretty good for such an old & small machine, and about 1gb of ram.

but the inbuilt 3g modem is most important to me. i just changed my home isp contract, and got an extra sim card with it, but only for data, not for calls. i also dislike touchscreens and wanted something as small as possible, but with a real keyboard. and, very important, something onto which i can install real gnu/linux - not android. happens that it also was damn cheap. so, one happy nerd.

first i bought some anti-glare screen protection. not the right size, so i had to cut it a little. it was easy to remove the bezel around the screen, apply the foil, and put the bezel back on. but still, i made a mistake and it didn't turn out so well (only the foil is wasted, not the screen itself. phew!). but before i buy a new foil, i want to do some field testing to see how well the anti-glare actually works.

what kind of system would i use on this machine?

installing arch linux

i will not go through the whole archlinux installation rigmarole, that's what wiki.archlinux.org is there for. just the notable things after the base system was installed.

i like yaourt. usually i take the time to install it manually (and i recommend that if it's the first time for you). well, this time i was lazy. i added the inofficial archlinux.fr repository to /etc/pacman.conf.

using archlinux with i3

one more time i decided for the lightweight & barebone alternative: Xorg + windowmanager + no display manager. the small screen and smaller touchpad made a keyboard driven tiling wm seem the best choice. the i3 windowmanager is dynamic, but its main goal is tiling.

not installing a proper desktop environment, i have to set up my system manually. it is not enough to install the window manager and a few graphical applications, especially on a laptop. so confusing, after the base install, coming to general recommendations... where to start?

power management

some strange problems with suspend & wakeup. i'd like to stick with systemd's built-in functionality for as long as possible, see /etc/systemd/logind.conf

but the problem persists: sometimes closing the lid makes the computer go into suspend, sometimes not. when i open the lid again, something is very wrong: either the screen remains black (no backlight, either) or the system freezes.

adding acpi_sleep=s3_bios,s3_mode to the linux bootup command line (source) helps.

spent most of the night applying power management from wiki.archlinux.org. i got suspend & lock screen on lid close now to achieve that, create /etc/systemd/system/suspend@.service:

[Unit]
Description=Lock Xsession before sleep
#Before=sleep.target

[Service]
User=%I
Type=forking
Environment=DISPLAY=:0
ExecStart=/usr/bin/i3lock --dpms -e -c 111111

[Install]
WantedBy=suspend.target

(see here) and activate it with sudo systemctl enable suspend@<username>. that way it will only activate when the laptop goes to sleep, but not when it goes to hibernate.

i still have to find a solution for applying different settings when on battery power (and suspending/hibernating/shutting down when on low power.

i decided to go with TLP. the archwiki article is short, but links to the official documentation. i went through the config file, changed 1 or 2 settings, but mostly it's good just as it is.

this still leaves me with one important thing: go for hibernation when battery is low.

first, need a swap partition. then i have to enable hibernation by configuring both kernel parameters and the initramfs.

but the system still has to find out when the battery is low. at first i thought that one udev rule would suffice, but it turns out that my battery does not communicate with the kernel, to send events to udev. you can find out for yourselves with udevadm monitor --subsystem-match=power_supply.

instead of installing another daemon or bunch of utilities, i thought i'd come up with something myself. here it is - just a small shellscript:

#!/bin/bash

DEV="BAT1"
minimum_capacity=2
timeout=10

status=$(cat "/sys/class/power_supply/$DEV/status")
>&2 echo "$(date) - $status"

if [ "$status" == "Unknown" ]
then
    >&2 echo "Status $status - try one more time in ${timeout}s"
    sleep $timeout
fi

status=$(cat "/sys/class/power_supply/$DEV/status")

if [ "$status" == "Discharging" ]
then
    >&2 echo "Status $status properly recognized"
    capacity=$( cat "/sys/class/power_supply/$DEV/capacity")
    >&2 echo "Capacity $capacity%, must be equal or more than $minimum_capacity%"
    if (( capacity < minimum_capacity ))
    then
        >&2 echo "Time to hibernate!"
        /usr/bin/systemctl hibernate
    else
        >&2 echo "Nothing to do."
    fi
fi

exit 0

then go to /etc/systemd/system/ and create 2 files: lowbat-hibernate.timer:

[Unit]
Description=Runs lowbat-hibernate every minute, starting 3min after boot

[Timer]
OnBootSec=3min
OnUnitActiveSec=1min

[Install]
WantedBy=timers.target

and lowbat-hibernate.service:

[Unit]
Description=Hibernate when battery level is lower than given minimum and not connected to power source

[Service]
ExecStart=/absolute/path/to/lowbat-hibernate.sh

and activate the timer with systemctl start lowbat-hibernate.timer.

battery life

these netbooks were said to come with great battery life, but i don't know how old the battery is. however, i notice distinct improvement after applying all power management tweaks. the battery itself (via i3status) tells me now that it has around 6h to go when fully charged, but it seems exaggerated. i once tried to watch two full-length movies, but half-way through the second one i had to plug in the charger. that would make around 3h under fairly high load.

more todo's

  • better settings for the tiny touchpad ( => it seems to have worked itself out. 2-finger-scrolling works.)
  • set up nano properly ( => done via archwiki. nano is pretty cool & up-to-date.)
  • i have already decided on dwb as web browser - firefox & co. are really too resource-intensive. dwb is light, yet up-to-date (*)
  • decide on a file manager and mail client ( => filemanager: pcmanfm, mail client: claws-mail)
  • more power management, esp. for hard drive and pci ( => finally taken care of. phew.)
  • block some domains via /etc/hosts, aka poor man's adblock (i've been using hostsblock so far)

(*) dwb was unmaintained for a while in 2014, but as of may 2015 it is maintained is unmaintained, but still usable. just like i3, it takes some getting used to, and one cannot expect the same sort of feature-richness as with e.g. firefox. note: i don't use the flashplugin. if you want sites like youtube to use html5, you have to install webkitgtk2's optional dependencies gst-plugins-good and gst-libav.

at the same time i'm getting to know i3 better. it works well enough out of the box, but i notice that urxvt (the rxvt-unicode terminal emulator) does not take kindly to the resizing policies of this tiling (actually dynamic) wm. furthermore i do not like the exit function, using i3-nagbar. here's a little dmenu replacement:

#!/bin/sh

cmd=$(echo -e "exit i3\nsuspend\nshutdown\nreboot" | dmenu -fn -*-terminus-medium-*-*-*-14-*-*-*-*-*-*-* )

case $cmd in
  "exit i3" )
    i3-msg exit
    ;;
  "suspend" )
    systemctl suspend
    ;;
  "shutdown" )
    systemctl poweroff
    ;;
  "reboot" )
    systemctl reboot
    ;;
  "*" )
    exit 1
    ;;
esac

file manager

i did decide on pcmanfm in the end - i thought of going for a 2-pane manager like emelfm2 or even mc, but i wanted trash and mounting of removable devices. just remember to install gvfs with pcmanfm, and then gvfs' optional dependencies to your liking.

all we need is a polkit authentication manager; i chose lxsession, which provides lxpolkit. just remember to autostart lxpolkit at login, and you're good to go i'd say. haven't been able to test all usage scenarios for gvfs (cameras, iphones...), but that should be enough (edit: confirmed to work for my canon camera). lxpolkit also takes care of e.g. gparted starting with root privileges.

btw, the lxsession package also includes an xdg autostart utility. but i have no need for it at the moment.

mobile broadband

according to sudo lsusb -v the device is option globetrotter gtm380 and uses the hso kernel module and some protocol that is not compatible with the usual pppd setup.

this is the best way to get it working:

i tried networkmanager once more, this time with success. just following archwiki to install and set up networkmanager and modemmanager (the device is built-in and does not require usb_modeswitch). i also removed netctl for good measure; not sure if that was necessary.

i did not install nm-applet, because it pulls in too many dependencies & stresses the system. after enabling and starting the .services, to add a new connection, this line of code did the trick:
nmcli connection add type gsm ifname "*" apn <your-apn-here>

this connects in a few seconds, as compared to ~30 seconds with all the alternatives listed below. it also connects automatically on startup and reconnects after suspend, but not (yet) after hibernate. for that, i have to use the little switch on the side to switch 3G off/on, then issue systemctl restart ModemManager and systemctl restart NetworkManager... But, after a few times of doing that, simply restarting both services (and waiting patiently) seems to suffice. So I added another service to automate that.

First, create /etc/systemd/system/hibernate-after.service:

[Unit]
Description=Restart Networking after hibernate
After=hibernate.target

[Service]
Type=oneshot
ExecStart=/usr/bin/systemctl restart ModemManager ; /usr/bin/systemctl restart NetworkManager

[Install]
WantedBy=hibernate.target

which I then enabled with systemctl enable hibernate-after.

other alternatives:

networkmanager out of the game, there are only two ways to connect: either with sakis3g or with hsoconnect. both applications don't really tell you how they go on about it, and both resist attempts at automating reconnection after suspend. bummer.

until i find a solution, i go with sakis3g. it took me literally days to find the commandline options, but at least the connection dies gracefully on suspend, so it's easy to restart (unlike hsoconnect).

[ i finally found what i need. the source package of the hso kernel module contains a script hso_connect.sh that knows all the necessary secrets. it's rather simple and only uses standard networking utilities: ifconfig, route and chat (part of ppp). ]

unfortunately, either method takes ~30s to connect. i wonder if i can do something about it.

terminal emulator

rxvt-unicode (aka urxvt) has been my choice for a while, but it seems it doesn't work well with the constant and radical window resizing that happens with a tiling wm. not quite sure yet what to do about it.

other apps

edit sep 2015
at first i was worried about browsers; i thought that firefox would be way too heavy for this machine, and used dwm and qupzilla. both browsers are currently buggy under archlinux. in the end i installed iceweasel, and i'm surprised how well it plays. in fact, i don't feel any difference in performance, compared to lightweight browsers. the same goes for my mail client. i always had problems setting up claws-mail and sylpheed correctly. in the end, i just tried thunderbird, and again, i don't feel much difference performance-wise.

  • geany with geany-themes. what else.
  • feh as a lightweight image viewer and background setter.
  • gimp, surprisingly without major performance problems
  • dmenu for dialogs and application menus.
  • mpv as an all-purpose mediaplayer
  • keepassx (qt4 still doesn't apply my gtk2 theme automatically, i had to open qtconfig-qt4 and set gui style to GTK+. remember to save with ctrl+s.
  • office - i'm not sure yet. libreoffice will certainly be too heavy. abiword pulls in gtk3, so no, but there's abiword-3.x-gtk2 in AUR. it compiles ok, and is indeed very light. the user interface is not crowded...

general lightweightness recommendations

i think most aspects have been dealt with in this article. no desktop environment. selfmade scripts or non-gui versions of utilities.
additionally, i try to avoid gtk3 applications. they are usually heavier than gtk2 alternatives, plus it simply means an extra toolkit hanging out on your hard drive (gtk2 without gtk3 is possible, but gtk3 without gtk2 is highly unlikely).
qt4 usually can't be avoided, but it feels more lightweight than gtk3 imho.
being an arch user is of advantage - we have the arch user repository, a.k.a. AUR, which often offers lighter alternatives. but handle with care, as these packages are not supervised. it generally helps to look at the votes a package received and use common sense (e.g. don't blindly install binary blobs).

aftermath

on day three or so i noticed that the fan is running constantly, whether on AC or battery. the acerhdf module is loaded. i added the settings from here to /etc/modules-load.d/acrehdf.conf, always assuming that i use the newest version (that wiki article is more than 5 years old). matters have improved: the fan switches off after bootup has finished. it switches on when the defined fanon temperature is reached - but after that it does not switch off anymore. ever. i am still investigating; i found out that i can manually switch the fan off, the same way it should happen automatically. so meanwhile i've added a snippet to the above mentioned lowbat-hibernate script:

>&2 echo "2. FanOff"

temp=$(cat "/sys/class/thermal/thermal_zone0/temp")
fanoff_temp=63000
>&2 echo "Current temp is $temp, FanOff_Temp is $fanoff_temp"

if (( temp < fanoff_temp ))
    then
    >&2 echo "Switching Fan Off."
    echo 0 > /sys/class/thermal/thermal_zone0/cdev0/cur_state
fi

it works.
it really seems that the acerhdf module knows when to switch the fan on, but not when to switch it off.

obligatory screenshot

screenshot

requiem

archlinux dropped support for 32-bit, and at the same time the operating system started acting up; performance had never been too good, but some recent changes made it worse. I could have made an effort and install a distro that is more friendly with ancient devices (AntiX?), but I already had bought myself an ARM laptop, and so i decided to sell this one - and still got some money for it!

that was late 2017.

i'm a little sad, i did like it. small, clunky, loveable.