Wednesday, May 12, 2021

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I have a hard time with heavy mice, like MX Master itself. Also, the ergonomics is a killer here.

But I was having a hard time figuring out how to pair it to my Linux machine, Windows 10 was fine. Literally spent hours trying to Google a solution down. Nothing was showing up. The official pages only provide links to Windows Driver and MacOS drivers. The user manual is more of a translation tutorial rather than something useful. Really really hard to read with such small fonts as well.

But fortunately, switching the search term turned up with a russian blog post that had instructions for it. And an undocumented (or hard to find in the documentation) feature is all I needed. So I am going to post that here in order to keep a record and hope someone else does not have the same hard time.


Things to know:

  1. The device switcher button on the mouse has a "long press" functionality. It puts the specific responder on so the device tries to connect with that.
  2. You need to install 'hcitool" from AUR
Steps:
  1. First need to find out the MAC Address of the Bluetooth device. To do that, in your terminal type

    hcitool scan
  2. With your mouse turned on, long press the device switcher button. You will see that the device number blinker slows down and blink with less frequency. This is, according to the manual, when the mouse is trying to connect to a device
  3. At this point, the hcitool command should turn up with a MAC Address
  4. Now in terminal, type
    bluetoothctl
  5. Now type
    trust <MAC Address>
  6. And type
    connect <MAC Address>
  7. At this point, your mouse should be working already






Keeping a copy of that page here for future reference:

From sunny China came a mouse for the laptop - Rapoo MT550. Excellent ergonomics, power supply from 2xAA batteries promises to be long-lasting, and the most killer feature is work simultaneously with three computers via bluetooth with a simple switch.



Under Windows 10, no problems arose - I turned it on, clicked the "bluetooth scan" on the mouse, Windows found it and that's it.

Under Linux Mint 17.3 Cinnamon - the mouse is visible, but when trying to connect, it is impossible to enter pin code "0000" for this mouse in the pop-up notification. Accordingly, the BT manager has a mouse, but it is indicated that the pairing did not occur. Probably no problem under KDE or other shells.

The solution is that you need to manually pair:

1. Install the packages:

apt-get install bluez-tools
apt-get install bluez-hcidump

The first one swears that it is "untrusted".

2. Execute, on the mouse, press the "bluetooth" button for recognition:

hcitool scan
Scanning ...
6C: 5D: 63: 77: 1D: 1E  RAPOO BT3.

3. In a new terminal window:
sudo hcidump -at
HCI sniffer - Bluetooth packet analyzer ver 2.5

device: hci0 snap_len: 1500 filter: 0xffffffffffffffff

4. We are interested in hci0, execute:
sudo bluez-simple-agent hci0 6C: 5D: 63: 77: 1D: 1E
RequestPinCode (/ org / bluez / 11002 / hci0 / dev_6C_5D_63_77_1D_1E)
Enter PIN Code: 0000
Release
New device (/ org / bluez / 11002 / hci0 / dev_6C_5D_63_77_1D_1E)

It will ask for a pincode, for MT550 - "0000"

5. Making the bluetooth mouse "trusted"
sudo bluez-test-device trusted 6C: 5D: 63: 77: 1D: 1E yes

6. We cling to the mouse:
sudo bluez-test-input connect 6C: 5D: 63: 77: 1D: 1E

You can try to move the mouse - it should be recognized. After rebooting, it was recognized automatically, and in the Bluetooth manager of Mint itself, the mouse is now indicated as paired. 

7. For MT750 / 750S, the connection instructions are the same.

UPDATE for those who have Mint 19 / Ubuntu 18.04:

Although the mouse is detected in the bluetooth manager, it still does not want to connect at point-blank range. Simple-agent and the commands associated with it no longer work
in  bluez-tools .
To connect, enter:
hcitool scan - and hold down the channel selection button (on Rapoo 750S), we see the mouse:
Scanning ...
6C: 5D: 63: 76: AA: 17  RAPOO BT3.0 MS
Next, run the utility:
sudo bluetoothctl 
Shows a bunch of devices in the area, incl. and mouse (for some reason I have different macs and BT versions):
[NEW] Device ED: 8E: 0E: 10: AA: 28 RAPOO BT4.0 MS
[NEW] Device 6C: 5D: 63: 76: AA: 17 RAPOO BT3.0 MS
Then in the console [bluetoothctl]:
help - list of commands
We need to entrust the required MAC and connect:
[RAPOO BT4.0 MS] # trust 6C: 5D: 63: 76: AA: 17
[CHG] Device 6C: 5D: 63: 76: AA: 17 Trusted: yes
Changing 6C: 5D: 63: 76: AA: 17 trust succeeded
[bluetooth] # connect 6C: 5D: 63: 76: AA: 17
Attempting to connect to 6C: 5D: 63: 76: AA: 17
[CHG] Device 6C: 5D: 63: 76: AA: 17 Connected: yes
Connection successful
I can't vouch for the trust / connect sequence - first I tried connect, then trust - the result is negative. After trust - again connect - everything came to life. 
At the time of connect,  you must also keep the channel selection on the 750S.

Saturday, July 04, 2020

Connected to Bluetooth headphones on Arch / Manjaro

I use Manjaro most of the time these days as my daily driver OS. I have tried a few others but I keep coming back to Manjaro. Recently I started using the i3 spin of Manjaro which is as far as I could understand, a community maintained edition. I had one problem with this version right away, bluetooth audio. I use a bluetooth headphone and this needed to be fixed. Thankfully it didn't take much long to find the solution.


You can find the solution here.

https://wiki.archlinux.org/index.php/Bluetooth_headset#Configuration_via_CLI:~:text=Start%20the%20bluetooth.service%20systemd%20unit.

(If you browser does not support text fragments, just go to this link and search for "Start the bluetooth.service systemd unit.")

Thursday, January 02, 2020

Unreal Tournament 2004 bugs in Linux

There are 2 specific problems that I almost always run into when I attempt to run Unreal Tournament 2004 on Linux.


  1. No soound
  2. Libstdc++

I am keeping a note of these 2 here.

For no sound, just use "padsp ./ut2004"

And for Libstdc++, try installing the library through your distro's package manager. Example: "sudo pacman -S libstdc++5" 

Saturday, May 18, 2019

Troubleshooting NetworkManager disconnecting Wifi on Start Up

So I was having this weird problem lately. Whenever I booted my Laptop and it came to the desktop, the Wifi would suddenly get disconnected. It would then stop working at all. I have had this problem before which would not be this repetitive and definitely not this much quick. Well, Manjaro Forums came to the rescue. One of the posters gave a command that turns Wifi off for the 'nmcli' command. I simply converted it into a Wifi Off and Wifi On command. Upon doing that, Wifi got fixed.

#!/bin/bash
nmcli r wifi off
nmcli r wifi on
Credits: https://forum.manjaro.org/t/solved-networkmanager-choose-when-to-enable-wifi-on-reboot/63810/4

Wednesday, May 15, 2019

Installing TP Link TLWN823N on Manjaro / Arch Linux

I will be super quick about this. I received it today and upon connecting on my Manjaro box, it showed by Wifi but with very poor signal. I suspected it could be a driver issue. So I googled and it was pretty easily available. I am doing this write up to sum up the whole process in a script.


git clone https://github.com/Tafhim/rtl8192eu-linux-driver.git
cd rtl8192eu-linux-driver
sudo dkms add .
sudo dkms install rtl8192eu/1.0
echo "blacklist rtl8xxxu" | sudo tee /etc/modprobe.d/realtek.conf
Then reboot.

Tuesday, June 26, 2018

Useful commands for the MariaDB/Mysql DB

So, today I was caught up in a problem where, I was using a migration generator in Python. I accidentally made some mistakes in one of my models, for which, the migration generator lost it's track and subsequently, was generating a duplicate column issue.

Also, another problem was the use of a non UTF-8 collation type. So, I had a pretty rough time trying to solve these things.

I will list down some of the things that I did, not in any useful order, to solve these problems.

#1 I was using SQLAlchemy with Alembic.
Here's the migration that went berserk

def upgrade(): # ### commands auto generated by Alembic - please adjust! ### op.add_column('bot_article', sa.Column('blogs_id', sa.Integer(), nullable=True)) #op.drop_constraint('bot_article_ibfk_1', 'bot_article', type_='foreignkey') op.create_foreign_key('bot_article_ibfk_1', 'bot_article', 'blogs', ['blogs_id'], ['id']) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### op.drop_constraint('bot_article_ibfk_1', 'bot_article', type_='foreignkey') # op.create_foreign_key('bot_article_ibfk_1', 'bot_article', 'blogs', ['blogs_id'], ['id']) op.drop_column('bot_article', 'blogs_id') # ### end Alembic commands ###

So, as you can see from the commands, there was a foreign key constraint for the column that I had deleted. So I had to first delete the creation process of that column. Which subsequently failed since I had to actually also remove the constraint that involved that column. But how to do that?


alter table bot_article drop foreign key bot_article_ibfk_3;

This command above removes that constraint from the table. Now I was free to use the proper column and customize my Alembic script, which is what you just saw.

#2 Fixing column collation.
My problem in this case was that had to fix the collation of a column that was using a latin collations. For this reason, I could not insert my unicode encoded strings. But how did I find out what collation was this using, or even if it was using a wrong collation?


SHOW FULL COLUMNS from bot_article;

This command, shows whatever settings you have for each column. So I had a latin collation. I had to convert it to 'utf8_general_ci'. Way to do that?

ALTER DATABASE flask_app CHARACTER SET utf8 COLLATE utf8_general_ci;

#3 Finding out what foreign key constraints are in effect in columns
This one's pretty useful. To find out everything you need to type to create a column (intact with all it's settings) you have to do the following

show create table bot_article;

#4 How to add collation using SQLAlchemy

db.Column(db.Text(collation='utf8_general_ci'), nullable=True)

It's possible that Alembic will not detect this using the migrate command, you have to manually add this in a migration file.

Monday, December 18, 2017

Change Matplotlib backend to avoid QT5 issues.

This is an issue that has been bugging me for about 5 hours. Until I reached the solution of changing the backend of Matplotlib for good.

import matplotlib
gui_env = ['TKAgg','GTKAgg','Qt4Agg','WXAgg']
for gui in gui_env:
    try:
        print "testing", gui
        matplotlib.use(gui,warn=False, force=True)
        from matplotlib import pyplot as plt
        break
    except:
        continue
print "Using:",matplotlib.get_backend()


Credits: https://stackoverflow.com/a/43015816/1928610

Tuesday, October 17, 2017

Playing around with NL Toolkit

So I was planning to play around with Natural Language a little. I have started from this page here http://www.nltk.org/book/ch01.html since it uses Python and is easily accessible.
I am going to this use this page as a log for this activity to log how I fixed certain errors and progressed through the processes. So here goes.
#1 Error: Resource gutenberg not found
Solution: I almost gave up when I finally hit this URL https://groups.google.com/forum/#!topic/nltk-users/LEGj1IHJJ1g
I used this command to fix the path to the library
nltk.data.path.append('path_to_nltk_data')

Wednesday, September 27, 2017

How to configure Wordpress to run on Docker

Well, it's not a big deal. You need two (2) things.
#1. This Nginx config
server {
    listen 80;
    server_name wp-hakase.co;
 
    root /var/www/html;
    index index.php;
 
    access_log /var/log/nginx/hakase-access.log;
    error_log /var/log/nginx/hakase-error.log;
 
    location / {
        try_files $uri $uri/ /index.php?$args;
    }
 
    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass wordpress:9000;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    }
}
#2 You have to make sure your PHP instance (docker) has mysqli installed (or installing via DockerFile) everytime.

Credits: https://www.howtoforge.com/tutorial/dockerizing-wordpress-with-nginx-and-php-fpm/
https://forums.docker.com/t/status-code-500-wordpress/36581

Sunday, November 27, 2016

Display switcher for terminal buffs

I am not a Linux developer or anything, I just love writing scripts that facilitate in making me lazy. So here's one that lets me switch my displays (dual). I usually work on only one and when I need to quickly switch, I use this. It depends on xrandr though. And it has my display names hardcoded (lots of assumptions, I know), but it might just come in handy.
Switch to left or right
./reset_display.sh left
./reset_display.sh right
Set both on with duplicate view
./reset_display.sh
Set both on their individual view
./reset_display.sh both

You can simlink it /usr/local/bin too.
Github gist

Sunday, November 06, 2016

Getting file list from torrent magnet URLs using Aria2

So, I hit upon this realy awesome SO reply on how to fetch the torrent file list using magnet URLs. I use Aria2 for torrents and it's be design that you cannot get any meta data from Magnet URLs because they do not hold any information off the link. They fetch the meta data when you use them. So, what you have to do is, generate a torrent file from them and then use THAT torrent file for listing. So it's a 2 step process.

First you create the torrent file using:
aria2c --bt-metadata-only=true --bt-save-metadata=true -q "magnet url here"
It will generate a torrent file right there with a name that is a hash just use that to get the file list.

Credits: http://unix.stackexchange.com/a/134286/52595

Saturday, October 08, 2016

Replacing Apache in your VPS with Nginx

If you have not been following the web development scene recently, you need to know that Apache is being seriously challenged by Nginx in the ideal server candidate position. Nginx is a great server daemon that also uses much less resources. Recently I attempted to make a move to Nginx from Apache. But there were some issues that needed to be addressed.

Well, setting up Nginx is really straightforward, just run
# apt-get install nginx
But you might face problems with starting the nginx service. Well, the most likely reason probably is that by default Nginx is configured to run on Port 80. In computers one port cannot be used by multiple programs at the same time. But Apache too is configured to listen on port 80. Now, if you want to move to Nginx and serve all your sites via Nginx, you can unassign Apache from port and give Nginx the instruction to listen to port 80. To do that you will need to tweak an apache configuration file. This may be different for different distros and scenarios but the most common place to look for the Apache configuration files is
/etc/apache2
or
/etc/httpd
Now usually the configuration can be found in
/etc/apache2/apache2.conf
or
/etc/httpd/httpd.conf
Just open your appropriate configuration file and try to find the the line:
Listen 80
If you can't find the line it's very much possible that the port instruction is in different file. Just read through the configuration and try to find if any "Include" directive. It could be like
Include "ports.conf"
Which means the port Listen directive is there. Open the file (you should be able to find that in the same directory).
Now change "Listen 80" to "Listen 1234". This will make Apache listen to port 1234.
Now you should restart Apache with
#servicectl restart apache2
And start nginx with
#servicectl restart nginx

Monday, October 03, 2016

Wordpress to survive the most difficult hurdle

A legend in the making. Wordpress, as popular as it is among content writers, it is also one of the most cubersome platforms to deploy on. And when it comes to merging more than one wordpress sites, the biggest hurdle is the Database. Well, VersionPress is coming to the rescue.

What VersionPress (VP) attempts to do is make the whole Wordpress installation version controllable. Now, it's one thing when you are merging files but it's completely different monster when you want to take on the Database. Sure, merging 2 DB dumps cannot be an issue for git but what about context?

Imagine this scenario where you have developers making your site look and work awesome and content writers writing away on live production server. Now the day comes when you have to pull the changes from the development version to the production. Well several things get intertwined here
  • Posts having same IDs
  • Plugins having custom tables
  • Options and Meta
Now that's a real spaghetti you got there. When you think about it, you feel like nothing short of a magic is going to be needed for that right? Well, if that's so, VersionPress is magic. Here's how they are supporting plugins in their new alpha. If you are late to the show, you might want to read their past release notes too.
https://github.com/versionpress/versionpress/blob/1036-plugin-support/docs/Plugin-Support.md

Tuesday, September 27, 2016

Cracking guide

I recently found this guide somewhere on the internet and thought it was an interesting read. Just storing for reference.

https://docs.google.com/document/d/1qRdWYx25yyteX8DQF_LIciT5VZ1_1RnT2ar7w5YP_40/edit?usp=sharing

Saturday, August 06, 2016

Solving GPU nvidia Optimus issues on Linux

I have gone through painstakingly complex processes to solve this issue time after time and today I just decided to record my approach for this time. I understand that one approach almost never works twice for this issue in particular. So I am just going to add links and references that help me solve this problem.


First of all, my approach is based on Bumblebee and nothing beats this when it comes to Arch or Arch based.
https://wiki.archlinux.org/index.php/bumblebee
Then to solve any optimus related issue, https://github.com/Bumblebee-Project/Bumblebee/wiki/Troubleshooting
And finally for primus run
https://wiki.archlinux.org/index.php/bumblebee#Primusrun

Wednesday, July 06, 2016

Fixing assets broken by Google reCaptcha

Well this does not fix the page fully but it make it workable. Follow the steps.
Open fiverr.com, and click "inspect element". Go to "Console".
Then click on an asset (js/css) that has 403.
Now right click on it and click "open in new tab"
Enter the reCaptcha, you'll see the asset file now
Now repeat this for the assets that got 403
Now you got your page partially fixed, you might find some more JS missing, just go to console and fix that using the same way.

Tuesday, July 14, 2015

Connecting via Remote host using postgresql

When the instance of postgres is inside vm and you are on the host machine with some stack such as Node, the scenario becomes as if connecting from a remote host. To make it possible, we have to make postgres listen to remote (all) hosts and also specify the IP of that host.
1. To add the ip to the allowed host list, edit /etc/postgresql/9.1/main/pg_hba.conf and add the lines
host all all 192.168.0.1/24 md5
where 192.168.0.1 is the IP of the host you want to connect from.
2. And to enable listening from remote hosts, edit the file /etc/postgresql/9.1/main/postgresql.conf and add the following line
listen_addresses = '*'
Credits http://www.thegeekstuff.com/2014/02/enable-remote-postgresql-connection/

Setting up Node with NVM

I always keep facing problems with Node. It just keeps pushing me around with it's numerous errors. So, lately I found out about NVM and tried it. Still had an issue with it. But finally got it up and running. Here are some important things to keep note of when attempting to install node using NVM.
1. The default installation directory of the NVM installer (provided in the repo readme) is ~/.nvm. I find this a bit problematic so I actually just clone the repo into /opt/nvm since I kind of stick to sudoing things when they need to be global for node and ~/.nvm isn't owned by root, I kind of like to keep it that way.
2. Now setting up the envvars is done using profile.d/nvm.sh. This could also be done using ~/.zshrc or ~/.zprofile but I like it this way. In whatever case the envvar setup script is like this
export NVM_DIR=/usr/local/nvm
source /opt/nvm/nvm.sh

export NPM_CONFIG_PREFIX=/usr/local/node
export PATH="/usr/local/node/bin:$PATH"
3. So it's basically done (setting up NVM, not node) but since to install anything via nvm I'll need sudo so I must (at least) source the /etc/profile.d/nvm.sh into root. So I just do
$ sudo su
# source /etc/profile.d/nvm.sh
4. Now for the installation of a node version
# nvm install 0.12
# nvm ls
The last one should be done from root because it creates a particular directory that $ can't create.
5. Now we can simply execute
$ nvm use 0.12

Credits:
http://stackoverflow.com/questions/11542846/nvm-node-js-recommended-install-for-all-users
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps
Found a nice article here: http://www.liquidweb.com/kb/how-to-install-node-js-via-nvm-node-version-manager-on-ubuntu-14-04-lts/

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...