Simple automatic script to configure Linux Mate after an installation

Posted by & filed under .

Linux Mint - Mate

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 softwares, configurations and tests that I’ve installed or done. It’s also more secure in case there’s a malware, virus or trojan that got installed.

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. If you don’t have a NAS, then you should definitely get one, it’s a must.

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, try this:

gsettings list-recursively > file1
# Make your Mate's modification
gsettings list-recursively > file2
diff file1 file2

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
# https://bugs.launchpad.net/ubuntu/+source/nvidia-graphics-drivers-367/+bug/1638983
sudo sed -i -e 's/quiet splash//g' /etc/default/grub
sudo update-grub

If you have a NAS, then to automount a drive, modify the command below and run it:

sudo sh -c "echo '//123.123.123.123/folder /media/folder cifs user,username=?,password=?,uid=?,gid=?,vers=3.0 0 0 _netdev' >> /etc/fstab"

Install youtube-dl:

sudo apt install curl && sudo curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl && sudo chmod a+rx /usr/local/bin/youtube-dl

Install mp3gain manually because it is not in Debian’s repository:

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

Install some basic applications:

sudo apt install gimp numlockx id3v2 p7zip-full ttf-mscorefonts-installer imagemagick lame mplayer mencoder tree lftp filezilla openclipart

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 with xmodmap which will replace the nobreakspace character to a normal regular space. The nobreakspace character 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:

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

Configure the printscreen key, this will open up the screenshot with GIMP so you can easily modify the image afterwards 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 org.mate.Marco.global-keybindings 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\'

Configure GIMP’s fonts:

# Configure GIMP fonts if you need to have special fonts:
mkdir $HOME/.fonts
cp /somewhere/backup/fonts/*ttf ~/.fonts/

Configure GIMP’s image orientation:

# Configure GIMP image orientation
cat << EOF > $HOME/.gimp-2.8/parasiterc
# GIMP parasiterc
# 
# This file will be entirely rewritten each time you exit.

(parasite "exif-orientation-rotate" 1 3 "yes")
EOF

Configure file association:

cat << EOF > $HOME/.config/mimeapps.list
[Default Applications]
video/x-matroska=vlc.desktop
video/mp4=vlc.desktop
video/x-msvideo=vlc.desktop
video/webm=vlc.desktop
video/mpeg=vlc.desktop
message/rfc822=thunderbird.desktop
video/mp2t=vlc.desktop
audio/mpeg=vlc.desktop

[Added Associations]
video/x-matroska=vlc.desktop;
video/mp4=vlc.desktop;
video/x-msvideo=vlc.desktop;
video/webm=vlc.desktop;
video/mpeg=vlc.desktop;
message/rfc822=thunderbird.desktop;
video/mp2t=vlc.desktop;
audio/mpeg=vlc.desktop;
EOF

Install trash-cli, very useful software, it will automatically delete files in your trash that are X days old. You don’t need to think anymore about emptying your trash. Debian’s repository has an old version which is buggy, use these commands to install the latest version:

cd $HOME
git clone https://github.com/andreafrancia/trash-cli.git
cd trash-cli
sudo python setup.py install
cd ..
rm -fr trash-cli

Configure crontab:

# 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

That’s it! With these commands, my new installation is almost totally configured, it took only a few minutes and it’s all automatic!

Finally, some last personal configurations that isn’t automated unfortunately. Here’s the one of Firefox. Note that AdBlock Plus is in blacklist mode instead of the default whitelist, this means that only websites added in this plugin will have their ads blocked. Else, I find that it will break webpages too often.

about:config : 
browser.bookmarks.autoexportHTML	true
browser.urlbar.clickSelectsAll		true
browser.urlbar.trimURLS			false
mousewheel.min_line_scroll_amount	50
View Image		https://addons.mozilla.org/en-US/firefox/addon/view-image/
Web Developer		https://addons.mozilla.org/en-US/firefox/addon/web-developer
AdBlock Plus            Settings / Advanced / My Filter List: @@*$document,domain=~youtube.com|~speedtest.net

Configure 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

Configure LibreOffice:

Tools / Automatic Spell Checking
Tools / AutoCorrect Options... / Options / URL Recognition: Disable
Tools / AutoCorrect Options... / Options / Replace dashes: Disable
Tools / Customize / Keyboard: delete CTRL-Down and CTRL-Up

Configure VLC:

Tools / Preferences / Interface / Use only one instance: Disable
Tools / Preferences / Interface / Display playlist tree
Tools / Preferences / Video / Video snapshots / Directory
Tools / Preferences / All / Interface / Main interfaces / Qt / Systray icon: Disable
Tools / Preferences / All / Interface / Main interfaces / Qt / Show notification popup: Never
Tools / Preferences / All / Interface / Main interfaces / Qt / Resize interface to the native video size: Disable
Tools / Preferences / All / Interface / Main interfaces / Qt / Continue playback?: Never
Tools / Preferences / All / Playlist / Subdirectory Behavior: Expand

Leave a Reply

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

 

Comments / Questions