www.alxm.org

Linux Mint Notes

These are notes for myself about configuring my Linux Mint computer.

Contents

System#

Laptop Battery Care with TLP#

I use TLP to set battery charge thresholds to help keep my laptop battery in good shape for longer. After doing some online research, it looks like starting to charge when below 75% and stopping at 80% is the sweet spot for battery health.

1
$ sudo apt install tlp tlp-rdw tp-smapi-dkms
1
$ sudo tlp setcharge 75 80
1
2
START_CHARGE_THRESH_BAT0=75
STOP_CHARGE_THRESH_BAT0=80

Use tlp-stat to confirm the configured thresholds:

1
2
3
4
5
6
7
8
9
$ sudo tlp-stat -b
...
Parameter value ranges:
* START_CHARGE_THRESH_BAT0/1:  0(off)..96(default)..99
* STOP_CHARGE_THRESH_BAT0/1:   1..100(default)
...
/sys/class/power_supply/BAT0/charge_control_start_threshold =     75 [%]
/sys/class/power_supply/BAT0/charge_control_end_threshold   =     80 [%]
...

Use RAM for /tmp#

Add this line to /etc/fstab to use a RAM-backed file system instead of local storage for /tmp:

1
2
# <device> <mount point> <type> <options> <dump> <pass>
tmpfs /tmp tmpfs defaults,nodev,noexec,nosuid,mode=1777,size=4096M 0 0

This is what the options do:

Check if /tmp is RAM-backed after reboot:

1
2
$ mount | grep /tmp
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noexec,size=4194304k,inode64)

I had trouble installing Linux games from GOG because of the noexec option. Setup failed with errors like eval: ./startmojo.sh: Permission denied. The solution is to run the installer with the --keep flag, which makes MojoSetup write and execute its temporary files in the current directory instead of in /tmp.

Disable Swap#

My computer doesn't have a lot of RAM, but I don't run anything too intense either. Since I don't need swap space, I would rather it be put to better use by the SSD's wear leveling system.

The Linux Mint 18 installer lets you choose not to use a swap partition, but Linux Mint 19 and later always use a swap file located at /swapfile. Note how this is a special file instead of a separate partition. Here are the steps I used to turn it off:

1
$ sudo swapoff -a
1
2
/swapfile none swap sw 0 0
/dev/mapper/cryptswap1 none swap sw 0 0
1
cryptswap1 /swapfile /dev/urandom swap, ...
1
2
$ sudo rm /swapfile
$ reboot

At first I ran swapoff without editing the files in /etc, and that caused issues that added 30 seconds to the kernel boot time according to systemd-analyze! The boot time returned to normal after I edited the two files.


Desktop#

Configure Redshift Manually#

Redshift is great for eye comfort in the evening (I use it all day). Sadly, the internet location server it uses to determine dawn and dusk times has been retired in 2024, which makes Redshift crash at launch on Linux Mint 20 and 21.

Luckily, you can set the dawn and dusk times manually in $HOME/.config/redshift.conf, and then redshift and redshift-gtk will work again:

1
2
3
4
5
6
[redshift]
temp-day=6500
temp-night=3600
dawn-time=06:00-06:30
dusk-time=18:00-18:30
fade=1

Fix Oversized Icons in Cinnamon Panels#

When I upgraded to Cinnamon 4.4.8, some of the panel icons like WiFi and Sound were larger than the rest. Here is a way to fix them:

Before:

After:


Git#

Show the Time and Git Branch on the Shell Prompt#

I have my Bash prompt show the current time, and if inside a Git repo also the name of the checked-out branch. This goes at the end of ~/.bashrc, to override any previously set PS1 (the environment variable for the shell prompt's format string),

1
2
3
4
5
6
git_branch() {
    branch_name=$(git symbolic-ref --short HEAD 2>/dev/null)
    [ $? -eq 0 ] && echo "[$branch_name]"
}

export PS1='\t \u@\h \w$(git_branch) \$ '

The shell prompt should look something like this now:

1
2
3
4
18:44:05 alex@laptop ~ $
18:44:06 alex@laptop ~ $ mkdir MyProject && cd MyProject
18:44:14 alex@laptop ~/MyProject $ git init
18:44:20 alex@laptop ~/MyProject[master] $

Convenient Single-Letter Aliases#

I keep a few short shell aliases for the Git commands I use the most day to day. All of them are for read-only actions though, muscle memory can be dangerous when you're tired...

1
2
3
4
5
6
alias b="git branch -a -vv"
alias d="git diff"
alias ds="git diff --staged"
alias h="git show"
alias l="git log --graph --decorate=full --pretty=medium"
alias s="git status"

Colored Text in the Terminal#

Add to ~/.gitconfig:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
[color]
    ui = true
[color "branch"]
    current = yellow reverse
    local = yellow bold
    remote = green bold
[color "diff"]
    meta = magenta bold
    frag = magenta bold
    old = red bold
    new = green bold
[color "status"]
    added = blue bold
    changed = green bold
    untracked = cyan bold

Push to Multiple URLs#

Git remotes can be configured to push to multiple URLs, which is great for having backups and keeping things distributed. You can add extra addresses with git remote set-url --add --push origin git@host2:project.git or edit the project's .git/config directly:

1
2
3
4
5
6
[remote "origin"]
    url = git@host1:project.git
    pushurl = git@host1:project.git
    pushurl = git@host2:project.git
    pushurl = git@host3:project.git
    fetch = +refs/heads/*:refs/remotes/origin/*