Random screensaver with Linux Mint Cinnamon

If you like screensavers, probably you already installed the xscreensaver package, but in Cinnamon you don't have the option to select a random one. But we can let the crontab periodic jobs change the systems entry where the currently selected screensaver is set.

Install instructions

In a terminal launch the command
crontab -e
to edit your crontab definitions and add the following at the end of the file:
# Randomize screensaver
0 * * * * DISPLAY=:0 gsettings set org.cinnamon.desktop.screensaver xscreensaver-hack \'$(ls /usr/lib/xscreensaver | sort -R | head -n 1)\' 2>&1 | logger -t screensaver
This will change every hour the screensaver to one located in the xscreensaver package.

Use Nemo with All-in-one-Places Cinnamon applet

It's really a pity, that the All-in-one-places applet hasn't got an update for including support for Nemo, as this is IMHO the best one of its kind.
But there's a workaround.
Its enough to add Nemo to the available filemanagers in settings.py
I provide you here a patchfile that you can apply, so you don't have to edit the file by yourself.
Just execute the following steps in a command line terminal.

Install instructions

First you'll have to create the patchfile with this:
cat <<EOF  >/tmp/All-in-one-Place.patch
--- a/.local/share/cinnamon/applets/all-in-one-places@jofer/settings.py
+++ b/.local/share/cinnamon/applets/all-in-one-places@jofer/settings.py
@@ -28,7 +28,7 @@ PANEL_WIDGETS = [
     {'type': 'switch', 'args': { 'key': 'full-color-panel-icon', 'label': _("Show the panel icon in full color") }},
     {'type': 'switch', 'args': { 'key': 'show-panel-text', 'label': _("Show text in panel") }},
     {'type': 'entry', 'args': { 'key': 'panel-text', 'label': _("Panel text") }},
-    {'type': 'combo', 'args': { 'key': 'file-manager', 'label': _("File manager"), 'values': {'nautilus': 'Nautilus', 'thunar': 'Thunar', 'pcmanfm': 'PCManFM'} }},
+    {'type': 'combo', 'args': { 'key': 'file-manager', 'label': _("File manager"), 'values': {'nautilus': 'Nautilus', 'thunar': 'Thunar', 'pcmanfm': 'PCManFM', 'nemo': 'Nemo'} }},
     {'type': 'entry', 'args': { 'key': 'connect-command', 'label': _("Application for the  \"Connect to...\" item") }},
     {'type': 'entry', 'args': { 'key': 'search-command', 'label': _("Application for the \"Search\" item") }}
Apply the patch with this:
cd ~ ; patch -p1 < /tmp/All-in-one-Place.patch
No log out of the cinnamon session is necessary.
Just open now the settings of All-in-one-place and select Nemo from the filemanager combo.

Adorn a dumb terminal

 Sometimes, you need to sit in front of a servers terminal, one without any window manager.
So you lack the cut&paste function of your mouse.
And to make things worse, it's keyboard isn't your native one, so you start trying out certain characters like . / and so on.

An administration nightmare!

So here come some instructions to get rid of these burdens so you can focus on the real problems.

Set your favourite keyboard

Just load another keyboard translation table that fits your fingers needs:

loadkeys [keymap]

# Examples:
# loadkeys de   # german keymap
# loadkeys es   # spanish keymap
Available keymaps can be found mostly in /lib/kbd/keymaps.

Cut&paste mouse functionality

If your server has internet connection than go and install the gpm package, a cut and paste utility and mouse server for virtual consoles, which permits to use your mouse on the terminal, even if it's very basic it permits selection and pasting with middle button.
# Install the gpm package
yum install | apt-get install | etc.   gpm

# Launch the daemon
gpm -m /dev/input/mice -t exps2

Speed-up bash scripts that use grep often

The last day I ran into a very awkward situation, but lets start from the beginning:
I wrote a bash script that had to perform several regular expression grep's in several text files.
So far so good, but the script always needed several minutes since the first version. I never wondered about this long execution time, the script runs on a remote server and also uses some mysql searches on another server.
Until some days ago, I wanted to debug a minor error with bash -xv to see all instructions when being executed.
To read the huge output more easily, I logged into the remote server from emacs editor and launched the script and had all the output in my emacs window in a few seconds. Wait, it only needed a few seconds?!
What happened, I rechecked the execution, with exactly the same parameters to the script from my emacs shell and from a ssh terminal.
The same, within emacs it only took some seconds, within the ssh terminal y took minutes.

So what's going on here?
Investigating the processes in the remote server with htop showed that the grep commands consumed almost 100% of the CPU for some time.
But when launched from emacs they did not.
What might be different?
Well, what about the environment?
Emacs might use it's own set of environment, different from a terminal.
Looking at the export definitions of both, I could see that the locale was different, emacs was using the C, whereas the terminal was using the English en_UK.UTF8.
Issuing a export LC_ALL=C in the terminal and then launching the script ... only a few seconds.
So it seems, grep is sensible to the locale of the shell.
Investigating in the web confirmed this, people talk about a speed enhancement of up to 10 times when using the C locale with grep, as it doesn't have to convert anything, it just compares a plain ASCII set of character, which in most cases is enough.
Also, grep is slightly faster when comparing fixed strings if you use the -F flag or call it with fgrep (due to lazyness I always used grep in such cases).

Instructions for speeding up grep

At the beginning of my scripts, I now put these instructions, which will force to use the C locale for all three flavours of grep:
shopt -s expand_aliases
for g in "" e f; do
    alias ${g}grep="LC_ALL=C ${g}grep"  # speed-up grep commands by not considering locale.
It does not work to just put export LC_ALL=C at the beginning.