A "note to self" post on how to create a systemd service and run it a regular user.
Assuming, you're logged in as a regular user, create the ~/.config/systemd/user/ directory using the mkdir -p ~/.config/systemd/user/
command. Then, create a .service file:
nano ~/.config/systemd/user/my_service.service
Specify the service options:
[Unit]
Description=My_service
[Service]
Restart=always
ExecStart=/path/to/executable
ExecStop=/usr/bin/kill -HUP $MAINPID
[Install]
WantedBy=default.target
It's important that WantedBy
is set to default.target
.
Save the unit file, and reload the systemd daemon using the systemctl --user daemon-reload
command. Enable and start the service as the user:
systemctl --user enable my_service.service
systemctl --user start my_service.service
Finally, run the loginctl enable-linger $USER
command.
Notebook batteries are fickle creatures. They don't like being charged to 100%. But they also not keen on being completely depleted. According to the conventional wisdom, to give your notebook's battery a long, productive, and healthy life, you should avoid charging it above 80% and discharging it below 25%.
Sounds simple, but how can you actually accomplish that without keeping your eyes peeled to the battery charge indicator? By letting the TLP worry about that. Install the tool on your system, configure battery charging thresholds, and leave it to TLP to take care of the rest. Here's how to do this on Linux Mint.
Continue reading
The best way to learn new words and phrases is to use them actively. The next-best way to learn new words is to be exposed to them as much as possible. And since the wallpaper that adorns my graphical desktop environment is what I stare at most of my waking hours, I thought that it'd only make sense to add words and phrases I want to memorize there.
Half an hour after the eureka moment, I had a working hack consisting of a plain text file with words and phrases along with their translations, a wallpaper template PNG file, and a simple Bash shell script. The latter pulls a random line from the text file, and uses the template to generate a new wallpaper with the picked line. Below are all the gory details worth knowing if you want to roll out something similar.
Continue reading
I'm always fashionably late to the party. So forgive me for being the last to get all excited about Restic. Encryption by default, snapshots, deduplication, support for various storage types—Restic checks all the boxes. Not only that, it is also a supremely easy to use backup tool.
While learning how to use Restic, I took notes for future reference. I'm sharing my trivial findings here on the off-chance that someone might find them useful. The notes cover a simple scenario, where Restic backs up data to an external USB storage device.
Continue reading
Nothing lasts forever, including laptop batteries. But how do you know when your laptop's battery is ripe for a replacement? Easy: install the acpi package (sudo apt install acpi
on Ubuntu and Linux Mint), run the acpi -V
command, and check the line that looks something like this:
Battery 0: design capacity 4867 mAh, last full capacity 4584 mAh = 94%
In this case, the battery is at 94% of its designed capacity, so there is no cause for concern. If the value is nearing 50%, you should probably start saving for a new battery.
Since it makes sense to run battery checks regularly, you can create an alias for that. Open the .bashrc file for editing using the nano ~/.bashrc
command and add the following alias:
alias chkbat="acpi -V | grep Battery"
Save the changes, reopen the terminal, and run the chkbat
command.