Category Archives: Linux

Linux Tips & Tutos.

Sony Xperia Z3 Tethering Error after Update to Android 6.0.1

Once you update your Sony Xperia Z3 to Android 6.0.1, Tethering might break.


It has to do with something related to Operator APN and DNS resolution. The update forces APN resolution to succeed before activation. It’s amongts new tactics of Telecom operators tyranny. Anyway:

  • Enable Development mode on your Smartphone (CGo to Settings -> Phone Details -> Click several times on Build Number)
  • On your Ubuntu 16.04, install Android SKD along with ADB and fastboot (sudo apt install android-tools-adb android-tools-fastboot -y) (ref:
  • Start an adb shell by typing the following command: adb shell
  • At the adb shell prompt, run this command: settings put global tether_dun_required 0
  • hanine @col in /opt/android-studio/bin (13 entries, 0 hidden)
    7 2005 $ adb shell
    shell@D6603:/ $ settings put global tether_dun_required 0
    shell@D6603:/ $ exit
  • Type exit, then disconnect your phone and reboot

Huawei E3531s-2 on Ubuntu 14.04

The BroadBand modem Huawei E3531s-2 on Ubuntu 14.04 does not work out of the box.

Let’s make it work.

  • – Install supervisor:

sudo apt-get install supervisor -y

  • Add a supervisor configuration to a new program: A script we’ell shortly create, In /etc/supervisor/conf.d/broadband.conf


  • Write a script in /usr/bin/broadband and make it executable.

# Script to enable Mobile Broadband
# Author: (
# Huawei E3531s-2
isBUP=$(nmcli con status | grep -i "${localcon}")
if [ -z "${isBUP}" ];then
echo "Broadband Connection Status is void: ${isBUP}"
nmcli nm wwan on;
sleep 1;
nmcli nm wwan off;
sleep 1;
if [ -n "${isBUP}" ];then
echo "Switching Off connection to ${localcon}"
nmcli con down id "${localcon}";
sleep 1;
echo "Trying to Connect to $localcon"
nmcli con up id "${localcon}";
if [ "$?" -eq 0  ]; then
echo "Connection Established."
sleep 1
#exit 0;

while true; do
if [ -n "$(lsusb | grep '12d1:15ce')" ]; then
# This will switch to modem mode : 12d1:15b1
sudo usb_modeswitch -v 12d1 -p 15ce -M '55534243123456780000000000000011062000000100000000000000000000'
echo "Activating modem, please wait ${WAIT} seconds."
notify-send -u normal -a broadband "Connecting Broadband" "Modem $(lsusb | grep -i huawei). \nPlease wait 25 seconds"
sleep $WAIT
isModem=$(lsusb | grep -iE '12d1:15b1|modem on')
if [ -n "${isModem}" ]; then
eval connector

  • Change ‘localcon=”Meditel2″‘ to the name of your BroadBand Connection (You should have already configured it using Network Manager Applet)
  • Restart Supervisor.
sudo service supervisor restart

Now everytime, you plug the broadband device, it will get connected through the BroadBand connection configuration you already set up. In our case it’s called “Meditel2”.

Please note that once you plug the device, you have to wait 30 seconds before the connection is established.

Persist your screen brightness settings in Linux

If you like me have a machine running Linux OS and want to be able to persist your screen’s brightness setting, here is a small script that does the trick. (I don’t know if that feature lacks only in Ubuntu running in a Dell XPS 15 l502x or common to all Linux laptops)

Initially the problem is that once you reboot the machine, you lose the brightness setting and you have to manually adjust again. Annoying!

With the following instructions, you’ll be able to fix that. Tested in Ubuntu 13.10.

Copy these following three scripts in your Desktop folder (Or in the same folder) and give them execution permission:

RESET script (

# Author: Hanine HAMZIOUI ALMADANY <>
# This script sets the brightness in Ubuntu as it is not persistent upon reboot

# In order to manually execute these commands below, the user must be root

# Brightness values are integers that range from 0 to 15

if [ -f $CUSTOMBRIGHTNESS ];then echo $(cat $CUSTOMBRIGHTNESS) > /sys/class/backlight/acpi_video0/brightness
else echo $DEFAULT_BRIGHTNESS > /sys/class/backlight/acpi_video0/brightness
exit 0

Brightness RUN (


# Persist Brightness value in Ubuntu 13.10
# Author Hanine HAMZIOUI ALMADANY <>

if [ -f "" ]; then
sudo cp -v /etc/init.d/ && sudo chmod +x /etc/init.d/
else echo "brightness-reset file does not exist, it must be in the same folder. Terminating..."; exit 0;

if [ -f "" ]; then
sudo cp -v /etc/init.d/ && sudo chmod +x /etc/init.d/
else echo "brightness-save file does not exist, it must be in the same folder. Terminating..."; exit 0;

sudo ln -s /etc/init.d/ /etc/rc0.d/K10brightness-save # Brightness SAVE Symbolic link to RC 0
sudo ln -s /etc/init.d/ /etc/rc6.d/K10brightness-save # Brightness SAVE Symbolic link to RC 6

rawfile=`cat /etc/rc.local | grep "/etc/init.d/"`
if [ -z "$rawfile" ]; then
sudo sed -e 's/exit 0//g' -i /etc/rc.local
sudo echo "#Reset screeen brightness" >> /etc/rc.local
sudo echo "/etc/init.d/" >> /etc/rc.local
sudo echo "exit 0" >> /etc/rc.local
else echo "RC.LOCAL file is already customized to reset brightness at startup...If you think otherwise, do it manually again!"

exit 0;



# Author: Hanine HAMZIOUI ALMADANY <>
# Target: Ubuntu 13.10 and below
# Script that saves the last brightness value used

mkdir -p $(dirname $CUSTOMBRIGHTNESS)
cat /sys/class/backlight/acpi_video0/brightness > $CUSTOMBRIGHTNESS
exit 0;


chmod +x ~/Desktop/brightness-*

And finally; from your terminal again:

bash ~/Desktop/

You will be prompted for your user password.

Now adjust brightness ti a certain value and reboot. 😉

QT Application with Java. Possible? Yes QT Jambi does it.

If you’ve never heard about it, you can build rich cross-platform GUIs with Qt Jambi., while coding in Java. What?
Yes, QT Jambi is a QT Binding to Java, allowing you to develop QT GUI using Java instead of C++.
It practically is the same thing as Java-Gnome library which is a GTK+ binding.

QT Jambi is still maintained as opposite to rumors. And the last snapshot was build on 11 November 2012.
If you want to give it a shot, the following is a ‘get started’ tuto:


  • OS: Ubuntu 12.10 AMD64
  • Desktop: Unity
  • IDE 1: Netbeans 7.3
  • JDK: Oracle JDK 1.7.u10
  • IDE 2: Eclipse Juno

First, install Qt Jambi from its PPA:

sudo add-apt-repository ppa:qtjambi-community/libqtjambi-snapshots && sudo apt-get update && sudo apt-get install --install-suggests libqtjambi-snapshot qtjambi-examples-snapshot qtjambi-designer-snapshot ant-qtjambi-snapshot libqtjambi-redist-snapshot

Then, use this script, to tell your JDK where to find corresponding QT libraries used by QT Jambi:


#| Title: CopyJambi
#| Author: Hanine HAMZIOUI
#| Contact: <>
#| Date:  Sat 15 Dec 2012 03:57:00 AM WET
#| License: GNU GPL v3+
#| Description: Create symlinks to QT libs in default JDK for Jambi.
#| Version: 1.0
#| Environment: Netbeans 7.3 on Ubuntu 12.10 AMD64
#| Compliance: bash, zsh, ksh, dash, sh

# sudo add-apt-repository ppa:qtjambi-community/libqtjambi-snapshots
# sudo apt-get update
#sudo apt-get install --install-suggests libqtjambi-snapshot qtjambi-examples-snapshot qtjambi-designer-snapshot ant-qtjambi-snapshot libqtjambi-redist-snapshot

# Pick the JDK path
if [ -n "${JAVA_HOME}" ]; then jdk=${JAVA_HOME}
    if [ -d "/usr/lib/jvm/default-java" ]; then jdk=/usr/lib/jvm/default-java
    else whiptail --msgbox "No JAVA_HOME was found. Script will abort." "$LINES" "$COLUMNS"; exit 0

# Two Temporary files that receive names of libraries to be copied

# Get the names of libraries to be copied
ls /usr/lib/x86_64-linux-gnu/ | grep libQt | sed -e '/.prl$/g' -e '/.a$/g' -e '/[0-9].[0-9]$/g' | perl -ne 's/^$//g || print' > ${tmp1}
ls /usr/lib/x86_64-linux-gnu/ | tr '[:upper:]' '[:lower:]' | grep libqt | sed -e '/.prl$/g' -e '/.a$/g' -e '/[0-9].[0-9]$/g' | perl -ne 's/^$//g || print' >> ${tmp1}
ls /usr/lib/jni |  tr '[:upper:]' '[:lower:]' | grep trolltech > ${tmp2}
ls /usr/lib/jni |  tr '[:upper:]' '[:lower:]' | grep jambi >> ${tmp2}

# Create symbolic links to QT libraries
while read line; do
sudo ln -v -s /usr/lib/x86_64-linux-gnu/${line} /usr/lib/${line}
sudo ln -v -s /usr/lib/x86_64-linux-gnu/${line} ${jdk}/jre/lib/amd64/${line}
done < ${tmp1}
echo "Copied ${count} QT libraries Symbolic links"

# Create symbolic links to Jambi Libraries
while read inline; do
sudo ln -v -s /usr/lib/jni/${inline} ${jdk}/jre/lib/amd64/${inline}
sudo ln -s -v /usr/lib/jni/${inline} /usr/lib/${inline}
done < ${tmp2}
echo "Copied ${i} Jambi QT libraries Symbolic links"

# Remove temporary files
if [ -f ${tmp1} ] || [ -f ${tmp2} ]
    then rm -v ${tmp1}; rm -v ${tmp2}

# Make sure the user system is amd64
arch=$(uname -i)
if [ "${arch}" = "x86_64" ]; then eval OPERATION
else whiptail --msgbox "Your system architecture is not AMD64. Script will not continue. Abort." "$LINES" "$COLUMNS"
exit 0

The above script will create symbolic links in your JDK path. If you want you can copy the libraries instead of just symlinking them.

Next step is to create a Java Project in Netbeans and import Qt Jambi library in classpath as well as QT Jambi Demos library. (You’ll find them in /usr/share/java/)


Here is a screenshot of a demo example :


You can test with a simpler example (Hello World):

package jambi;

import com.trolltech.qt.gui.*;

public class HellowWorld {

public static void main(String args[]) {
QPushButton hello = new QPushButton("Hello World!");
hello.resize(120, 40);
hello.setWindowTitle("Hello World");;


When running a QT Jambi java file, you might encounter this error :
# A fatal error has been detected by the Java Runtime Environment:
# SIGSEGV (0xb) at pc=0x00007f6b95e362ba, pid=10602, tid=140100171314944
# JRE version: 7.0_10-b18
# Java VM: Java HotSpot(TM) 64-Bit Server VM (23.6-b04 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [] QWidgetPrivate::deleteTLSysExtra()+0x3a
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
# An error report file with more information is saved as:
# /home/hanine/Workspace/test/jambi/hs_err_pid10602.log
# If you would like to submit a bug report, please visit:

Yet, entering : ulimit -c unlimited does not help at all. It sounds like an old bug related to Java HotSpot, where a zip file is read and modified in the same time. In other situations this bug is overriden using -Xmx option (e.g. -Xmx2900m : Maximum Memory : 2.9 GB )
E.G: java -Xmx:1864m -Xms:1864m myapp.jar sets minimum & maximum java memory heaps to 1864 MB for myapp.jar.
So, it appears that in almost all cases, a java file with the following statements will produce this error:

 public static void main(String args[]) {

        Wiggly d = new Wiggly(null);;


So to get rid of this error, change the code to look like this instead (Still investigating on the root problem though):

 public static void main(String args[]) {
        new Wiggly(null).show();


Running your Qt Application from terminal

When you clean and build with Netbeans, you’d get a Jar File in your project workspace, in a folder named dist.
Make this jar file executable : chmod +x /path/to/this/jar/file.jar
and run it from terminal: java -jar /path/to/this/jar/file.jar

Qt Application executed as a JAR file.

Qt Application executed as a JAR file.

Eclipse Juno IDE

You can achieve the same thing using Eclipse if it’s your preferred IDE. Just make sure you install qt-jambi from Launchpad PPA and run the above script:

  • – Use the script from above or just download it from here : QtJambiCopierSCript
  • – Save it in your Desktop and run : bash ~/Desktop/
  • – Follow instructions if any.
  • – Open Eclipse Juno, Create a Java Project and add external libraries from /usr/share/java/
  • – Adding the qtjambi.jar and qtjambi-examples.jar does the job.


GUI Designer

Unlike Java-Gnome binding library which does not yet integrate with GUI designer GLADE, Qt Jambi integrates with QT Designer.
If you followed instructions above, go to your Terminal and type:


bash /usr/bin/

This will launch QT Jambi Designer. Henceforth, you can start designing visually your GUI. Once finished, save the work as a "*.jui" file, which you would reuse as your Application UI.
Normally, Qt Designer produces a file with "*.ui" extension; but QT Jambi team has modified the thing with custom modifications that allow better integration and generation of UI java files.
We will cover this later in this same post.
Thanks for reading.
N.B: Qt Jambi Community website is down since yesterday (14th December).
You can browse other useful resources that will get you accustomed to QT Jambi quickly: QT JAMBI RESOURCES

Take a screenshot while a menu is activated in Ubuntu

If you’re running Ubuntu and want to take a screenshot using the gnome-screenshot utility, you would notice that when you press the PRINT SCREEN keyboard key while a panel or launcher menu is activated, the screen shooter does not get executed. This is a known bug due to some old Xorg issue:

Meanwhile, You can work around it by adding a delay before it gets executed. During this delay, you activate the menu you want to include in the screenshot.
Think about a more advanced screenshot utility which is SHUTTER (sudo apt-get install shutter).

Here is a comfortable solution:

1- Install Kazam
2- Install VLC media player in order to use the cvlc dummy interface command.
3- Install dconf-editor or CompizManager in order to bind the keyboard PRINT key to a custom command.
4- Create a script that will run Kazam with a custom delay if installed.

Copy/Paste the following code in a text file, and save it into your home directory and name it:


# This script runs shutter screenshooter if installed instead of gnome-screenshot


if [ -z ${arg} ]
    then delay=3
    else delay=${arg}

if [ -f "${shutterbin}" ] 
        if [ -f "${cvlcbin}" ]
            then shutter -f -d ${delay} & sleep ${delay} && cvlc --play-and-exit ${sound}
            else shutter -f -d ${delay}
    else gnome-screenshot
exit 0

Workspace 1_001
Then, go to CompizConfig in Gnome_Compatibility/Commands and bind the PRINT command to this command:
bash ~/ 3
This means, when you press the PRINT key, Kazam or gnome-screenshot will be launched within a delay of 3 seconds, the necessary time for you to activate the menu you want to printed in the screenshot.
CVLC was used just to play the camera sound the screenshot is taken. You can get rid of it if you want by modifying the script if you don’t want to install VLC.

The following is a screencast demonstarting this post.

If you have any questions or any better solutions, please post a comment.