Saturday, December 15, 2012

Raspberry Pi - Daily Deviations Picture Frame



I have been following the progress of the Raspberry Pi with keen interest for a while now and I’ve finally got one of my own to play with. Over the past couple of weeks I’ve been tinkering with it in the evenings and I’m absolutely blown away by this little device. With a $35 dollar price tag, the RPi is a surprisingly capable computer. You obviously won’t be doing some of the CPU intensive tasks you would be used to on your PC, but its a great way to tinker and learn and maybe find a great practical use for it along the way. After a little trial and error I’ve found an interesting application for it that I wanted to share.

I’ve seen a few people contemplating using the Raspberry Pi to power a photo frame for the living room. One of those digital picture frames that cycles through a bunch of pre-loaded jpgs of your friends and family. This gave me the idea of having a piece of art hanging on the wall, with a nice wooden frame, that actually downloads new art everyday and cycles through it. So I’ve come up with a fairly simple way to do this all without ever starting X.

I would just like to clarify a few things first. This solution relies on a few bash scripts, and this is my first experience making them. I’ve really been piecing together bits of commands that I have found all over the web. I am by no means an expert and this method is probably not the best way to achieve the end result. In saying this, if you know of a better way to get this job done, by all means leave me a comment as I would love to hear your ideas.


What it does

When the RPi is turned on it boots up, deletes all jpg’s and png’s in the directory /home/pi/deviant/, downloads the daily deviations from deviantart, deletes any that aren’t a jpg or png (gifs and other files don’t work yet) and begins a slideshow using the framebuffer. At midnight the slideshow is halted, the RPi is rebooted and the cycle starts over.

What I used

Raspberry Pi Model B
8GB SD Card
Rapbian Wheezy

How it works

After you have a fresh install of raspbian wheezy on your SD Card, pop it into your RPi and boot it up. There is a little wizard at the beginning that walks you through a few simple startup options. I chose to expand root partition to fill SD Card, changed the keyboard layout to us, changed my timezone to Edmonton and changed start desktop at boot to no. After a reboot the RPi will take a few minutes to resize the root and then it will ask you to login. The username by default is pi with a password of raspberry. Every time the device is turned on it will ask you to login, and for our purposes this is not ideal. We want the user pi to be automatically logged in upon boot. Here is how we do that:
  • sudo nano /etc/inittab


This will open nano as root, which is a terminal based text editor. Scroll down until you find the following line:

  • 1:2345:respawn:/sbin/getty --noclear 38400 tty1

Add the pound sign to the beginning of this line to comment it out and add the following to the line beneath it:

  • 1:2345:respawn:/bin/login -f pi tty1 </dev/tty1 >/dev/tty1 2>&1

Please note that I've used the default user "pi". If you are using a different user name use that instead. Press ctrl+x to exit, type Y to save and enter to confirm filename. Now type

  • sudo reboot

The RPi will reboot and if you did everything right, it will now automatically login as user pi. The next thing we will need to do is install fbi (Linux FrameBuffer Image Viewer). To do this type the following:

  • sudo apt-get update
  • sudo apt-get install fbi

The next thing we have to do is create the scripts that will do the work. Make sure you are in the home directory and type

  • mkdir deviant

This will create a new directory within your home folder called deviant. Change into this newly created directory and type

  • sudo nano getart.sh

Once nano is open we will enter the commands to remove any images from the deviant directory.

  • rm *.jpg *.png
  • rm aa.*

The aa.* will make sense later. Next we will enter the commands to download the daily deviations from deviant art:

  • wget -U 'SomeUserAgent/1.0' -O- 'http://backend.deviantart.com/rss.xml?q=special:dd' 2> /dev/null |

  • grep -Po 'http://[^.]+\.deviantart.com/art/[^"]+-\d+' |

  • sed -r 's/.+-([0-9]+)/http:\/\/www.deviantart.com\/download\/\1\/aa/' |

  • wget -U 'SomeUserAgent/1.0' -i-

This will download the files and name them aa.1, aa.2, aa.3, etc. sequentially so we need to now go through each file and rename it or delete it depending on its file type:

  • FILES=~/deviant/*
  • count=0
  • one=1

  • for f in $FILES

  • do

  • file -b $f

  • echo "Checking file number $count"
  • count=$(($count + $one))

  • if [ "$(file $f|grep JPEG)" ]; then
  • mv ${f} ${count%.*}.jpg



  • elif [ "$(file $f|grep PNG)" ]; then
  • mv ${f} ${count%.*}.png

  • elif [ "$(file $f|grep ASCII)" ]; then

  • echo ”Skip Script file”

  • else
  • rm ${f}

  • fi
  • done

This will go through each file in the directory and either rename, skip or delete it depending on if it is a jpeg/png, script, or anything else. The last line will execute the slideshow script we will write next:

  • bash /home/pi/deviant/slideshow.sh

Now type ctrl+x to save. Next we will create the slideshow script. Type the following:

  • sudo nano slideshow.sh

Once nano has opened enter the following command:

  • fbi -noverbose -m 1920x1080 -a -t 10 /home/pi/deviant/*.jpg /home/pi/deviant/*.png

Now type ctrl+x to save and the slideshow script is done but there is one problem. My screen resolution is 1920 x 1080 so I have set the mode to 1920x1080 but this probably won’t actually work right until we add this mode to the system. You can customize this part to whatever works best for your set up. Type the following to add a mode:

  • sudo nano /etc/fb.modes

Now scroll to the end of the page and enter the new mode:

  • mode "1920x1080"
  • geometry 1920 1080 1920 1080 32
  • timings 0 0 0 0 0 0 0
  • accel true
  • rgba 8/16,8/8,8/0,0/0
  • endmode

Now type ctrl+x to save the file. There is one more script to create before we move on. This one is a simple reboot script. Type the following:

  • sudo nano rboot.sh

Once you are inside nano enter the command:

  • sudo reboot

Crtl+x to save and now we have to make these three scripts executable. Type the following commands:

  • sudo chmod +x getart.sh
  • sudo chmod +x slideshow.sh
  • sudo chmod +x rboot.sh

The purpose of the rboot script is to reboot the RPi at midnight everyday. To accomplish this we are going to use cron which is a handy tool for scheduling tasks. First we must start cron at every bootup. Enter the following:

  • sudo nano /etc/rc.local

When the script opens in nano we want to add the following two lines on the line above exit 0.

  • /etc/init.d/cron start
  • bash /home/pi/deviant/getart.sh

Ctrl+x to save. This will start cron and execute the getart script every time the RPi is booted up. Now the final step is to schedule the unit to reboot at midnight everyday. To do that type the following:

  • crontab -e

We need to enter the following command in nano:

  • @midnight /home/pi/deviant/rboot.sh

Again Ctrl+x to save and we are done. Type:

  • sudo reboot

The system is now up and running. So as I mentioned before, there is probably a better way to do some of this stuff and I’ll keep tinkering with it, but it should give you at least a starting point for creating a really simple image viewer.

Saturday, November 24, 2012

Install Multiple Desktop Environments in Ubuntu

As I was testing different distributions I was really blown away at the variety and quality of the different desktop environments. I was incredibly impressed by how robust and powerful some were, such as KDE, and how functional and sleek others were, like Cinnamon. While I did eventually decide to settle on Ubuntu because of their massive user base and application support (Steam, Lightworks, etc.), it was not an easy decision to make, mostly because of how much I had enjoyed many of these desktop experiences. I could really see how certain desktops would be perfect for certain tasks, and finding one that was good for all tasks was almost impossible, at least for my multifaceted workflow that is. Wouldn’t it be great if you could use Ubuntu as a base and choose which desktop environment happens to suit your current needs. Well, as it turns out, you can and it’s actually incredibly simple to do. I want to give a quick run through of how I setup my Ubuntu 12.10 system to allow me to choose between my favorite desktop environments at login.

Unity

This one comes standard with a new install of Ubuntu 12.10 and while it gets a lot of mixed reviews, I actually really like it. It’s a great interface for when I’m working with web applications. With web app support for google docs, reddit, google+ and many more, I find myself using Unity when I’m in a browsing mood. No special steps required to get this one rolling.

LXDE

This is a super lightweight, low profile desktop environment. It loads up insanely fast and takes very little system resources to run. Although I wouldn’t say it’s exactly beautiful to look at, when I need to get some real computing done, thats the last thing I care about. I have been playing with Blender over the past couple of weeks and I could definitely see the benefit of this option when building and rendering complex scenes. To get this desktop simply open the terminal and enter the following:

  • sudo apt-get install lxde

KDE

I’m still discovering all the awesomeness that is kde. I love the idea of activities and could see this being incredibly helpful. I also found it really useful for setting up application menu entries, which I discovered totally by accident. I had downloaded the latest blender release from blender.org (not from the ubuntu software centre) and extracted the files to a folder in my home directory called “Blender”. Although I could start the application by double clicking the blender executable file, I wasn’t able to see it in my application lens. Not the end of the world, but something I wanted to eventually rectify. After installing kde and booting it up, I dragged that same blender executable file to the main panel, right clicked it and chose "icon settings". After clicking on the icon within the next window I was able to browse to the svg file that blender provides in the package and the icon was applied to the file. Interestingly, when I had switched back to unity, blender now shows up with it’s beautiful vector icon in my application lens. I would encourage everyone to at least try kde, it’s a bit of a bigger download (around 300MB) so if you are really low on storage keep that in mind. To install it just open the terminal and enter:

  • sudo apt-get install kde-plasma-desktop

Cinnamon

I was really impressed by this desktop. I was immediately comfortable moving around its workspace, and everything just felt good. I think this desktop is a great option for those switching from windows as its layout will feel pleasantly familiar. It’s simple yet elegant and puts the focus on the applications you are running. To get this desktop up and running, just open the terminal and enter the following:

  • sudo add-apt-repository ppa:gwendal-lebihan-dev/cinnamon-stable
  • sudo apt-get update
  • sudo apt-get install cinnamon

Chrome OS

I had been curios about google’s chrome operating system for a while, so when I saw that it was possible to install it on Ubuntu I just had to give it a shot. I think it only works on a 64 bit system, so make sure that’s what you’re running. Open the terminal and enter the following:

  • wget https://github.com/downloads/dz0ny/lightdm-login-chromeos/lightdm-login-chromiumos_1.0_amd64.deb
  • sudo dpkg -i lightdm-login-chromiumos_1.0_amd64.deb

Cleaning Up the Login Screen

So now that we have a variety of desktops installed, it’s time to try them out. Just log out of your session to get back to the login screen. From here click on the little Ubuntu logo to see all your options. You will probably notice that there is a bunch of desktops that got added that you may not need or want as it can start to get a little cluttered, not to mention unusable if you are on a low resolution monitor. For example, after installing cinnamon, I noticed there were two versions available in the list; Cinnamon and Cinnamon 2D. After using Cinnamon, and seeing that it loaded and worked great, I wanted to remove Cinnamon 2D from the list (along with a few others) and to do this is fairly easy. Just log back into any of your desktop environments and open the terminal. The different options are stored in *.desktop files within the folder /usr/share/xsessions. To remove desktop entries from the login menu, you simply need to rename the ones you don’t want. In the terminal navigate to the folder and rename the appropriate files:

  • cd /usr/share/xsessions
  • sudo mv cinnamon2d.desktop cinnamon2d.desktop.bac


Continue this method for all the options you wish to remove and the next time you log out, you will see the change. To get an option back just rename it back to the original:

  • cd /usr/share/xsessions
  • sudo mv cinnamon2d.desktop.bac cinnamon2d.desktop




Wednesday, November 21, 2012

Fixing Broken NVIDIA Drivers in Ubuntu

Once I got Ubuntu installed I ran into a few issues with the NVIDIA drivers. One of top suggestions people have when starting Ubuntu for the first time is switching to the newest graphics driver. By default the system is set to use the Nouveau driver and for me it worked great without any issue. However when I would switch to any of the other drivers, upon reboot, the login screen would come up a very low resolution and unity wouldn’t pop up at all. I was able to right click the desktop and choose “change desktop background” to get into the settings and change it back, but I couldn't figure out why none of the other drivers worked. After a bit of research and playing around I have discovered a fix to the problem. I needed to install the kernel headers in order to make it work. I opened the terminal and entered the following:

  • sudo apt-get install linux-headers-$(uname -r)

After I entered my password the headers were installed and I switched to the NVIDIA driver and rebooted. This has fixed the issue and I can now successfully use all the NVIDIA drivers.

Friday, November 16, 2012

Dual Booting on Separate Drives



When I installed Ubuntu 12.10 I decided to install it on a separate hard drive from my Windows 7 install. Windows is installed on a 1.5TB hdd and I had an extra 500GB hdd that I intended to use for Ubuntu. I installed the hard drive in my PC and booted up the 12.10 installer. When the “installation type” window came up I chose “Something Else” and then “continue”. This popped up a partition editor and I was able to see both drives in the list. Because they were both different sizes, it was easy to determine which was which. In my case the windows drive was called /dev/sda while the new drive was called /dev/sdb. I had used the drive before so there was a bunch of partitions that I needed to erase. To do this I just selected the partition I wanted to erase and clicked “Delete”. Once they were all gone I was left with one item under /dev/sdb called “free space”. I selected this and clicked “add” to create a new partition. Under “Mount Point” I picked “/boot”, I made the size 500MB, left the rest at default and clicked “OK”. I created another partition for root choosing “/” under Mount Point, Logical for the type, and a size of 50,000MB. For the next partition I selected “swap area” under “use as”, making it 4000MB, I clicked “Logical” for type, and “End” for location. Finally for the last partition I used the remainder of the drive for the home partition. I chose “/home” under Mount Point, “Beginning” for location and “Logical” for type.



Important Step!

To make sure I could boot into both Windows and Ubuntu, I selected /dev/sdb under “device for boot loader installation”. and then clicked “Install now”. Once the install was finished I rebooted the computer and pressed the delete key to enter the BIOS. I set the second Ubuntu hdd as my primary boot device and BAM! I was dual booting with windows.

Wednesday, November 14, 2012

Distribution Addiction

It’s time for me to pick a distribution. Over the past few days I’ve been testing out a bunch of different distro’s and desktops and wanted to share some of my experiences. I’m actually planning on installing Linux on two different machines so I'll also give an overview of the hardware to be used.

Laptop / Tablet
Asus Eee Slate EP121
Intel Dual-Core i5 470um
4GB Ram
Intel HD Graphics

I’ll start by saying that while I’ve made my decision about which distribution I’m going to keep installed on my PC, I’m still undecided on the tablet. I’ve had a bit of difficulty even getting some installed using just a USB stick. Here is what I’ve tried on the tablet.



Fedora 17 - Beefy Miracle

I was able to successfully install this using a USB stick and the process was incredibly easy. I used unetbootin to create the bootable stick and the whole process took maybe an hour. I had read that the gnome 3 desktop was a bit more friendly to the tablet form-factor so I was eager to give it a try. Upon booting it up I was surprised to discover that I couldn’t operate it without a keyboard. Even after enabling the on-screen keyboard from the accessibility menu, any time I was required to enter a password, which is really quite often, the keyboard wouldn’t come up and there didn’t seem to be any other way of activating it. There is a couple hardware buttons on the EP121 so I thought I might be able to map one to bring up the keyboard but I couldn’t seem to work it out. In the shortcut menu both buttons came up as 0xf8 and didn’t seem to really do anything. There are things about it that I think show a lot of potential but I really won't be able to use it because of the keyboard limitation.





OpenSuse 12.2

Not much to report here actually as I couldn’t get it working. I once again used unetbootin to create a bootable USB stick and was able to boot up a live session with ease, but once the installation was finished, the system would crash upon log in.





Kubuntu 12.04

This I actually really liked. Once I figured how to go into the netbook workspace, I really started to see how this could be a great option for the tablet. At first KDE seemed a bit odd to me, almost cartoony or toy like, but the more I use it the more I really really dig it. It’s super robust and incredibly customizable and I think it’s a really good option. I did have some problems with my touch becoming unresponsive sporadically but I could always switch to the pen which was totally reliable. Web browsing was a bit of a chore, and while installing the grab and drag add-on to firefox helped a lot, it was still very laggy.






Gubuntu 12.10

I thought I would give gnome 3 one more chance as I think it could be a really great tablet OS, so I installed Gubuntu just to see if there was any immediate improvements. Low and behold the onscreen keyboard problem had been resolved. If it is enabled in the accessibility menu it will automatically appear when I’m prompted to enter my password. Hurray! I can actually use it without a keyboard. One issue I’m having is that there is no hibernate option when I flick the power button. I can only turn the system right off or restart. Even setting the suspend option in the power menu to five minutes doesn’t seem to do anything, so for now my tablet is either totally on or totally off which seems a bit strange.

So for now I’m going to keep playing with Gubuntu until I can find a better option for my tablet. Do you guys have any suggestions about what might work better? If you do please leave a comment and I’ll check it out.


PC
Dell Studio XPS 9000
Intel Core i7 CPU 920 @ 2.67GHz x 8
12GB Ram
GeForce GTX 260 with 896MB

Thankfully I had a bit of an easier time getting things rolling on my PC. Linux seems to really shine on the traditional desktop form-factor. Here is what I’ve tried.



Arch Linux

I was a bit nervous about using Arch because everyone keeps telling me its aimed at advanced Linux users and I can definitely see why. After fumbling around trying to get it installed, I came across youtube user TheRobGraves and his tutorial on getting it going. This guided me through the installation process and although I didn’t exactly understand everything I was doing, I did manage to get it up and running with the KDE desktop. I have nothing but good things to say about KDE, it is absolutely awesome! I love how customizable it is and figuring it out took no time at all. I got the hang of using pacman pretty quickly to install packages and after doing a bit of research I discovered the yaourt wrapper which opened up a huge amount of content. After going to town on installing packages using yaourt, I started having a lot of conflicting dependencies which was a bit over my head. I’m not really comfortable editing PKGBUILDs, nor do I really understand how they work so I decided I may need a bit more time to learn these concepts before making arch my full time distro. One thing I will say is that the Arch wiki page is really good. There is a huge amount of information there to keep me busy for a while.





LinuxMint 13 - Cinnamon Edition

A lot of people on different forums have suggested I check this distro out and I immediately could see why. This operating system strikes me as an incredibly polished package, something that is perfect for anyone migrating from Windows. Another super easy installer and almost zero learning curve to get started are what really made this distro stand out.






Ubuntu 12.10

After having to do so much work getting arch installed, the ubuntu installer was hilariously easy. The distro installed effortlessly and I was up and running in no time. Based on the comments I’ve been reading online for the past few days, I have a feeling my opinion of ubuntu and unity might be a little unpopular but, I love it. I will admit I was really turned off at first by the sheer amount of clicking around I seemed to be doing but once I started getting the hang of all the shortcuts, I was really happy. I can see why this distro is suggested for new linux users, because I have had a really easy time getting up and running. I signed up for ubuntu one and was able to install some of the games I purchased on the Indie Humble Bundle with great ease. There seems to be a lot of people bagging on unity out there so I was expecting it to be a bit of a mess, but that hasn’t been my experience at all. I think its really interesting how it integrates with certain web pages and I could definitely see this being my full time desktop. I think I’m going to keep it installed and get a bit more familiar with the interface because it seems like a good starting point for now.



Elementary OS

With the release of elementary OS Luna Beta 1, I decided to give it a try as it looks like a really sleek and simple distribution. I downloaded the 64 bit version and installed it on a new Acer Veriton I had laying around. This machine has an Intel i3 processor and 4GB of ram. It first boot directly into a live session as you would expect, from there I chose to install elementary OS and then went through the same process to install as with Ubuntu. When the install finished and I got a chance to start using the desktop, I was really impressed by how fluid the experience was. This is a very simple but beautiful desktop, smooth and subtle animations keep everything looking really polished. And I got the hang of it in no time.


Couple of things I should touch on. The implementation of the multiple desktops is very nice but it took me a bit to work it out. Pressing the Windows key and S brings up the workspace switcher at the bottom of the screen. From there its easy to create a new workspace and move between them. You can also use the Windows key and the left and right arrow keys to switch between desktops. Check out the video to see what I mean.




I’m sure there is a ton of distributions I should check out and I could see this becoming kind of addicting. I’ve been really happy with everything I’ve tried on my desktop PC, but things really fall short on my tablet. Everything is very clunky and awkward to navigate. Does anyone know of any good Linux operating systems for a tablet PC? Let me know.

Monday, November 12, 2012

Why Linux? Why Now?

I wanted to talk briefly about why I have chosen to make this journey into the world of Linux, why I think it’s necessary and what other options I've considered. I have been using windows since Windows 95, and have used almost every iteration of the OS as its progressed. It’s a solid system with a lot of huge advantages due to it’s massive user base and plethora of applications available on it. Part of the reason it has been so successful is not due necessarily to Microsoft’s efforts, but rather the thousands of companies and individuals that have contributed towards making it useful. My first action upon booting up a new windows machine has always been replacing many of the operating systems default programs. Windows media player with VLC, Internet explorer with chrome, windows media center with XBMC and the list goes on. It has never bothered me at all because Microsoft seemed to understand what it’s strengths were; maintaining a solid foundation for others to innovate on. They now seem to be straying from this trend, tightening their grip on the development process, perhaps drawing inspiration from another successful company.

A lot of you may be wondering why I don’t just move to Apple’s OSX. Certainly this would be the easiest move for me to make. As a graphic designer, most of the applications I know and love are available for the mac platform and the operating system is familiar and easy to use. If I'm being honest, I really like OSX, I find it to be a very nice user experience regardless of your computer competency. I just personally can’t get behind this company. Their “patent everything” and “sue everybody” approach to business over the past few years, along with the “you use what we tell you to use” attitude towards the user makes me very hesitant. So I am going to avoid taking that path as long as Apple continues to be a bully in the tech world.

So now on to Linux. I love the concept of a free and open platform, with millions of people from all over the world working together towards making something better. People sharing and learning from one another and creating new possibilities for those who wouldn't have otherwise had them. Linux is something I want to be a part of, something I would like to contribute to, and something I think more and more people are starting to get behind. It also seems like there is a lot of interesting innovations happening on the ARM front in the Linux world. Not just crippled versions of the distributions that can't run any of the traditional applications but the full desktop experience running on the new architecture. Check out this video about Ubuntu for Android. This seems really interesting!

Saturday, November 10, 2012

The Switch to Linux - Introduction



I've had my eye on Microsoft’s windows 8 for a while now. Some of the ideas initially sounded quite promising; windows running on the ARM architecture along with a GUI that could work well on both the tablet and traditional PC form-factors. But as time went on, my excitement started to turn to worry. And after trying many of the developer previews and now the final releases, I can safely say I don't really like the new direction of windows. That's not say that there isn't some really great things about the windows 8 platform, there is, but it may not be suitable for everyone, especially those of us who might be considered "power users". This is why I've decided to begin making the switch to Linux. I want to make this transition from Windows to Linux a public and open experience, in the spirit of the open source concept and in the hope that my successes and failures may help others who are considering the switch as well.

Let me just quickly explain a little about myself. I've been working for a media company doing mostly graphic design and video production for the past four years. Some of my everyday duties include, creating advertisements, designing digital signs / menu boards, producing GUI elements for interactive displays as well as web design. I have also been doing a lot of programming and have created applications for the RCMP and a few educational institutions. I also wrote the digital signage application that my company now uses to deploy our product across North America. I am by no means an expert in the realm of programming, but I have taught myself enough to be fairly useful. I use dozens of windows applications everyday to do what I do, so this switch to Linux will most likely be a slow transition. In the meantime I will keep my Windows 7 system on hand until I no longer require it, which may be a while.

Although I have had my eye on many Linux distributions for a while I am a total noob and only really tinkered with a few so this blog will be coming from a new users point of view. In saying that I apologize to any Linux gurus who may be offended by my ignorance or terminology but... get over it. We've all got to start somewhere. I will try to talk a little bit about every step I take in setting up a Linux system and getting productive on it. Please feel free to comment and let me know if you have any tips or suggestions for a new Linux user that may have helped you in the beginning.