Hibernate after suspend (on Fedora)

I recently found out that Windows has this nice feature where, after suspending your laptop, it’ll go to hibernate after a while to preserve battery. Seems like a really cool feature, saves your battery too, so I wanted it on my linux installation. I’m using Fedora 27 right now.

To get it working, you’ll first need to verify that your suspend to ram and suspend to disk actually work. There are plenty of articles on the web that can guide you through it.

The solution is relatively easy, thanks to the internet ;) I got most of the info here, on the ArchLinux forums / wiki. create the following systemd unit file (in /etc/systemd/system), called suspend-to-hibernate.service. After some testing I ended up with this file:

[Unit]
Description=Delayed hibernation trigger
Documentation=https://bbs.archlinux.org/viewtopic.php?pid=1420279#p1420279
Documentation=https://wiki.archlinux.org/index.php/Power_management
Conflicts=hibernate.target hybrid-sleep.target
Before=sleep.target
StopWhenUnneeded=true

[Service]
Type=oneshot
RemainAfterExit=yes
Environment="WAKEALARM=/sys/class/rtc/rtc0/wakealarm"
Environment="SLEEPLENGTH=+30min"
ExecStart=-/usr/bin/sh -c 'echo -n "alarm set for "; date +%%s -d$SLEEPLENGTH | tee $WAKEALARM'
ExecStop=-/usr/bin/sh -c '\
 alarm=$(cat $WAKEALARM); \
 now=$(date +%%s); \
 if [ -z "$alarm" ] || [ "$now" -ge "$alarm" ]; then \
 echo "hibernate triggered"; \
 systemctl hibernate; \
 else \
 echo "normal wakeup"; \
 fi; \
 echo 0 > $WAKEALARM; \
'

[Install]
WantedBy=sleep.target

Afterwards, enable it through systemctl enable suspend-to-hibernate.service; start it through systemctl start suspend-to-hibernate.service and you should be good to go.

DIY ambilight with Hyperion and a Raspberry Pi

I’ve always liked the Ambilight technology Philips builds into some of their TV’s. I just don’t like the price that they ask for it… so I looked around if there was no way to build that yourself. There is, using a Raspberry Pi, some leds, and some bits and pieces ;)

I found this tutorial which explains quite a bit of the build process, and which pieces to get. Since I suck at soldering (and/or my soldering iron is just plain crap), I went for another solution, and bought corner pieces to attach the different led strip parts together.

After attaching it to the back of the TV (with tape, to test), this is what you get:

To make it work for any HDMI input, I can refer you to this tutorial. It consists of using an HDMI splitter, convertor to AV, and an AV to USB convertor. This signal is piped into the Pi, where Hyperion can do it’s magic with it.

Quite happy with the end result ;)

Why you should use Syncthing

I’ve been a user of Dropbox for ages, I’ve tried Owncloud, I’ve tried Box, and probably numerous others that I’ve forgotten about, but in the past year I’ve migrated over to Syncthing, and I haven’t looked back. Opensource software, well designed protocol, complete ownership of your data, I could go on… but this post by gbolo explains it perfectly!

Syncthing – Why you should be using it

Upgrading the TP-Link Archer C5 (v1.2) to an Archer C7 (v2.0)

I own a TP-Link Archer C5 router, version 1.2 – which is identical to the TP-Link Archer C7, version 2.0, save for some limitations which are introduced through software. These limitations include a 300Mbps cap on 2.4GHz (450Mbps for the C7) and a 876Mbps cap on 5GHz (1300Mbps on the C7). Not that much, but still enough to be worth tinkering for.
Since I was looking at increasing the WiFi speeds in my home, I searched around a bit, and found out on Stefan Thesen’s blog and Hagensieker’s blog that it is perfectly possible :)

First, make sure you definitely have an Archer C5 version 1.2, with three antennas. Don’t even try with another version. If it breaks, noone is to blame but you.

You’ll need to flash DD-WRT, OpenWRT or LEDE-Project (check the respective projects for instructions on how to do that) first.

Next, download an Archer C7 firmware from the TP-Link website. I downloaded version 3.14.1 (141110) – which contains the firmware in the file ArcherC7v2_v3_en_3_14_1_up_boot(141110).bin

Now, remove the first 256 bytes, which is the bootloader (which we don’t need to flash it):  dd if=ArcherC7v2_v3_en_3_14_1_up_boot(141110).bin of=tplink_mod.bin skip=257 bs=512 (In case you don’t trust doing it yourself, you can also download the firmware from the blog of Stefan)

Next, you can transmit this (using SFTP) to your router, and then force flash it: sysupgrade -F /tmp/tplink_mod.bin. This will flash the firmware, and reboot the router. You’ll have to reconnect to it (default IP address is 192.168.0.1) and the web interface should report an Archer C7 :)

Afterwards you can either upgrade to the latest C7 firmware, or whichever 3rd party firmware you want. I reflashed to LEDE-Project.

Initial testing showed an improvement in WiFi throughput speeds – so I’m happy with my ‘new’ C7 :)

Installing microG services (as Play Services replacement) on the Asus TF101 tablet

I still have an Asus Transformer TF101 tablet in use – running MarshMallow – but after a Play Services upgrade, in which Google inserted some NEON instructions (which the TF101 does not support) , a lot of “Play Services has stopped working” popups showed up  – making the tablet nigh unusable. Initial tests blocking upgrade of the services yielded no success, and a lot of programs demand the newer versions of the services anyway.

In my searches I ran across the microG Project – “A free-as-in-freedom re-implementation of Google’s proprietary Android user space apps and libraries.” Sounded interesting, so I went and tried it, with success, on the tablet. It runs faster, battery life is better, and it works for everything I use it for.

Below you can find the steps I used. These apply to the Transformer TF101, and come with no guarantees whatsoever.

Preparing the tablet

  • First, you’ll need to uninstall both “Google Play Servics” and the “Google Play Store”. Use something like Lucky Patcher, or Titanium Backup, or whatnot, to remove them.
  • Reflash the ROM for KatKiss (I’m using 6.0.1 #29) and SuperSU (linked on the same page). Do NOT install opengapps!
  • Install F-Droid.
    Make sure you enable “Expert Mode” and “Unstable updates” in the settings, as we need the latest version of the packages.
  • Add the repository for microG: https://microg.org/fdroid/repo (as described here)
  • Temporarily disable the F-Droid repository.
  • Install the following items using F-Droid:
    • microG Services Core
    • microG Service Framework Proxy
  • Re-enable the F-Droid repository, and install

Patching the ROM to allow signature spoofing
Download (with git) a copy of https://github.com/Lanchon/haystack.git: git clone https://github.com/Lanchon/haystack.git

Make sure your tablet is connected through usb, and that adb works, and execute these commands in the directory where you cloned the git repository:
(you can find more information on the page of the git repository)

  • ./pull-fileset tf101
  • ./patch-fileset patches/sigspoof-hook-4.1-6.0/ 23 tf101/
  • ./patch-fileset patches/sigspoof-core/ 23 tf101__sigspoof-hook-4.1-6.0/
  • ./patch-fileset patches/sigspoof-ui-global-4.1-6.0/ 23 tf101__sigspoof-hook-4.1-6.0__sigspoof-core/
  • ./push-fileset tf101__sigspoof-hook-4.1-6.0__sigspoof-core__sigspoof-ui-global-4.1-6.0/

Reboot the tablet. Afterwards, go to “Settings”, “Developer options”, scroll to the bottom and enable “Allow signature spoofing”.

Configuring microG Services
Go into the application drawer, and look for an application calld “microG Settings”.

  • Tap “Permission Missing” and give all permissions
  • Enable “Google device registration”
  • Enable “Google Cloud Messaging”
  • Go in “UnifiedNlp Settings”, tap both “location backend” and “address lookup backends” and enable the backends there.
  • Go back to the main menu of microG Settings and tap “Self-Check” and make sure it doesn’t complain about anything
  • In “Self-Check”, make sure to tap “Battery optimizations ignored” to allow the service to run in the background

Reinstall Google Play Store
Download the Play Store from eg. APKMirror (http://www.apkmirror.com/apk/google-inc/google-play-store/[/url] to your PC. Rename it to com.android.vending.apk
Execute the following with adb:

  • adb remount
  • adb shell mkdir /system/priv-app/Phonesky
  • adb push com.android.vending.apk /system/priv-app/Phonesky/

Reboot the tablet one last time. Now you should have the Play Store available and you can install apps again to your heart’s content ;)