Protecting my sleep

My another attempt to break the habit of being up until very late into the night and as such very tired the next day.

For years I thought of configuring my computer to suspend at around night time so I will be somehow forced to go to sleep. Well, the main problem with this was that I only thought about it and never actually did any research on this subject.

At normal times under my normal user I suspend my machine with elogind loginctl command and this works fine but there might be a problem with sessions and stuff around that which I refuse to work with. So I searched a bit and found out that there is nice system API to manage power state.

The system/kernel API consist of a file located at /sys/power/state.
When I try to print the content of this file it shows the currently available states (or values it accepts) which is my case are:

$ cat /sys/power/state
freeze mem disk

And when I looked at the printed values I saw mem option which is probably what I want (I was lazy and did not look at any docs) to suspend my machine into RAM. The power state can be changed by writing desired state into /sys/power/state file.

$ echo "mem" > /sys/power/state

Sure, you need to be root to do so, but so what? This is my machine and I can. Since I figured this out I put it into a file, set it executable and configured cron to start it at 23:00 from Sunday to Thursday like this.

0 23 * * 0-4 root /usr/scripts/suspend

And done, now I hope it can help me get my desired rest.

Articles from blogs I follow:

Richard Stallman's political discourse on sex

Richard Stallman, the founder of the Free Software Foundation, has been subject to numerous allegations of misconduct. He stepped down in 2019, and following his re-instatement in 2021, a famous open letter was published in which numerous organizations and i…

via Drew DeVault's blog November 25, 2023

Upgrading to FreeBSD 14 - how to fix a broken BIOS bootcode

A lot of people running ZFS zroot have managed to break their FreeBSD systems upgrading from 13.2 to the new 14.0 release because of a broken BIOS bootcode. In this tutorial I'll show you how you can fix that without having to reinstall.

via unixsheikh.com November 22, 2023

C++ Guidelines

C++ is definitely a language that has Lots of Ways to do It – kind of like Perl’s TIMTOWTSAC. A consequence is that when writing code, you need to think about which way to do things. When context-switching between projects, employers, or what-have-you, yo…

via [bobulate] November 21, 2023

Generated by openring