Tag Archives: Arch Linux

Building a Volume Popup using Dzen2

If you have been following my blog at all lately, you’ll know that I’ve been pretty obsessed with my brand new ASUS ux305. After browsing /r/unixporn for days without doing anything, I decided to take a stand against my bland i3 setup and get things rolling. One of the things that has always bothered me about my Linux machines is the fact that a lot of the hardware keys don’t work because I am too lazy to make them work.

This was changing. Now.

So far, for my volume keys, I had them hooked up to a small BASH script which called on alsamixer to raise or lower the volume by 5%. My volume level is also continuously displayed in a conky panel at the bottom of my screen; however, the conky panel only updates every second, and sometimes this second is a little too slow when the volume button is being pressed in rapid succession. Thus, I needed something to alert me in realtime when I was changing the volume.

The main thing I was interested in was making something like GNOME or OSX have – something that pops up and alerts you of the volume (Preferably without an annoying popping noise). Something like this:

volumetrickformacIn order to do so, I needed to find a tool that would display something on the screen. Some sort of notification/message platform that was extremely lightweight. I have heard of some of my friends using dzen2 to power their panels, so I decided to look into that. It was the perfect solution. Basically, now every time I call my volume changing scripts, I can display the current volume level in some sort of alert.

First, I had to create an alert script that would make my alert designs a little more portable and easily customizable. I went with something that allowed me to create alerts in both the middle and the top of the screen and with colors that matched my status bar. The result was this mess:

#!/bin/bash 
                                                                   WIDTH=300                                                                       
HEIGHT=50                                                                       
                                                                                
# This script shows an alert using dzen                                         
screenWidth=$(xdpyinfo | grep 'dimensions' | egrep -o "[0-9]+x[0-9]+ pixels" | sed "s/x.*//")
screenHeight=$(xdpyinfo | grep 'dimensions' | egrep -o "[0-9]+x[0-9]+ pixels" | egrep -o "x[0-9]*" | sed "s/x//")
let "middleY = $screenHeight / 2 - ($HEIGHT/2)"                                 
let "middleX = $screenWidth / 2 - ($WIDTH/2)"                                   
                                                                                
if [ "${2}" == "top" ]; then                                                    
        echo $1 | dzen2 -fn "DejaVu Sans Mono 8" -p $3 -h $HEIGHT               
else                                                                            
        echo $1 | dzen2 -fn "DejaVu Sans Mono 8" -p $3 -y $middleY -x $middleX -h $HEIGHT -w $WIDTH &
fi

Basically, this script takes 3 arguments – The message, the position, and the wait time. This is all of the information I am going to need to ever specify for my popups. Now all that is left is to get the volume buttons working with the script. My volume buttons are already linked to two scripts via my i3 config file, mainly the two lines:

bindsym XF86AudioRaiseVolume exec $HOME/.i3/bin/raiseVolume.sh
bindsym XF86AudioLowerVolume exec $HOME/.i3/bin/lowerVolume.sh

The final step is simply creating the lowerVolume.sh and raiseVolume.sh scripts. They are simple, now. They basically call amixer to handle the volume control, save the output, and display it in an alert. Here’s the code to lowerVolume.sh

#!/bin/bash                                                                     
                                                                                
volume=$(amixer -c 1 set Master 5%- | egrep -o "[0-9]+%")                       
`$HOME/.i3/bin/showAlert.sh "Volume: $volume" middle 1`                         

Note that this uses our alert script to display a message in the middle of the screen for 1 second. It’s perfect. The raiseVolume.sh script is exactly the same, but there is a “5%+” instead of a “5%-“.

The end result is beautiful.

rsz_2015-04-16-224403_1920x1080_scrot

This alert system will soon be implemented into the script I use to detect new emails and brightness keys, once I get them working.

I’m Going Full Linux

Running Linux on my machines is my own personal hobby. One of the first things I did with my first laptop was dualboot Ubuntu and Windows. Ever since then, I have installed Linux on every machine I’ve had. Usually, I install Linux thinking that I have no need for any other operating system. Then, a need comes along, and I end up dual-booting Windows and Linux. Currently, my ASUS K55N-DS81 laptop holds the record with about a year running only Linux. However, this streak was ended when I went out of town with only my laptop and needed to do some serious .NET editing in Visual Studio.

Needless to say, the dream still continues. I still want to have atleast a single machine that runs only Linux. One of the main problems I have with my current laptop is its abysmal battery life. I get about 2.5 hours per charge, which is not enough to make it through the day. Thus, I’ve been looking for a replacement laptop. Something powerful enough, but also lightweight and not lacking in the battery department. What I found was the ASUS UX305.

ux305After browsing several Arch Linux forums and webpages, it seems that this laptop is perfect for Linux. Everything works out of the box. This is more than I could ask for given its astonishingly low price of $699.

Laptop selection aside, the struggle comes when installing Linux. The problem isn’t getting everything to work, but rather finding alternatives to all the Windows software that I use on a daily basis. Time and time again, the troublesome piece of software proves to be Visual Studio. I do a lot of development for work in Visual Studio, so it is a relatively mandatory piece of software. Recently, however, I stumbled upon MonoDevelop and its fantastic GTK# Window Designer. After trying it out for a few hours, I have determined that it is a worthy alternative to Visual Studio’s Form Designer. I look forward to seeing how it compares when using it on a daily basis.

That being said, the laptop is arriving in two days. I plan to heavily document my Linux installation process and all other things in order to create a sort-of ongoing guide for anyone who wishes to pickup this laptop and install Linux on it. I will not give up on this Laptop. I will not dual-boot. I am going full Linux.

Using cmatrix to Test Graphics Drivers

cmatrix is a command-line utility that displays the famous terminal screen from the movie The Matrix that the characters stare at. A lot of people in IRC land mention that they like to have cmatrix running somewhere on their screen so when someone that doesn’t know much about computers walks by, they are set in awe and amazed at how the programmer is able to quickly decipher such sporadic information. They also suggest to have a cat of /dev/urandom on another terminal screen.

cmatrix

cmatrix

When installing Arch Linux on my ASUS K55N-DS81 laptop, I noticed that when I installed and ran the cmatrix utility (which is available in the Pacman community repo), it would begin to lag after about 5 seconds of operation (when the screen got really crowded). At first, I thought that this was due to the fact that the window manager I use (i3-wm) does not support true double buffering, thus causing cmatrix to have trouble outputting its payload to the console. In order to remedy this, I went ahead and installed compton, which is a composite manager known for working well with i3. Unfortunately, this did not solve the problem.

Thus, There was only one other thing that was really affecting how things were displayed onto my screen, and that was the display drivers. I currently had the xf86-video-ati drivers installed, which are the open source drivers for ATI graphics cards supported by Arch Linux. Obviously, these were causing problems. I then went through the semi-painful process of getting ATI’s catalyst drivers installed on my laptop (the process is very well documented, so it’s actually not that big of a deal).

Well, after getting the drivers installed and restarting my system, cmatrix ran without a hitch. Buttery smooth. I was even able to launch many, many instances of it without problem. Thus, when installing Arch on a new system (or any linux distro), cmatrix serves as a simple way to make sure that the display settings are up-to-par (For basic CLI programs, at least). Be aware that this is not a test for actual graphics intensive things.

The Switch to Arch: Day 1

One of the things that I’ve wanted to do for as long as I’ve known about Linux is make the switch to Linux full time. I wanted to understand how the operating system functioned, how I could use it, how I could alter it, and how I could get it installed on all of my machines. I have taken many baby steps to get to that point. For instance, from 2013-2014, I only had Lubuntu installed on my laptop and forced myself to use Linux for every task that came to mind. Of course, I also had my trusty desktop with a Windows installation. Although I definitely learned about Linux this way, I found myself often coming back to my Windows machine in order to edit with Photoshop, play some video games, or even do things without trying to make them compatible with Linux.

Just recently I decided to really push for the conversion process by taking a dive into Arch Linux and putting it onto my laptop. After about 2 days of struggling to get it installed and working as I wanted, I felt super happy and super confident. If you are unfamiliar with using Arch Linux, I highly recommend it. It is a great way to learn about how Linux works and it is a great experience (and very rewarding).

Anywho, so I got ArchLinux running on my laptop. I decided to choose Slim as my display manager, X as my display server, and i3 as my window manager. I really enjoy the tiling nature of i3 and the simplicity of its dynamic windows. I have tried Awesome and bspwm, but I just cannot get away from i3 and its charm. I think my favorite part about running ArchLinux is its system resource usage. While idling, Arch on my laptop uses 150MB of its 8GB of RAM. This is definitely something that not even Windows nor Lubuntu could pull off. Maybe I am missing some precious functionality that existed in those operating systems, but I definitely don’t feel like I’m missing much.

Inspired by the switch on my laptop, I decided to do the same thing on my desktop. Of course, this is a little more risky because video games have a reputation of not working all that well on Linux, but I am confident that my beast of a machine can pull off at least 30fps on the latest games running under WiNE, so I decided to give it a shot.

After the hours it took to install Arch on my desktop (experience from my laptop install definitely came in handy), I am very pleased with the results. The thing I had most difficulty with was getting my internet to work. For whatever reason, my WiFi  card could see the network but wouldn’t complete the DHCP handshake. The same thing would happen with a wired connection. Thinking it may have been a problem with the WiFi card, I even bought a new card. After messing with this for a few days, it turns out that in order to get internet working for PCI and Mobo adapters in Linux with a GIGABYTE motherboard, you have to enable the IOMMU setting in the BIOS. What IOMMU stands for, I have no clue. For more details on this situation, you can take a look at the ArchLinux forum post I made regarding the issue: https://bbs.archlinux.org/viewtopic.php?pid=1459970#p1459970

In short, I am loving this so far. I intend on posting a more detailed guide to getting Arch perfectly setup on machines that have a similar setup to mine. For now, I will just say that I am a very happy man.

The ArchLinux setup on my desktop machine

The ArchLinux setup on my desktop machine