Delayed hibernation on Linux with SystemD

One thing that I liked on modern laptops with MS Windows or Apple macos was this power saving technique od delayed hibernation. On set timeout of inactivity or after closing laptop’s lid it goes into suspend and then after sometime into hibernation. That’s great because it stops battery drainage needed to support RAM during regular suspend. With it I can go for days of work without the need to recharge my laptop. From many methods to achieve this with SystemD this one worked always and keeps working for me to this day.

But first things first. You need to check if your machine is capable of hibernation. Generally you need to have a swap partition at least a little bigger then your RAM capacity. My machine is also encrypted with LUKS so my kernel line has the following line included:


While adding it to your bootloader config make sure that you account for your distro specific variables like different name of swap partition in LVM config (you can check it by listing /dev/mapper/). Additionally my mounting of swap partition in /etc/fstab goes like this:

UUID=r5f026te-e9d2-4973-81fd-998e04dae75f    none    swap    defaults    0 0

After your swap is properly setup you can go ahead and check if hibernation works by executing:

sudo systemctl hibernate

If your laptop went dark after a minute or so and resumed after you pushed the power button you’re good to go. Now it’s time for the actual delayed hibernation setup.

Backups, backups, backups. To stay on the safe side if you have file /etc/systemd/system/systemd-suspend.service present, make a copy:

sudo cp /etc/systemd/system/systemd-suspend.service /etc/systemd/system/systemd-suspend.service.orgi

Then we do the actual change to replace original suspend action with our desired one:

sudo ln -s /usr/lib/systemd/system/systemd-suspend-then-hibernate.service /etc/systemd/system/systemd-suspend.service

And that’s mostly it. Now we can adjust the timeout after which our machine will go from suspend to hibernation. This one takes some experimentation. For me optimal value is 15 minutes. If I didn’t open my laptop after that time I’m probably out commuting to another location or done fo the day. To make the adjustment we edit /etc/systemd/sleep.conf, uncomment the following line and set the time:


Now any suspend action called by you or any kind of automation will trigger delayed hibernation.

Please note that in different distros documentation you can find many other tutorials and ways to set this up. Most of them is outdated. The one presented above while being the oldest one, is working for me at any point of time and in any GNU/Linux distribution with SystemD.

When you’ll find that you lack some of the files or some other differences please follow this thread on mastodon and feel free to contact me.

For example on Ubuntu you might find service file that you need to symlink under:

Continue Reading

Upgrade your Samsung Galaxy S (GT-I9000) to KitKat

Warning: tasks described below will lead to complete removal of data from your smartphone and might lead to bricking it.

Root and CWM Recovery

It’s good to start by having rooted phone with Android Gingerbread 2.3.5 on board. During the process you might find yourself in hard position of trying to select proper builds for your system so I recommend wiping it completely and flashing software stored in the following package: It contains:

  • Windows drivers for Samsung smartphones;
  • right version of Odin flashing software which works with our smartphone;
  • complete image of gingerbread android, root and kernel with CWM recovery;
  • last release of cyanogenmod 11 for galaxysmtd;
  • selected gapps.

Another warning: You might want to follow these instructions on a Windows system which you’re ready to reinstall afterwards. It might get infected during the process and virtual machine will not suffice.

First step is installation of Samsung drivers and Windows reboot afterwards. Then we’ll start Odin. 1.83 is the last release which supports I9000 correctly, otherwise it might get stuck on „initializing connection”.

Let’s get to the phone. We need to start it in Download mode by pressing and holding VOL DOWN + POWER + HOME until it flashes with yellow icon and text. Then we connect the phone to computer, Odin should react with message containing Added.

Download mode

Now in Odin I9000XXJW4_I9000OXAJW4_XEU we open the following files:

  • PIT: s1_odin_20100512.pit
  • BOOTLOADER: APBOOT_I9000XXJW4_CL1043937.tar.md5
  • PDA: CODE_I9000XXJW4_CL1043937.tar.md5
  • PHONE: MODEM_I9000XXJW4_CL1118084.tar.md5

Next click on Start. Process will take a while and our I9000 might restart few times, but do not react. When Odin tells you it’s finished close it and disconnect the phone. We need to restart the phone into Downloadmode again by pressing and holding VOL DOWN + POWER + HOME until it flashes with yellow icon and text. Then we connect it to the computer and wait for Odin response.

This time from I9000XXJW4_I9000OXAJW4_XEU_DEODEX_ROOT directory we select these files:

  • PIT: s1_odin_20100512.pit
  • PDA: CODE_I9000XXJW4_ROOT_DEODEX.tar.md5

And click on Start. This process should take less time. When Odin tells us it finished our Samsung will be in the process of another restart. We need to close Odin again, and restart our phone int o Download mode.

Those restarts are necessary in order for the whole process to go smoothly, other wise you might get stuck with Odin not flashing files or not recognizing connected phone.

One last time from CF-Root-XX_OXA_JW4-v4.4-CWM3RFS directory we select CF-Root-XX_OXA_JW4-v4.4-CWM3RFS.tar as PDA and click on Start. Afterwards phone will reboot into system showing us first time wizard. We need to go through until we have our system ready to work.

Upgrade to Android KitKat 4.4

After reconnecting phone to the computer it should announce itself in the system and let us copy files onto it. We copy:


To the main memory of the I9000, not the SD card. Than disconnect the phone.

This time we need to boot the phone into Recovery mode by pressing and holding VOL UP + POWER + HOME until it displays another menu of Clockworkmod recovery. We go through it using VOL UP (up), VOL DOWN (down) and HOME (select). Before flashing new system on our Samsung we need t finish the following tasks:

  • wipe data/factory reset
  • wipe cache partition
  • wipe dalvik cache (from advanced submenu)

Now that our phone is wiped clean we can install CM11 by choosing install zip from sdcard option, selecting from its memory and confirming the task. After the start phone will reboot few times showing different screens, please do not react and wait for it to finish.

When it’s done it will show you different Recovery screen ready for another tasks. Now we flash gapps by selecting install zip from sdcard option, selecting and confirming the process. This time phone will not restart, just wait patiently for it to finish. Et voilà, please restart your phone by choosing reboot system now. After standard Samsung screen you’ll see Cyanogenmod’s boot screen. This start will take a long time so please wait for it to finish. When you see first time wizard you have succeed and are ready to go!

Recovering I9000 from brick

There are many ROMS and versions available, including Android 5, 6 and even 7. Not all of them are as easy to flash and as stable as CM11. Users often note high battery usage and overall slowdown of the system. There are also failing installs which left you with not working TWRP or bootloop. If you will find yourself in one of those brick situations or in need to reverse to the stable system please follow Root and CWM Recovery section of this guide. You’ll be up and running in no time.

Continue Reading

Sounds of nature: Birds being fed

We’ve found a nest in a tree in front of our countryside house. There were four baby birds regularly fed by their parents. You can hear them flying in and out.
Captured with ZOOM h2n.

This work is under Creative Commons Attribution-Noncommercial-Share Alike 3.0 license, so you can mix it and use for your own work! You can find the sound on soundcloud or

Photo: Courtesy of Marek Karpezo

Continue Reading

My book about WordPress out now!

Might not be worth too much outside of Poland but here it is. My first book containing summary of tips and tricks used at work with WordPress.

It contains information about:

  • how and which themes and plugins you should consider;
  • how to secure your website;
  • make and restore your perfect backup;
  • manage SEO;
  • run your own, professional newsletter;
  • optimize your website for mobile devices;
  • speed-up your WordPress

… and many more!

You can buy it online or as paperback thanks to „Komputer Świat” magazine.

Continue Reading

2020 that I’d be looking forward to

FSF Survey has this great question, so I thought that I’d share my answer.

Imagine it’s 2020 and people are more free and empowered as computer users, due to the efforts of the free software movement and the FSF. Describe some things that we have accomplished to reach this point.

My phone is able to run software completely of my choice without so much effort as it was needed back then in boring 2016. It’s the place I store my personal information, completely encrypted and I do most of my work on it. Just go somewhere connect with the screen, display keyboard on the table and work. Big, old machines and those abominations called laptops were moved back to the server rooms again! I’m able to get one for myself from local store, set it up in minutes, connect and talk safely with my family,friends and coworkers and those who were so retarded that they still need this thing called “the cloud”. Distributed everything. Everyone’s talking right now with everyone with no spying from those governments and companies giving you their servers to talk through.

Discussion: Feel free to join the discussion under this post on Diaspora*

Continue Reading

History migration from ZSH to BASH

I’ve decided to move back from zsh to bash shell. It appeared that history migration is much bigger problem in this direction, mostly due to prefix added by zsh:

: 2145123543:0;git push origin master

Numbers are random, I’ve just wanted to show the example. I don’t know if it was created by my specific zsh config based on [oh-my-zsh](] or if zsh does that by default. Fortunately there is this simple one-liner which will solve the problem and migrate your history in seconds:

cat ~/.zsh_history | sed 's/\:...........\:.\;//g' > ~/.bash_history

It removes the prefix and saves the file in bash default location. After reloading bash you’ll be able to search through your history. Another tip that I like to use in my computing is .inputrc modification which does the autocomplete based on the history on any stage of building the command, by using arrow keys “↑” and “↓”. You can find it in my configs repository and put it in your home directory.

Continue Reading

GPG key transition statement

Date: 8th October, 2015
(You can also download this statement signed by both the old and the new key.)

For a number of reasons, i’ve recently set up a new OpenPGP key, and will be transitioning away from my old one.

The old key will continue to be valid for some time, but i prefer all future correspondence to come to the new one. I would also like this new key to be re-integrated into the web of trust. This message is signed by both keys to certify the transition.

the old key was:

pub   2048R/DBAB60F2 2012-09-08
      Key fingerprint = 99A7 D000 D012 7BD7 F497  BC51 C277 D526 DBAB 60F2

And the new key is:

pub   4096R/3F332AEF 2015-10-08 [expires: 2017-10-07]
      Key fingerprint = 39FB 5452 5236 AB4E 886E  BA75 CE97 A663 3F33 2AEF

To fetch the full key (including a photo uid, which is commonly stripped by public keyservers), you can get it with:

wget -q -O- | gpg --import -

Or, to fetch my new key from a public key server, you can simply do:

gpg --keyserver --recv-key 3F332AEF

If you already know my old key, you can now verify that the new key is signed by the old one:

gpg --check-sigs 3F332AEF

If you don’t already know my old key, or you just want to be double extra paranoid, you can check the fingerprint against the one above:

gpg --fingerprint 3F332AEF

If you are satisfied that you’ve got the right key, and the UIDs match what you expect, I’d appreciate it if you would sign my key:

gpg --sign-key 3F332AEF

Lastly, if you could upload these signatures, i would appreciate it. You can either send me an e-mail with the new signatures (if you have a functional MTA on your system):

gpg --armor --export 3F332AEF | mail -s 'OpenPGP Signatures'

Or you can just upload the signatures to a public keyserver directly:

gpg --keyserver --send-key 3F332AEF

Additionally, I highly recommend that you implement a mechanism to keep your key material up-to-date so that you obtain the latest revocations, and other updates in a timely manner. You can do regular key updates by using parcimonie to refresh your keyring. Parcimonie is a daemon that slowly refreshes your keyring from a keyserver over Tor. It uses a randomized sleep, and fresh tor circuits for each key. The purpose is to make it hard for an attacker to correlate the key updates with your keyring.

I also highly recommend checking out the excellent Riseup GPG best practices doc, from which I stole most of the text for this transition message 😉

Please let me know if there is any trouble, and sorry for the inconvenience.

Continue Reading

Canonical is doing it wrong. Again.

Looks like Canonical, creators of Ubuntu had a great idea to implement new multi-device Linux distro – one code base for all, but development takes too long. Results?

  • Desktop users left with almost nothing to be happy about in each release for some time now. Even package manager called “Software Center” isn’t working properly anymore for independent devs.
  • Mobile users can try to think positive about upcoming Ubuntu Phone releases, but they have to try really hard
  • Ubuntu will probably grow independent from Debian and deb packages, but not yet, so no new defaults in upcoming releases and no changes in present set of apps.
Continue Reading

Using OpenVPN with cheap VPS and NetworkManager

Another gathering of information laying around in various places over the web. This time I wanted to configure OpenVPN on cheap VPS (OVH classic) and my Linux laptops and Android devices. After great deal of problem solving here it is:

The easy part is installing OpenVPN on your VPS. Just follow the guide from DigitalOcean. Download your desired file (I use autologin version). It’s written for CentOS but works well on other distros too. In my case on Ubuntu Server.

Continue Reading

The ultimate guide: Keepass2 on Ubuntu with browser integration

This one is written because to install Keepass2 successfully on Ubuntu 15.04 you need to read and search through at least 5 different sources. So without further ado:

Add ppa’s for Keepass indicator plugin:

sudo add-apt-repository ppa:dlech/keepass2-plugins
sudo add-apt-repository ppa:dlech/keepass2-plugins-beta
sudo apt-get update

Second one contains updated version with solved problem of missing libmagickwand5 dependency.

Continue Reading