Tuesday, May 8, 2012

Setting brightness at Ubuntu startup



In Ubuthu machines such as Thinkpad T520 every-time when we restart the computer the brightness level will be at its maximum and then we need to manually set the brightness to a comfortable level.

To solve this issue here I share a small script I have written.

First install xdotool
sudo apt-get install xdotool
This will allow you to change the brightness easily from the command line with out admin privileges.


Check whether the brightness is changing with the following command
xdotool key XF86MonBrightnessDown

Now we have to find the file where the brightness value is stored, try doing
cat /sys/class/backlight/acpi_video0/brightness
If you get an integer value then your good to proceed, else you have to find the appropriate file in your system. In that case check in /sys/class/


Adjust the brightness and find your desired brightness level using the above command E.g. 9


In this example I have used 9 as my brightness level change it according to you.

 
#!/bin/bash

myBrightness=9;
currentBrightness=`cat /sys/class/backlight/acpi_video0/brightness`;
count=$(( $currentBrightness - $myBrightness )) ;
while [ $count -gt 0 ]
do
     xdotool key XF86MonBrightnessDown
     let  count=$(($count-1));
done
Save this as brightness.sh


Then make this file to be an executable, by running
chmod +x brightness.sh

Finally open the "Startup Applications" click Add and add the following


Name :<appropriate name>
Command:/<path to file from root>/brightness.sh
Comment:<appropriate comment>

How to install Java Cryptography Extension (JCE) unlimited strength jurisdiction policy files


How to over come "org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size or default parameters" or "java.security.InvalidKeyException:illegal Key Size" error when invoking secured services

These "org.apache.xml.security.encryption.XMLEncryptionException: Illegal key size or default parameters" or "java.security.InvalidKeyException:illegal Key Size" error usually occurs when we try to invoke a web services in a secured manner and your JVM is not provisioned for Java unlimited security jurisdiction.


To provision for the Java unlimited security jurisdiction we have to install Java Cryptography Extension (JCE) unlimited strength jurisdiction policy files.


How to Install JCE

  1. Go to the Oracle Java SE download page http://www.oracle.com/technetwork/java/javase/downloads/index.html
  2. Scroll down ... Under "Additional Resources" section you will find "Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy File"
  3. Download the version that matches your installed JVM E.g. UnlimitedJCEPolicyJDK7.zip
  4. Unzip the downloaded zip 
  5. Copy local_policy.jar and US_export_policy.jar to the $JAVA_HOME/jre/lib/security (Note: these jars will be already there so you have to overwrite them)
  6. Then restart your application to get rid of this exception.

Sunday, April 29, 2012

Change the default Java installation used by Ubuntu


Though you have installed and using a particular Java installation (E.g. Oracle Java 7), sometimes when you install some other softwares they might change the default to other Java installations (E.g. OpenJDK)

In such situations to change the default version, run the following commands and chose the appropriate selection when prompted.

For Java :
update-alternatives --config java
For Java compiler :
update-alternatives --config javac
For Java web start :
update-alternatives --config javaws

How to instal Java in Ubuntu

Now, Java is installed and we need to set the JAVA_HOME.
Visit How to set JAVA_HOME in Ubuntu post to get to know how you can appropriately set JAVA_HOME and PATH.

Saturday, April 28, 2012

Apache MeetUp held in Hill Country




The students of University of Peradeniya did a great job organizing an amazing Apache meet up at Kandy, Sri Lanka. This was the second major event in Sri Lanka next to the Apache Bar Camp Colombo that was held this year.

Here the first talk was on "FOSS in Kandy" by Dr. Nimal Rathnayaka, followed by Dr. Srinath Perera explaining "The Apache Way" of managing projects, how the communities work together and how they resolve conflicts using the voting system with the -1 veto. 

After the introduction of open source and Apache, Nandika Jayawardrdana gave an inspiring speech on "Open source and your career" giving out some valuable informations to the audience how one can use open source to become much better at his career. Here he explained how open source can improve your communication skills, writing skills - where you have to convince and argue on your ideas via the mailing list, and how your participation on open source makes you famous - which indeed will be eye catching even at the selection phase for a grad school, and most importantly he also expressed how we get a self satisfaction when so many people are using the product that you have build. This also falls according to the famous saying "A project without users (means, it) does not exist".  

Following this, Sagara Gunathunga gave a good briefing on how you can "Find your way to Apache Contribution", Here he not only stressed on coding but also mentions some other great ways of contributing, like writing technical blogs on the project, helping with documentation and testing the project. He continued explaining how these are extremely valuable to do when you are a newbie and gain recognition from your project community. 

After lunch, we had two practical sessions, the first one is on how to configure and use Apache Web Server in an efficient manner - by Anuradha Ratnaweera, and the second was on "Apache build projects" - by Prabath Abeysekara and myself, where we demonstrated Apache Subversion, Maven and Ant. 

Finally the session was concluded with Pradeeban's lighting talk on how to build a community for your project.