How to disable the Forward/Back buttons on mouse

Source: https://unix.stackexchange.com/ by Gilles

Start the program xev in a terminal. Move the mouse inside the xev window; you’ll see a lot of stuff scroll by. Press each button in turn. Then switch back to the terminal window and press Ctrl+Cxev shows a description of each input event, in particular ButtonPress and ButtonReleasefor mouse clicks (you’ll also see a number of MotionNotify for mouse movements and other events).

It’s likely that your forward and back buttons are mapped to mouse buttons, maybe buttons 8 and 9:

ButtonPress event, serial 29, synthetic NO, window 0x2e00001,
    root 0x105, subw 0x0, time 2889100159, (166,67), root:(1769,98),
    state 0x0, button 8, same_screen YES

If that’s the case, remap these buttons to a different action in your browser; or to disable the buttons altogether, put these lines in a file called ~/.Xmodmap:

! Disable buttons 8 and 9
pointer = 1 2 3 4 5 6 7 0 0

Test it with the command xmodmap ~/.Xmodmap. Most desktop environments and window managers run this command automatically when you log in; if yours doesn’t, arrange for it to run when X starts.

It’s also possible that your mouse sends a keyboard event when you press these buttons:

KeyPress event, serial 32, synthetic NO, window 0x2e00001,
    root 0x105, subw 0x0, time 2889100963, (957,357), root:(2560,388),
    state 0x0, keycode 166 (keysym 0x1008ff26, XF86Back), same_screen YES,
    XLookupString gives 0 bytes: 
    XmbLookupString gives 0 bytes: 
    XFilterEvent returns: False

In that case, put lines like these in ~/.Xmodmap:

keycode 166 = NoSymbol
keycode 167 = NoSymbol

Helpful link: Reprogram mouse buttons

How to Install the MySQL ODBC Driver on Ubuntu 16.04 or Linux Mint 18.x

Source: https://www.datasunrise.com/blog/

# Download the ODBC driver:

Download ODBC driver for Ubuntu 16.04

wget https://dev.mysql.com/get/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit.tar.gz

# Extract:

tar -xvf mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit.tar.gz

# Copy the driver to the ODBC folder:

sudo cp mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit/lib/libmyodbc5* /usr/lib/x86_64-linux-gnu/odbc/

# Install:

sudo mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit/bin/myodbc-installer -d -a -n "MySQL" -t "DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so;"

# Check:

sudo mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-64bit/bin/myodbc-installer -s -a -c2 -n "test" -t "DRIVER=MySQL;SERVER=127.0.0.1;DATABASE=mysql;UID=root;PWD=password"

[Result should be “Success”]

# Download the 32-bit ODBC driver:

Download 32-bit ODBC driver for Ubuntu 16.04

wget https://dev.mysql.com/get/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-32bit.tar.gz

# Extract:

tar -xvf mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-32bit.tar.gz

# Copy the driver to the ODBC folder:

sudo cp mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-32bit/lib/libmyodbc5* /usr/lib/i386-linux-gnu/odbc/

# Install:

sudo mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-32bit/bin/myodbc-installer -d -a -n "MySQL" -t "DRIVER=/usr/lib/i386-linux-gnu/odbc/libmyodbc5w.so;"

# Check:

sudo mysql-connector-odbc-5.3.10-linux-ubuntu16.04-x86-32bit/bin/myodbc-installer -s -a -c2 -n "test" -t "DRIVER=MySQL;SERVER=127.0.0.1;DATABASE=mysql;UID=root;PWD=password"

[Result should be “Success”]

Connecting Xiaomi Redmi Note 3 on Linux (Mint)

First install Android tools:

sudo apt-get install android-tools-adb

Open file (create it if necessary):
/home/[your-username]/.android /adb_usb.ini

and add next line in it:

0x2717

Open file:
/lib/udev/rules.d/69-libmtp.rules

and add next lines:

 # Xiaomi Redmi Note 3
 ATTR{idVendor}=="2717", ATTR{idProduct}=="ff68", SYMLINK+="libmtp-%k", MODE="660", GROUP="audio", ENV{ID_MTP_DEVICE}="1", ENV{ID_MEDIA_PLAYER}="1"

Restart services:

sudo service udev restart

Now you should be able to see your phone’s storage when you connect it to your computer over USB cable.

GRUB shows Windows 7 instead of Windows 10

source: link

author: david6

After installing Windows 10, every time I get a kernel update or I run the update-grub2 it always shows Windows 7 instead of Windows 10. How do I fix this permanently?

The reason why it still shows Windows 7 instead of Windows 10 is that the file /usr/lib/os-probes/mounted/20microsoft does not contain the label for Windows 10, so during the os-prober detection of the OS it falls back to Windows 7.

To correct this, you need to make the following changes to the /usr/lib/os-probes/mounted/20microsoft file:

NOTE: Always make a backup of the file before modifying it!

if item_in_dir -q bootmgr "$2"; then
        # there might be different boot directories in different case as:
        # boot Boot BOOT
        for boot in $(item_in_dir boot "$2"); do
                bcd=$(item_in_dir bcd "$2/$boot")
                if [ -n "$bcd" ]; then
                        if grep -qs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; then
                                long="Windows 10 (loader)"
                        elif grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then
                                long="Windows 8 (loader)"
                        elif grep -qs "W.i.n.d.o.w.s. .7" "$2/$boot/$bcd"; then
                                long="Windows 7 (loader)"

the changes above are changing the line if grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then to elif grep -qs "W.i.n.d.o.w.s. .8" "$2/$boot/$bcd"; then, and adding if grep -qs "W.i.n.d.o.w.s. .1.0" "$2/$boot/$bcd"; then and long="Windows 10 (loader)" above that line and saving it.

Once saved, then running os-prober now looks like this:

terrance@terrance-ubuntu:~$ sudo os-prober
[sudo] password for terrance: 
/dev/sdf1:Windows 10 (loader):Windows:chain

then running update-grub2 it will now make the updates to your /boot/grub/grub.cfgpermanent anytime you get a kernel update so it will show the correct version of Windows now (example below):

terrance@terrance-ubuntu:~$ sudo update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.19.0-26-generic
Found initrd image: /boot/initrd.img-3.19.0-26-generic
Found linux image: /boot/vmlinuz-3.13.0-58-generic
Found initrd image: /boot/initrd.img-3.13.0-58-generic
Found linux image: /boot/vmlinuz-3.13.0-57-generic
Found initrd image: /boot/initrd.img-3.13.0-57-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
Found Windows 10 (loader) on /dev/sdf1
done

Hope this helps!

Install pngquant on Raspbian, Raspberry Pi

pngquant is a command-line utility and a library for lossy compression of PNG images. The conversion reduces file sizes significantly (often as much as 70%) and preserves full alpha transparency.

Install dependency, a library implementing an interface for reading and writing PNG (Portable Network Graphics) format files:

apt-get install libpng-dev

Download source code:

git clone git://github.com/pornel/pngquant.git

Go to directory:

cd pngquant

Build it:

make

Install it system-wide:

sudo make install

More info: http://pngquant.org/install.htmlhttps://github.com/pornel/pngquant

Raspberry Pi GPIO Temp Controlled Fan

Source: https://ich.wtf/blog/en-raspberry-pi-fan-gpio.php

Author: HerrAusragend

Our aim:

We want to setp up an automatic, GPIO and temp controlled fan using a Raspberry Pi without additinal software. After the CPU Core temperature exceeds a specific temperature, the fan starts spinning.

Needed:

  • Raspberry Pi (Model B+) (Buy)
  • Fan (4-Pin, 12V) inin this case from an old NVIDIA Graphicscard
  • Pinboard
  • GPIO Connector wires (3x) (Buy)
  • Transistor BC337-40 800mA (Buy)
  • Resistor 1 kΩ 0.5W (Buy)

These hyperlinks are just recommended. You can use similar parts.

Helpful Links:

Plan:

rpi circuit diagram
Circuit diagram

 

We connect Pin 4 (5V out) directly to the fan.
Pin 6 (Ground) will be connected over the Transistor with the 2nd fan wire.

To activate the Transistor, we need a low volatage, which we gain by Pin 3 (GPIO2). The GPIO Pins have a standard voltage of 3.3V. We reduce this by inserting the Resistor.

Result:

If we now switch on Pin 3 (GPIO2), the fan should start to spinn.

Enable GPIO2: (root)

echo "2">/sys/class/gpio/export
echo "out">/sys/class/gpio/gpio2/direction

Switch on GPIO Pin / Fan (root)

echo "1">/sys/class/gpio/gpio2/value

Switch off GPIO Pin / Fan (root)

echo "0">/sys/class/gpio/gpio2/value

Set up autmoatic temp control

In the following, we will set up the fan so that it starts after reaching a special temperature.

We log into the Raspberry Pi as root.

Prinzip:

The Raspberry Pi autmoaticly checks the core temperature throught the built-in control panel.
If the temperature exceeds a certain value, the fan will start.
As long as the temp doesn’t fall below our value, the fan will not stop.

apt-get update && apt-get upgrade
apt-get install nano

Now we locate our directory of the script…

mkdir /home/fan
cd /home/fan

…and create our script.

nano fan.sh

Copy the following content into the script: (Use right mouse button to paste)

#!/bin/sh
timestamp() {
	date +"%Y-%m-%d %T"
}
LOGDIR="/var/log/fan.log"

VALUE=42

TEMP=`vcgencmd measure_temp | cut -c6,7`
STATUS=`cat /sys/class/gpio/gpio2/value`
echo `timestamp` "  Info:    Temperature: $TEMP"	>>$LOGDIR
if [ $TEMP -ge $VALUE ] && [ $STATUS -eq 0 ]
	then
	echo `timestamp` "  Warning: Fan started."	>>$LOGDIR
	echo "1">/sys/class/gpio/gpio2/value
elif [ $TEMP -le $VALUE ]  && [ $STATUS -eq 1 ]
	then
	echo `timestamp` "  Warning: Fan stopped."	>>$LOGDIR
	echo "0">/sys/class/gpio/gpio2/value
fi

To change the value, you have to edit line 6.

To let the script run in background, we need cronjob.

crontab -e

and paste the following content:

* * * * * /home/fan/./fan.sh

(repalce with your path)

Install Xfce 4.12 in Ubuntu using a PPA

Source: http://www.omgubuntu.co.uk/2015/03/xfce-4-12-released-after-almost-three-years, by

Although probably not recommended just yet (early doors and all that) the Xubuntu Development PPA contains pre-release builds of Xfce 4.12 for Ubuntu 14.04 LTS and 14.10 users to install from at their own risk.

Add the Xubuntu Dev PPA to Ubuntu’s Software Sources using a Terminal and the following commands (assuming the Xfce desktop is already installed):

sudo add-apt-repository ppa:xubuntu-dev/xfce-4.12
sudo apt-get update && sudo apt-get dist-upgrade

To remove the PPA and downgrade to the version of PPA in the main Ubuntu repos/other installed PPAs the ‘ppa-purge’ utility should be installed and used:

sudo apt-get install ppa-purge
sudo ppa-purge ppa:xubuntu-dev/xfce-4.12

Overclocking Raspberry Pi: Set scaling_governor on Raspbian boot

If you are trying to overclock your Raspberry, but CPU keeps running at same frequency, there may be a reason in aggressive scaling_governor set to “powersave”.

Check your scaling_governor:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

If the result is

powersave

its probably the reason why your overclocking in /boot/config.txt file is not working.

You can see the list of available scaling governors using next command:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors
conservative ondemand userspace powersave performance

Let do some tests.

Check the current frequency:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

The result is probably “700000”, which is default CPU frequency.

Lets make processor bussy and check its result:

for i in {1..10000} ; do set X 1; done && cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

The result is probably “700000” again.

Change the scaling governor:

su -c "echo ondemand > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor"

Check your scaling_governor:

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

The result should be

ondemand

Lets test it again:

for i in {1..10000} ; do set X 1; done && cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq

Now, the result should be “800000”.

To change scaling_governor on boot, edit /etc/rc.local file:

sudo nano /etc/rc.local

Add next line, so file looks like:

echo "ondemand" > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
exit 0

Reboot:

sudo reboot

After reboot, test if scaling_governor is set to “ondemand”:
(Note: Wait few minutes before you issue next command. There is a delay before new scaling_governor is applied.)

cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor

The result should be:

ondemand

By default, CPU threshold is set to 95.

You can check it using:

cat /sys/devices/system/cpu/cpufreq/ondemand/up_threshold
95

So, a threshold is set to 95. It means CPU speed will rise when CPU utilisation is 95%.

You can set this value to a lower percentage. It means CPU will be clocked higher when CPU utilisation is lower.
For example if you want to speed up your CPU at 60%, add next line to /etc/rc.local file.

echo 60 > /sys/devices/system/cpu/cpufreq/ondemand/up_threshold

Install Nibbleblog on Raspbian, Raspberry Pi

Nibbleblog is a powerful engine for creating blogs, all you need is PHP to work. Very simple to install and configure (only 1 step).

First, install:

sudo apt-get install php5-gd

Restart Apache and PHP-FPM to reload new configuration:

sudo /etc/init.d/apache2 restart
sudo /etc/init.d/php5-fpm restart

Download latest archive (here):

wget http://sourceforge.net/projects/nibbleblog/files/v4.0/nibbleblog-v4.0.3.zip

Create folder for your blog (*example):

sudo mkdir /var/www/blog

Extract the archive:

unzip nibbleblog-v4.0.3.zip -d /var/www/blog

Note: You can download this archive on your computer and upload files via sftp://<raspberry-pi-ip-address> if you prefer.

Set permissions on your folder:

sudo chown johndoe:www-data -R /var/www/blog
sudo chmod 775 /var/www/blog/content

OR

sudo chown www-data:www-data -R /var/www/blog
sudo chmod 755 /var/www/blog/content

Point your browser to location where files are extracted, for example:

http://<raspberry-pi-ip-address>/blog

or

http://<dynamic-dns-address>/blog

and complete the form.

Done.

Install ReadyMedia miniDLNA 1.1.4 on Raspbian

Source: Install ReadyMedia miniDLNA 1.1.4 Raspberry Pi

The latest version of ReadyMedia miniDLNA in the Raspbian repos is ancient so we are going to compile miniDLNA (now ReadyMedia) from source on Raspbian. This should fix avi problems you may have had in the past like them not showing up in the library.

Remove your old miniDLNA 1.0.24 (if they exist)

sudo apt-get purge minidlna -y
sudo apt-get remove minidlna
sudo apt-get autoremove -y

Make sure you have a source repository, default Raspbian does not include this

echo "deb-src http://archive.raspbian.org/raspbian wheezy main contrib non-free" | sudo tee -a /etc/apt/sources.list

OR:

edit /etc/apt/sources.list file:

sudo nano /etc/apt/sources.list

and add next line:

deb-src http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi

Update repositories so it will detect your new source repo

sudo apt-get update

Grab dependencies for building it from source

sudo apt-get build-dep minidlna -y

If you get any errors you can install the dependencies manually

sudo apt-get install libjpeg-dev libsqlite3-dev libexif-dev libid3tag0-dev libvorbis-dev libflac-dev -y

Download miniDLNA 1.1.4 source

wget http://sourceforge.net/projects/minidlna/files/minidlna/1.1.4/minidlna-1.1.4.tar.gz

Unpack it

tar -xvf minidlna-1.1.4.tar.gz

Enter the miniDLNA directory

cd minidlna-1.1.4

Configure, make and install miniDLNA, it will take 5 minutes.

./configure && make && sudo make install

Copy the default configuration file

sudo cp minidlna.conf /etc/

Copy the startup daemon script to autostart ReadyMedia miniDLNA on boot

sudo cp linux/minidlna.init.d.script /etc/init.d/minidlna

Make the startup script executable

sudo chmod 755 /etc/init.d/minidlna

Update rc to use the miniDLNA defaults

sudo update-rc.d minidlna defaults

Edit the configuration

sudo nano /etc/minidlna.conf

Note: Edit the following to point to your media

This version of minidlna will give you multiple folders under Video. Before movies and TV would have been under separate categories, now movies and TV will both be under the category video. It will also show the folder structure of them instead of showing just the video files. Avi files will also show up and be streamable.

inotify uses resources because it autoupdates your library, if you don’t use inotify you will have to manually restart and reload the miniDLNA service

The friendly name is how your miniDLNA server will show up to its streaming clients

media_dir=V,/mnt/usbstorage/Movies
media_dir=V,/mnt/usbstorage/TV
media_dir=A,/mnt/usbstorage/Music
media_dir=P,/mnt/usbstorage/Pictures
# Names the DLNA server
friendly_name=RasPi Media Server
# Tells the DLNA to update the library when there are changes
inotify=yes

Ctrl+X, Y and Enter to save and exit

Start the minidlna service

sudo service minidlna start

Now make sure it starts on boot

sudo reboot

Your Raspberry Pi DLNA server will now be accessible to stream media to your clients: PCs, XBOX, PS3, Phones, TVs and more.