15 April, 2014

Gaussian Blur Lock Screen - i3lock


Since, I've switched to Awesome WM, I've been meaning to find a way to lock my X session.

What I want

I have an HTC One running ParanoidAndroid and one of my favorite features is the ability to set your lock screen wallpaper as a blurred see-through view of the underlying screen: this is exactly what I wanted to emulate.

What I needed

  1. i3lock
  2. scrot
  3. imagemagick
  4. xautolock

All four of these can be installed on Ubuntu through apt-get via

sudo apt-get install i3lock scrot imagemagick xautolock

How I did it

The way I approached this is by using scrot to take a screenshot, then use imagemagick to apply a Gaussian blur, finally run i3lock using the modified image as the background.

Create a new file /bin/lock (you'll need sudo to write) that contains

scrot /tmp/screenshot.png
convert /tmp/screenshot.png -blur 0x5 /tmp/screenshotblur.png
i3lock -i /tmp/screenshotblur.png

The first line takes a screenshot. The second line applies a Gaussian blur, the parameter is bias x radius, this what I liked but feel free to change it (note: the larger the radius, the longer it will take to process). The third line actually activates the lock screen.

Save the file and mark it as executable

sudo chmod +x /bin/lock

You can now run lock from bash to activate your brand new lock screen!


This is great, but it's useless unless our computer locks after inactivity. For this, I used xautolock that does just that. Add the following line wherever you keep your startup scripts (rc.lua, .bashrc, .xsessionrc, etc...)

xautolock -time 10 -locker lock

The first parameter denotes how long to wait, in minutes, before showing the lock screen and can range from 1 to 60. The second parameter is what to run, which should obviously be our new executable.

That's it

Looks pretty awesome huh?

Some further notes: i3lock has some other parameters you might want mess around with, check man i3lock

14 March, 2014

Awesome - An awesome window manager

My Setup

Window managers are arguably the most important program on your computer, yet they are widely unthought of by end-users. This is most likely because operating systems like Windows and OSX don't give you the freedom to switch, but in Linux: its an entirely different playing field. Although you can be very happy with the window manager that comes out of the box (for many its Unity, KDE, GNOME), there are also a myriad of highly-custimizeable alternative window mangers.

I am big fan of productivity and efficiency, so I decided I would try out a tiling window manager (as compared to conventional stacking managers), where all the windows are tiled across your screen; therefore, always using your entire screen real estate. Among the most common tiled window managers are i3, awesome, and xmonad. Although they all seem really cool and have their own advantages, I decided to go with awesome because it's a dynamic tiling manager that can be configured using lua.

Installing Awesome

Installing awesome was fairly painless, as it can be installed with

sudo apt-get install awesome

I also recommend that you install the extras as they include more options for customization (such as widget mangers) via

sudo apt-get install awesome-extra

I had an issue in which awesome wasn't being shown as an option on login, which can be fixed by editing /usr/share/xsessions/awesome.desktop and changing NoDisplay=true to NoDisplay=false

Getting into Awesome

Once you've installed and modified the xsession file, getting into awesome is a matter of logging out and selecting awesome at the login screen.

Picking awesome

Basic Commands

By default, all shortcuts in awesome are based on the Mod4 key, which is the GUI key your keyboard (usually the windows key). Some of the most common shortcuts are below

Mod4 + Enter - Start a new terminal Mod4 + r - Run a program (open up run prompt on your toolbar Mod4 + j - Switch to next window Mod4 + k - Switch to previous window Mod4 + Shift + j - Swap window with next window Mod4 + Shift + k - Swap window with previous window Mod4 + m - Maximize current window Mod4 + n - Minimize current window Mod4 + f - Toggle fullscreen behavior of current window Mod4 + Ctrl + Space - Toggle floating behavior of current window Mod4 + arrow keys - Switch to different tags (essentially workspaces) Mod4 + number - Switch to the nth tag

You can read more about awesome tags by running man awesome

Customizing Awesome

One of the awesome's most awesome features (sorry, I had too :D) is the fact that it can customized through Lua.

Begin by copying the default customization into your home directory

mkdir -p ~/.config/awesome
cp /etc/xdg/awesome/rc.lua ~/.config/awesome/

The default file is a great starting place and is very well commented, you should spend some time familiarizing yourself with it!

I recommend you read the Awesome's wiki's page on starting out as it provides examples on how to do basic customization such as changing the names of your tags, changing your background, and creating basic widgets.

Volume Buttons Not Working

There were two quirks that I had to deal when I switched to awesome. The first is that my volume buttons did not work out of the box. The way I solved this was by installing volumeicon

sudo apt-get install volumeicon

When you run volumeicon, it adds a volume icon to your toolbar and configures your volume buttons to work.

In order for it to run in the background whenever you login then create a file named .xsessionrc on your home folder and input the following

volumeicon &

We also need to ensure that the file has execute permissions

chmod u+x ~/.xsessionrc

Mapping Caps Lock to Esc

The second quirk, is that I used to have my Caps Lock key mapped to Esc (I highly recommend you do the same, especially if you use Vim (which you should :P)) but since I was using GNOME to configure it, I had to do the same in awesome

Thankfully xmodmap is just the tool that we need.

Begin by creating a file in your home directory ~/.xmodmap with the following contents

!Remap Caps_Lock as Escape
remove Lock = Caps_Lock
keysym Caps_Lock = Escape

To ensure that our mapping is set on login edit your ~/.xsessionrc file to contain the following

xmodmap ~/.xmodmap

If you haven't done so already, ensure that the file has execute permissions

chmod u+x ~/.xsessionrc

Awesome on

Although it took me a couple of hours to really get used to the shortcuts (I never used the GUI key for anything before), it quickly became natural. I still get a bit confused with how the windows are switched, but I'm sure time will help. I am extremely satisfied with awesome and cannot wait to get better at it!

10 February, 2014

Compiling Latex in Vim

I do a lot of typesetting, and a lot of my work in vim which means that I do a lot of compiling and displaying latex. Normally, I would either use a multiplexer like Screen or Tmux (I actually prefer Screen) to switch back and forth between the source code and compiling; plain old quitting vim to compile; or compiling within vim using something external commands. Although all of them work, they take a lot of keystrokes and are a hassle, and when you have to compile hundreds of times a day, the time adds up. So let's make it better!

What I want

I want either a command or a key map that will compile my current file and display it.

How I did it

By creating a custom command that compiles the current document using pdflatex, displays it using evince (or your favorite pdf viewer), makes sure that all the output is piped to /dev/null, and then redraws the screen. This will create a user-defined command, :Latex, that will compile and display your document.

command Latex execute "silent !pdflatex % > /dev/null && evince %:r.pdf > /dev/null 2>&1 &" | redraw!

You want this to be in your ~/.vimrc so that it will autoload.


The first keyword silent will prevent vim from displaying the "Press ENTER to continue" screen that is usually displayed whenever external commands are executed.

The first step uses pdlatex to compile the current file, denoted by % and pipes standrard output to /dev/null.

The second step uses a logical && so that the command will short-circuit if compilation failed, and then uses evince (or your favorite pdf viewer) to open the file. Note that we use %:r to get just the filename of the current document and then append .pdf to get the compiled version. Again we stdout to /dev/null and additionally pipe stderr to stdout to prevent errors from getting displayed. The command ends with a bitwise & so that the pdf viewer runs in the background

Finally the bitwise | is used to execute multiple commands, after which we redraw the screen. This is necessary to prevent artifacts from showing in the buffer.

Adding a key map (Optional)

If typing :Latex every time you want to compile is also too much, you can additionally map a key to execute it for you.

:map <F2> :Latex <CR>

This will map F2 to execute the Latex command ( is for carriage return, equivalent of pressing ENTER)

More VIM configuration

My entire vim configuration file (along with other common dotfiles) is on GitHub.

24 January, 2014

Using Git to deploy a website

I recently redid my personal website and ended up deploying it to both my personal domain and my UT website. In order to facilitate development and deployment I set up Git post-receive hooks on my servers so I could update my website with one command: git push web. This post will explain how you can do the same.

Setting up git locally

The first step is to git track the local copy of your website (only required if you haven't already initialized git on the local copy)

Using your favorite shell, navigate to the local copy of website on your computer and start git

git init
git add .
git commit -a -m "First commit!"

You have now initialized git, tracked your files, and committed your work!

Setting up git on server

Assuming you have a web server that you can ssh into we can the proceed on the server

cd ~
mkdir deploy.git
cd deploy.git
git init --bare

This will create a folder and initialize a barebones git repository within.

We then create a post-receive hook that will be called whenever you deploy and will update the latest version of your website

cd hooks

Then use your favorite text editor (vim, emacs, nano, etc...) to create 'post-receive' that will contain the following:

GIT_WORK_TREE=~/public_html/ git checkout -f
chmod -f -R o+x ~/public_html

The first line specifies that this is bash executable

The second line sets the GIT_WORK_TREE environment variable to wherever your public html files are located (usually in /var/www or ~/public_html)

The third line is optional, it gives the "others" group permission to execute files. This is a failsafe to ensure that apache can execute .php files.

In order to activate this hook, we must make it executable

chmod +x post-receive

Pushing to server

Returning to the local copy of the website

git remote add web username@yourserver:~/deploy.git
git push web +master:refs/heads/master

That's it!

Deployment workflow

Deploying to your website is now a breeze! Your typical development workflow will be

  1. Edit files like you normally would
  2. git add . (if you create new files)
  3. git commit -a -m "your message" to commit your changes
  4. git push web to deploy!
  5. Rinse and repeat
16 November, 2013

ProveMe: HackTX 2013


This year I attended my first hackathon, UT's very own: HackTX. It was an extremely exciting event, filled with smart people, cool companies, even cooler projects, and free swag!

I entered the competition with my friend, Will Yager, who specializes in embedded systems and cryptography. We decided to create a web service to cryptrographically timestamp data. My task was to create the web front-end and the back-end server to handle requests, files, and payments. Will had to create the bitcoin server which provides an API to timestamp and verify files and data.

We used $300 that RackSpace gave us in credit to rent a high-speed server where we ran a LAMP stack and a python bitcoin wallet and web server.

We used Apache and PHP to server the webpages as well as handle the file or data uploads. The data is then hashed using SHA256 and passed on (as a hash) to the python which creates a bitcoin transaction containing the hash in the message. Once the transaction committed to the blockchain (verified by the bitcoin network), it becomes permanent, and can therefore be securely used to prove existence.

Although ProveMe is not necessary to prove the existence of the data, ProveMe provides a way to upload data and check if it has been timestamped on the blockchain, and if it has, to see when.

Although we did not win, we still had an amazing time hacking and meeting awesome people!

PS: Our servers are no longer online, you can check out the project on HackerLeague, and the source code for the bitcoin server on GitHub

PPS: If you are actually interested in this service, a similar service (which came out after ProveMe) is Proof of Existence

11 August, 2013

Google Chrome Extension - Airdroid Notifier

AirDroid Notifier Banner

As a regular AirDroid user, I found that there is only thing keeping AirDroid from perfection: true message notifications. If you happen to be away from your phone (or have it on silent) and receive a message, the only notification you get is a small toast within the web interface; no sound, and no persistant notification. This means that I often have to be checking the Airdroid tab for new messages. After some researching, I could not find any simple solution for my problem; so I created my own.

I present: AirDroid Notifier!

This is a simple, lightweight Google Chrome extension that will notify and ring you whenever you receive a new message!

It uses webkit notification to ensure that you see it regardless of what window/tab you are using. Any incoming text message will trigger a notification that can be seen from any tab, any window, or any application.

AirDroid Screenshot

This extension is 100% free and simple to use! Just install it and get notified!

Install View in Chrome Web Store

Disclaimer: This extension and its author, are not affiliated with, endorsed, or sponsored by AirDroid

*The AirDroid icon and name are trademarks of Sand Studio

Home← Older posts