Simple automatic script to configure Linux Mate after an installation

Posted by & filed under .

I tend to format and reinstall my operating systems quite often. Usually every 6 months with each new releases of Linux Mint. I like seeing the changes they’ve done in the installation process steps and I like starting over from scratch, getting rid of all the useless software I’ve installed and the useless configuration I’ve tested. And if I ever installed a malware, virus, trojan, everything will be erased too, it’s more secure that way!

Installing the latest Linux Mint is quite easy and fast, that is not a problem. However, having to install and configure everything else does take some time, it’s redundant and can be avoided. Here’s the terminal command that can be used to install and configure Linux Mint in a much better way. You can easily copy, modify it to your liking and create your own automatic installation script!

With these commands, it’s extremely easy and fast to do the whole configuration but it must be said that all my data is on a Network Attached Storage (NAS) so I have nothing to backup before a new installation.

I’m using dconf instead of gsettings, most examples on the web are using gsettings but for some reason, dconf gave me more control and less problem.

If you have a setting you’d like to modify, run “gsettings list-recursively > file”, then make your Mate’s modification, run “gsettings list-recursively > file2” and then “diff file1 file2”. That way, you will see exactly what has change.

Linux Mint - Mate

Since I’m using dm-crypt for encrypting the whole hard drive and also the nvidia driver, let’s fix a small bug first:

# Fix GRUB bug with nvidia driver and dm-crypt
sudo sed -i -e 's/quiet splash//g' /etc/default/grub
sudo update-grub

To automount a drive, run this command below. The password is in the file but since the whole drive is encrypted, it’s quite secure. Just modify the IP, the password, the username and group of your user in the command first.

sudo echo "// /media/nas cifs user,username=z,password=XXXXXX,uid=USERNAME,gid=GROUP 0 0" >> /etc/fstab

Install applications

# Install youtube-dl
sudo apt install curl && sudo curl -L -o /usr/local/bin/youtube-dl && sudo chmod a+rx /usr/local/bin/youtube-dl

# Install mp3gain
sudo add-apt-repository ppa:flexiondotorg/audio && sudo apt update && sudo apt install mp3gain

# Install some usefull applications
sudo apt install python-pip numlockx id3v2 p7zip-full ttf-mscorefonts-installer imagemagick lame mplayer mencoder tree lftp filezilla libsox-fmt-mp3 openclipart deluge boinc scrot

Configure the GUI interface

# Configure terminal
dconf write /org/mate/terminal/profiles/default/background-color \'#000000000000\'
dconf write /org/mate/terminal/profiles/default/bold-color \'#000000000000\'
dconf write /org/mate/terminal/profiles/default/cursor-blink-mode \'on\'
dconf write /org/mate/terminal/profiles/default/cursor-shape \'block\'
dconf write /org/mate/terminal/profiles/default/foreground-color \'#0000FFFF0000\'
dconf write /org/mate/terminal/profiles/default/scrollback-unlimited true
dconf write /org/mate/terminal/profiles/default/use-theme-colors false
dconf write /org/mate/terminal/profiles/default/visible-name \'Z\'

# Configure the text editor xed
dconf write /org/x/editor/preferences/editor/display-line-numbers true
dconf write /org/x/editor/preferences/editor/wrap-mode-none
dconf write /org/x/editor/preferences/editor/insert-spaces false

# Configure the file explorer Caja
dconf write /org/mate/caja/preferences/default-folder-viewer \'list-view\'
dconf write /org/mate/caja/preferences/show-hidden-files true
dconf write /org/mate/caja/preferences/executable-text-activation \'display\'
dconf write /org/mate/caja/preferences/date-format \'iso\'
dconf write /org/mate/caja/preferences/show-image-thumbnails \'never\'
dconf write /org/mate/caja/preferences/show-directory-item-counts \'always\'
dconf write /org/mate/caja/list-view/default-column-order "['size', 'name', 'type', 'date_modified', 'date_accessed', 'group', 'where', 'mime_type', 'octal_permissions', 'owner', 'permissions', 'selinux_context']"
dconf write /org/mate/caja/list-view/default-visible-columns "['size', 'name', 'type', 'date_modified']"
dconf write /org/mate/caja/window-state/side-pane-view \'tree\'

# Configure the Desktop
dconf write /org/mate/caja/desktop/computer-icon-visible false
dconf write /org/mate/caja/desktop/home-icon-visible false
dconf write /org/mate/caja/desktop/network-icon-visible false
dconf write /org/mate/caja/desktop/volumes-visible false

# Configure Window
dconf write /org/mate/Marco/general/focus-mode \'sloppy\'

# Configure the Panel
dconf write /org/mate/panel/toplevels/bottom/size 40

# Configure screensaver / Power Management
dconf write /org/mate/session/idle-delay 60
dconf write /org/mate/power-manager/sleep-display-ac 3600

Configure the keyboard; xmodmap will replace the nobreakspace character to a normal regular space, nobreakspace is an hidden character which can cause problems when you code.

xmodmap -pke > ~/.Xmodmap; cat ~/.Xmodmap | sed 's/nobreakspace/space/g' > ~/.Xmodmap
gsettings set org.mate.peripherals-keyboard delay 280
gsettings set org.mate.peripherals-keyboard rate 70
gsettings set org.mate.interface cursor-blink-time 1200

Configure the mouse, faster and make it so that the window raise when you hover it

gsettings set org.mate.peripherals-mouse motion-acceleration 10.0
gsettings set org.mate.peripherals-mouse motion-threshold 10
gsettings set org.mate.Marco.general focus-mode 'sloppy'

When I press the printscreen key, I prefer having GIMP open it up since I can easily crop, scale, modify or add text on the image. It’s also quite useful when you need to grab multiple print screen because it will just open up a new tab every time you press the printscreen key.

# Configure PrintScreen key
gsettings set run-command-screenshot "disabled"
dconf write /org/mate/desktop/keybindings/custom0/action \'"scrot -e \"mv \$f /tmp; gimp /tmp/\$f\""\'
dconf write /org/mate/desktop/keybindings/custom0/binding \'Print\'
dconf write /org/mate/desktop/keybindings/custom0/name \'PrintScreen\'

If you’re using GIMP with special fonts, just copy them back

# Configure GIMP fonts
mkdir ~/.fonts
cp /media/nas/backup/fonts/*ttf ~/.fonts/

Configure your crontab like it was before.

# Configure crontab
crontab -l > tempCrontab
echo "30 */8 * * *  trash-empty 7" >> tempCrontab
echo "@reboot       sleep 30 && DISPLAY=:0 xmodmap ~/.Xmodmap" >> tempCrontab
crontab tempCrontab
rm -f tempCrontab

Install the trash-cli software which is quite useful, it will automatically delete files in your trash that are X days old. In my case, I configured it to 7 days as shown in the crontab. With this software, you don’t need to think about emptying your trash anymore. As for April 16th 2018, Debian’s repository has an old version which is buggy, use these commands to install the latest version.

# Install and configure trash-cli
# sudo apt install python-pip
pip install --upgrade pip
pip install --user setuptools
pip install trash-cli --user

That’s it! With these commands, my new installation is configured to about 90% and it only took 4 minutes to run this script and it’s all automatic.

Other configuration that isn’t automated yet is Firefox. I find the default installation a bit broken.

about:config : 
browser.bookmarks.autoexportHTML	true
browser.showQuitWarning			true
browser.urlbar.clickSelectsAll		true
browser.urlbar.trimURLS			false
mousewheel.min_line_scroll_amount	50
View Image
Web Developer
uBlock Origin
Duck Duck Go Plus
Privacy Badger
HTTPS Everywhere

Same with Filezilla:

Edit / Settings / Interface: Do not save passwords
Edit / Settings / Interface: Show the Site Manager on startup
Edit / Settings / Interface: When starting a new connection: Connect in current tab
Edit / Settings / Interface / File lists: Double-click action on files: View/Edit
Edit / Settings / File editing / Custom editor: /usr/bin/xed
Edit / Settings / File editing / Always use default editor
Edit / Settings / Filetype associations: uncheck

Leave a Reply

Your email address will not be published. Required fields are marked *