Friday, August 29, 2014

Another Useful Script - Better Brightness

Hello All! I know it hasnt been all that long since I last posted but I have another addition to my useful Linux scripts, randoScripts. Here is the previous post regarding this repo: linky! This script is particularly useful on Debian based laptops. If you have one in your possession I am sure that you have noticed that a fresh boot of the system blasts the screen brightness to the max. This script makes it so the brightness is set to a lower value on boot using the rc.local  script.

rc.local Is a script that by default does nothing and is executed last of all the startup scripts. Our plan is to edit this script to lower the screen brightness.


Step 1

All of my scripts are on Github:
$git clone

The first thing to do is figure out what brightness value works for you. So in order to accomplish this set your display using your function keys or under Brightness & Lock in your settings menu.

Once you have found the desired setting run this command:
$cat /sys/class/backlight/acpi_video0/brightness


If you finish this tutorial and it didnt work for you, you may need to use


instead. For me both worked just fine, however different values were used.

Anyway, the cat command should spit out a number. The number varies depending on your display. Mine happened to be 34 so I will use that in my examples.

If you would like to practice with values via terminal before settling use this:
$echo VALUE | tee /sys/class/backlight/acpi_video0/brightness
Where VALUE is the number you want to use.

Step 2 

 Go ahead and open up the rc.local file and place the value you want in the location of VALUE_HERE. The script should now look like this:
#!/bin/sh -e
# rc.local
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
# In order to enable or disable this script just change the execution
# bits.
# By default this script does nothing.

sleep 1
echo 34 > /sys/class/backlight/acpi_video0/brightness

exit 0

The sleep is somewhat important in this case by waiting until the OS is completely loaded before changing the values.

Step 3

Next move the script into the proper location if you didn’t edit your own.
$sudo mv rc.local /etc
And to enable it we have to make it executable
$sudo chmod +x /etc/rc.local


After a reboot you should now see that your screen will start at your desired value. I am considering editing the script to remember the last screen value. Not sure if its worth it.


I would really like to keep this repo going with many useful scripts. They show the real power of the Linux OS and your control over it.

Would an automated installer be a nice feature to have? Giving the user choices of scripts they may like to have.
Let me know in the comments.

**The customary for those who care
   Ubuntu 14.04, rc.local

Monday, August 18, 2014

Useful Linux scripts

Hey All! I know I havent been around of recently due to an extremely busy life. However here I am once again with something more useful for everyone! My new item on the table is a collection of Linux scripts (mostly bash) that I use everyday. Some of the collection include trim support, Google Drive, and xbind. So lets start!!!

First!!! All of these scripts can be found on Github. Linky

$git clone


If anyone owns a solid-state drive (SSD) trim support is a basic requirement. The basic issue is that an SSD can write pages of memory but only delete blocks. Blocks of memory consist of many pages. i.e. (page << block) For a much more detailed explanation read here. However as of this moment Linux does not support trim automatically, but it is easily added to cron tasks. In case you are a Linux n00b cron tasks are located the system and are executed on a regular basis.
Your choices of cron are:
  • Hourly
  • Daily
  • Weekly
The script will execute whenever the system is free and calls cron. Now for fstrim I personally call this weekly, monthly might even be a better option. As soon as trim is run your files are permanently removed, this means you will NOT be able to recover anything that has been trimed. All that is required of the user is to copy the script into the correct cron folder.

$sudo cp trim /etc/cron.weekly/
BOOM! complete :) If you would like proof that is executes a log is created:
$cat /var/log/fstrim.log
 IMPORTANT!!!: Read if you are using an LVM partition under EXT4.

Google Drive (grive)

As a Linux user you may know that Google has failed to provide a native drive client for us. This means you cant keep files synchronized on your drive and computer without doing so manually. Fortunately the group at The Fan Club saw the issue and provided us with grive. Grive is a 3rd party sync tool specifically for Linux. Despite how awesome this application is, it is missing an automatic synchronize. For this very reason I decided to create a cron bash script to take care of that, hence syncGrive. This script is capable of handling multiple accounts as long as they are under a single directory.

This script uses the power of the grive application by The Fan Club. To add it:
$sudo apt-add-repository

$sudo apt-get update && sudo apt-get install grive
After the application is installed copy my srcipt to cron.
$sudo cp trim /etc/cron.hourly/
I personally run this hourly do to my extreme use of Google Drive, but choose what works for you the best. 

  1. The script assumes the directory is "~/grive"
    1. If not change the directory in line 3
  2. By default grive does not delete removed files from the directory, however the script does. (
    1. To remove this comment: line 9:: rm -r .trash >> $LOG 
BOOM! complete AGAIN! :) If you would like proof that is executes a log is created:
$cat /var/log/syncGrive.log


xbindkeys is a part of xautomation that allows you to re-purpose  extra buttons on your mouse or keyboard in Linux. I see no real reason to cover this again in this exact same blog. Here is the link to the previous write-up. Linky