Linux

Little hacks I found useful and may need to refer to again later, cos it’s all so easy to forget. Raspberry Pi stuff is in its own page.

Invert Screen Colors

(to overcome dark mode madness)

sudo apt-get install xcalib then use xcalib -i -a

Add keyboard shortcut:
Menu: open keyboard > shortcuts > custom shortcuts. Add a new shortcut (with the “+” button). The command should be “xcalib -i -a” or “/usr/bin/xcalib -i -a

SSD

DigitalOcean has a good description of why.

Set the automatic TRIM job to daily

sudo mkdir -v /etc/systemd/system/fstrim.timer.d
sudo touch /etc/systemd/system/fstrim.timer.d/override.conf
nano admin:///etc/systemd/system/fstrim.timer.d/override.conf

Then reboot, and to check, use

systemctl cat fstrim.timer

Confirm that you’ve successfully edited trim’s configuration by executing this terminal command:

systemctl cat fstrim.timer

Your output should look approximately like this:

# /lib/systemd/system/fstrim.timer
[Unit]
Description=Discard unused blocks once a week
Documentation=man:fstrim
ConditionVirtualization=!container

[Timer]
OnCalendar=weekly
AccuracySec=1h
Persistent=true

[Install]
WantedBy=timers.target

# /etc/systemd/system/fstrim.timer.d/override.conf
[Timer]
OnCalendar=
OnCalendar=daily

Let’s take a closer look at this output. The first part shows the default setting (weekly), the second part shows the overriding setting that you’ve applied. That overriding setting contains two elements: first the existing OnCalendar setting (weekly) is being deleted by specifying nothing after the = sign, and then a new OnCalendar setting is being applied (daily).

If you ever want to check whether fstrim has actually happened, and when it happened, you can use this terminal command:

journalctl | grep fstrim.service

Want to undo? Remove the last 4 lines (the override.conf bit)

Limit swappiness to reduce writes

Decreasing the swappiness to a more reasonable level, namely 25:
check your current swappiness setting.

cat /proc/sys/vm/swappiness

The result will probably be 60.

sudo nano /etc/sysctl.conf

At the very end of the existing text:

vm.swappiness=25

Save the file and close, then reboot.

Log2Ram

To reduce th enumber of writes. Has its own page.

Linux Mint change notifications duration

The actual time on screen for transient notifications is hardcoded on /usr/share/cinnamon/js/ui/messageTray.js. Luckily it’s a plain text javascript file so amenable to end user tweaking (after making a backup and with elevated privileges)

The hard-coded values are near the start of the file and look like this. Time is in seconds.

var NOTIFICATION_TIMEOUT = 4;
var NOTIFICATION_CRITICAL_TIMEOUT_WITH_APPLET = 10;

NOTIFICATION_TIMEOUT is the default timeout

NOTIFICATION_CRITICAL_TIMEOUT_WITH_APPLET is used if the notification is flagged by the sending app as CRITICAL and the notification applet is present. If the applet is absent critical notifications won’t timeout.

So if you wanted to tweak
Make a back up

sudo cp /usr/share/cinnamon/js/ui/messageTray.js /usr/share/cinnamon/js/ui/messageTray.js.original

Open the file with elevated privileges

xed admin:///usr/share/cinnamon/js/ui/messageTray.js

Once tweaked and saved restart Cinnamon with Ctrl-Alt-Esc

Remove lock screen and logout from Cinnamon menu

  • Make a local copy of the menu applet: cp -r /usr/share/cinnamon/applets/menu@cinnamon.org ~/.local/share/cinnamon/applets
  • open the original: xed ~/.local/share/cinnamon/applets/menu@cinnamon.org/applet.js
  • // comment out everything in //Lock screen and //Logout button all the way down to the next //
  • Save the file and close the text editor.
  • Restart Cinnamon with Ctrl-Alt-Esc.

Reinstalling system

Disable window snapping

gsettings get org.cinnamon.muffin edge-tiling
  • this lists the current setting, which stubbornly stayed stuck on “true”. But type:
gsettings set org.cinnamon.muffin edge-tiling false

and the accursed tiling and snapping is gone !

Install Telegram

4 ways to install Telegram on Ubuntu 22.04 | 20.04 LTS

Without the flatpak crap.

Install Protonvpn

Instructions for linux here.

Flush DNS cache

andy@HP3:~$ sudo resolvectl flush-caches

should work. If not try

sudo systemd-resolve --flush-caches

to check,use

$ sudo systemd-resolve --statistics
or
$ sudo resolvectl statistics

use statistics before and after to compare, shoul be zeroed after flush.