Our website is made possible by displaying online advertisements to our visitors. Please consider supporting us by whitelisting our website.

large

SpotiAmp – Control Spotify the way you like, even mute commercials / ads

Spotify is a great service! I have been using it for quite a while, but I felt that something was missing.
Winamp has been my main player for years and I got inspired to make a combination and support things I wanted with this application.

Presenting SpotiAmp
SpotiAmp Mainwindow

Features

  • Global hotkeys to control play, stop, pause, next and previous
  • Mute commercials / ads, it comes with a price read about below
  • Simple Webserver support
  • Winamp WM_COMMAND / WM_WA_IPC support to let other applications (like girder) control Spotify

To download please visit the SpotiAmp page.

A Windows user confession: Make LIRC on Ubuntu manage your HTPC + making suspend-to-ram work properly

As the topic says; I am a Windows user. I been using the XBMC on Xbox1 for many years. Since the hardware on Xbox does not handle the new Ò??HD-thingÒ?, I started to find a replacement. This is my recipe that forced me to learn some basic Linux stuff.

Read my part 1 before you continue with this one.

1. Requirements
You need these following items:
* Ubuntu preinstalled with XBMC and LIRC
* A MCE IR receiver/remote that is supported by LIRC
* A confirmed working LIRC, tested with the irw command

2. What do you want it to do?
My HTPC requirements is XBMC, switch between another program (like MythTV) and do simple movements on the desktop. Another thing that is important is the on/off function and my prefer method is suspend-to-ram. It is quick, quiet and fully manageable on Linux.
Much of the information (and some scripts) has been processed and modified from vikjon’s Blog

3. Setting up IRExec+IRXevent and application specific settings
LIRC has an extra tool called IRExec+IRXevent that basically execute a command to terminal when an event happens. Also the MythTV-crew have made a generator for default LIRC-config. It creates application specific settings, we’ll now install’em both:
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Install IRExec+IRXevent by entering: sudo apt-get install lirc-x
3. Install Mythbuntu-lirc-generator by entering: sudo apt-get install mythbuntu-lirc-generator
4. Create default settings running: mythbuntu-lirc-generator
5. Start IRExec to check that it works, enter: irexec (nothing should be printed and a waiting cursor, break it with Ctrl-C)

LIRC is installed as a daemon (service) but the IRExec+IRXevent need to be in your “user space”. This script shall be started when you login. Here is what todo (in terminal):
1. Create a scripts directory, enter: mkdir ~/scripts
2. Create a script-file, enter: nano ~/scripts/startirexec.sh
3. Paste inn these lines, replace the “username” in the text with your own username

#!/bin/bash

# Test to see if IRXevent is running first, if so kill it, then restart
if ps -ef|grep -v grep|grep -i irxevent
then
ps aux|grep -i username|grep -i irxevent |awk ‘{print $2}’|xargs kill
else
# Do nothing
echo “irxevent already dead!”
fi

# Test to see if IRexec is running first, if so kill it, then restart
if ps -ef|grep -v grep|grep -vi start|grep -i irexec
then
ps aux|grep -i username|grep -i irexec |grep -vi start|awk ‘{print $2}’|xargs kill
else
# Do nothing
echo “irexec already dead!”
fi

#test to see if an instance of irxevent is already running
if ps -ef|grep -v grep|grep irxevent
then
# do nothing
echo “irxevent already running”
else
# start irxevent
irxevent /home/username/.lircrc &
fi

#test to see if an instance of irexec is already running
if ps -ef|grep -v grep|grep irexec
then
# do nothing
echo “irexec already running”
else
# start irxevent
irexec -d /home/username/.lircrc &
fi

exit

4. Save the file by pressing Ctrl-X, say Yes to save.
5. Go to System -> Preferences -> Startup applications
6. Press add and goto the directory “scripts”. Add the startirexec.sh file

When you restart and same user logs in, the IRXevent+IRExec will be running in the background.

3.1 Start/kill scripts for your applications
Here are two examples of start/kill application scripts. You should create one on each program you want to control using the remote.

Start-script (to customize to others change the xbmc.bin and the executable xbmc later on)

#!/bin/bash

# Test to see if XBMC is running first
if ps -ef|grep -v grep|grep -i xbmc.bin
then
# Do nothing
echo “XBMC already Running!”
else
# Startup XBMC
xbmc
fi
exit

Kill script (it does a soft kill first and hard after some time. Replace the “username” with your username.)
To manage other applications replace the xbmc and xbmc.bin with your executable.

#!/bin/bash

# Test to see if XBMC is running first
if ps -ef|grep -v grep|grep -i xbmc.bin
then
# Try a clean kill
ps aux|grep -i username|grep -v grep|grep -i xbmc.bin|awk ‘{print $2}’|xargs kill
echo `date` “Killed XBMC! (soft)” >> /tmp/killXBMC.log
else
echo “XBMC already dead! (soft)”
exit
fi

# takes a second or two to die with the soft kill
sleep 2

# Test to see if it’s still running
if ps -ef|grep -v grep|grep -i xbmc.bin
then
# If it’s still around, kill it -9
ps aux|grep -i username|grep -v grep|grep -i xbmc.bin|awk ‘{print $2}’|xargs kill -9
echo `date` “Killed XBMC! (hard)” >> /tmp/killXBMC.log
else
echo “XBMC already dead! (hard)”
exit
fi

Both of these scripts has been stored as ~/scripts/startxbmc.sh and ~/scripts/killxbmc.sh.

You could also create a ~/scripts/reboot.sh, it could look something like this

#!/bin/bash
sudo reboot
exit

Simple and hopefully you have turn off the password-nagging (as described in part 1) so it actually works πŸ˜‰

3.2 Executing these scripts using the IRExec
The mythbuntu-lirc-generator created a hidden directory that contains custom settings for several applications. We are now going to create a simple “common” script that will work independent on which program you have executed.

1. Open a terminal (Applications -> Accessories -> Terminal)
2. Create a common file for our commands, enter: nano ~/.lirc/common
3. Paste inn these commands

#Kill then start XBMC when pressing the Videos button
begin
remote = mceusb
prog = irexec
button = Videos
config = sh /home/username/scripts/killxbmc.sh
config = sh /home/username/scripts/startxbmc.sh &
repeat = 0
delay = 0
end

#Reboot the computer when you press the “Clear” button
begin
remote = mceusb
prog = irexec
button = Clear
config = sh /home/username/scripts/reboot.sh &
repeat = 0
delay = 0
end

4. Press Ctrl-X and save file.
5. Now we have to include the file as a LIRC resource, enter: nano ~/.lircrc
6. Add at the end of the file: include ~/.lirc/common
7. Press Ctrl-X and save file
8. Restart the IRExec by entering: sh ~/scripts/startirexec.sh

Try the remote by pressing “My Videos” and see that XBMC starts.

4. Wake-up on USB
MythTv have a good guide on how to get suspend-to-ram work, this info is partly taken from that guide.

1. Open a terminal (Applications -> Accessories -> Terminal)
2. List the devices available, enter: cat /proc/acpi/wakeup (it should look something like the list below)

Device S-state Status Sysfs node
PCI0 S4 disabled no-bus:pci0000:00
PEG1 S4 disabled pci:0000:00:01.0
IGBE S4 disabled pci:0000:00:19.0
PCX1 S4 disabled pci:0000:00:1c.0
HUB S4 disabled pci:0000:00:1e.0
USB0 S3 disabled pci:0000:00:1d.0
USB1 S3 disabled pci:0000:00:1d.1

3. Usally the USB0 is the one that your ir-receiver is connected to. To activate it enter: sudo sh -c ‘echo “USB0” >> /proc/acpi/wakeup’ (it should state S3 behind it, or else the item will be shutoff during suspend-to-ram)
4. Check in the list that the device is enabled, enter: cat /proc/acpi/wakeup

Device S-state Status Sysfs node
(snip)
HUB S4 disabled pci:0000:00:1e.0
USB0 S3 enabled pci:0000:00:1d.0
USB1 S3 disabled pci:0000:00:1d.1

5. Do a actual test (Warning; this might crash your system. Save any unsaved stuff before you test). Enter: sudo sh /etc/acpi/sleepbtn.sh
6. When it has suspended, hold the power-button on your remote down and see if it wakes up. (If it don’t you either got the wrong USB-device, in the wakeup-list, or the receiver doesn’t send a valid power-on signal to the computer.)

Notice that when the computer wakes up either it hangs or the remote does not work. This will be handled in the next chapter. But first, lets make the change wakeup device permanent.
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Edit the rc.local file (equal to autoexec.bat for us Windows users): sudo nano /etc/rc.local
3. Add at the end of the file (but before exit 0): sudo sh -c ‘echo “USB0” >> /proc/acpi/wakeup’ (change the USB0 if another device worked for you)

Reboot your computer to check if the /proc/acpi/wakeup list has the USB0 (or what ever device working for you) enabled. Do a second test, just to make sure the suspend/resume works.

4.1 Suspend-to-ram and wakeup script
When a computer is suspended a list of devices, drivers etc are stopped. IRExec+IRXEvent needs LIRC to work properly. Both of them are not installed as daemons so they will not be included in a suspend (for some reason).
I have also encountered several lock-ups because of the mce_usb driver, so it is clever to remove driver before a suspend. If you have other drivers for LIRC, just replace the mce_usb with your own name.

The suspendscript will be located at the same spots as our other scripts, here is what you do:
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Create the suspendfile, enter: nano ~/scripts/suspendcomputer.sh
3. Paste the script below into the file

#!/bin/sh
sh ~/scripts/killxbmc.sh
sudo /etc/init.d/lirc stop
sudo modprobe -r lirc_mceusb
sudo /etc/acpi/sleep.sh force
exit

4. Edit the common-file and make powerbutton, on the remote, run suspendcomputer.sh using the chapter 3.2 technique: nano ~/.lirc/common (if you are uncertain on the name of the powerbutton use irw to get them)

You could test the remote powerbutton and see that it suspend. Turn the power on with the remote again. Nothing IR-based is going to work since we have stopped LIRC and removed the drivers. Here is the wakeup-script.
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Create a acpi-resume file by entering: sudo nano /etc/acpi/resume.d/99-resume-lirc.sh
3. Paste the script below into the file. (Change the “Username” with your username, since the resume-daemon execute on another user/level we need to specify.)

#!/bin/bash
sudo modprobe lirc_mceusb
sudo /etc/init.d/lirc start
sudo -u username sh /home/username/scripts/startIRExec.sh
sudo -u username sh /home/username/scripts/startxbmc.sh

4. Make sure the script is executeable by entering: sudo chmod +x /etc/acpi/resume.d/99-resume-lirc.sh
5. Test the script by entering: sudo sh /etc/acpi/resume.d/99-resume-lirc.sh

Now the LIRC and the driver should work again. So try a new suspend/resume using the remote and the 99-resume-lirc.sh will be the last script executed by the resume-daemon.

5. Navigate on desktop using IR
After reading Bryan Ludvigsens blog on how to control Snes using LIRC and Xmacro, I got the idea of use something similar for controlling the desktop.

First off you need to install xmacro, this is how you do it:
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Install xmacro by entering: sudo apt-get install xmacro

Bryans approach is to complicated for me (linux newbie, you know). I took an easier route by reading this post. Here are some combinations you probably want to use, paste the line after the : – sign to test. If it works in terminal it works using the IRexec.

“Start”-button: echo -e ‘KeyStrPress Control_L\n KeyStrPress Escape\n KeyStrRelease Escape\n KeyStrRelease Control_L\n’ | xmacroplay -d 50 :0
Next window (alt-tab): echo -e ‘KeyStrPress Alt_L\n KeyStr Tab\n KeyStrRelease Alt_L’ | xmacroplay -d 50 :0
Close: echo -e ‘KeyStrPress Alt_L\n KeyStr F4\n KeyStrRelease Alt_L’ | xmacroplay :0

You probably got the picture. You can also record your own macros using this command: xmacrorec or xmacrorec2 (read more about that here). To find keyboard shortcuts read this wiki.

5.1 Grouping to re-use buttons in LIRC setup
LIRC support modes (or groups) that activate buttons based on where you are navigating. It is a way to seperate for example the Start-button on the remote. In XBMC you want to get the menu but in “desktop mode” you want it to open the start menu.
The ~/.lirc/common file would be a good place to seperate these modes, here is an example:

#Our wakeup-script execute xbmc and when LIRC is reloaded we are in “Xbmc-mode”
begin
flags = startup_mode
mode = mode_xbmc
end

#Global keys goes here (switch to/from applications). The XBMC button shall have the mode_xbmc (we don’t have any group since XBMC manage itself :))
begin
remote = mceusb
prog = irexec
button = Videos
mode = mode_xbmc
config = sh /home/username/scripts/killxbmc.sh
config = sh /home/username/scripts/startxbmc.sh &
repeat = 0
delay = 0
end

#Still global, but here we change to “desktop” mode
begin
remote = mceusb
prog = irexec
button = Music
mode = mode_desktop
config = sh /home/username/scripts/killxbmc.sh &
repeat = 0
delay = 0
end

#Here is the functions for the desktop, note the mode_desktop
begin mode_desktop

#Startbutton
begin
remote = mceusb
prog = irexec
button = Home
config = echo -e ‘KeyStrPress Control_L\n KeyStrPress Escape\n KeyStrRelease Escape\n KeyStrRelease Control_L\n’ | xmacroplay -d 50 :0
repeat = 0
delay = 0
end

# (…) More desktop-buttons goes here…

#End the mode_desktop here
end mode_desktop

When you press the “My Music” button XBMC will quit and the buttons below would be activated. When you are finished a press on “My Videos” will launch XBMC and deactivate the desktop-mode.

6. All scripts wrapped up
Here are my scripts that I’m currently using. Please note that you need to change the username in some of these scripts.
Common-script to be placed in: ~/.lirc/
Launchscripts to be used with IRExec. Common placement it ~/scripts/
Suspend/resume script to be placed in /etc/acpi/resume.d and common placement ~/scripts/

Note that these scripts contains comments on my native language Norwegian. But you should understand based on the guide. If there are any questions, please let me know in the comments.

    What is next…
    My HTPC works as expected so I don’t spend much time investigating. Nothing new will be added unless there are new stuff that could be interesting.
    The latest modification I’ve done is to install Spotify on Ubuntu, it is done easily by following this guide.

A Windows user confession: XBMC on Ubuntu using ION chipset, the way it should work!

As the topic says; I am a Windows user. I been using the XBMC on Xbox1 for many years. Since the hardware on Xbox does not handle the new “HD-thing”, I started to find a replacement. This is my recipe that forced me to learn some basic linux stuff.

Comments regarding other ways to handle stuff will be highly appriciated!

1. What hardware do you need?
I prefer a simple ION-chipset based computer to take on the task. They are small and have what it takes. I have tested two boxes: Asrock I330 and Acer R3600. Both work well and plays HD in 720p and 1080p without any problems.

None of the boxes above has an IR-eye. If you have an existing MCE remote you can use that, if not jump over to eBay and search for “mce remote”. Most of them work work good with LIRC (Linux IR control), ensure that you have a power on/off button on it.

2. What software do you need?
Ubuntu Desktop (v9.04, called Jaunty, it is what this guide is based on): Download the 32-bits version
XBMC will be installed using respotories after Ubuntu is installed.

2.1 Installing Ubuntu
There are several good guides out there for installing Ubuntu, like this one. Notice! Enable “Log in automaticly” on the “Who are you?” page, that saves you some trouble. Just follow the guide for references and instructions.
None of the ION boxes have a DVD-drive so you will be forced to use an USB-stick. Check this guide out for information regarding that topic.

Update Ubuntu with the Update Manager afterwards, like you would do with any OS.

2.2 Installation of NVIDIA graphics driver
As any operatingsystem you should install a new driver for the gfx-card. For the ION you must!
1. Download the drivers using firefox from here (The 190.18 was the latest when I wrote this and it is based on that)
2. Store them to your Desktop (NVIDIA-Linux-x86-190.18-pkg#.run files)
3. Press CTRL-ALT-F1 (you are now in a terminal without GUI)
4. Login with your username & password
5. Write: sudo killall gdm
6. Check that desktop is killed with CTRL-ALT-F7 (should show some text)
7. Goto root-mode by entering: sudo -i (the username in front should change from to root)
8. Write: cd /home/username/Desktop/ (username is what you entered earlier, might differ from locale to locale, TAB is your friend πŸ™‚ )
9. Start the installation by: sh NVIDIA-Linux-x86-190.18-pkg0.run
10. Next your way through it, straight forward
11. Reboot system by entering: reboot

You should now have Nvidia-Settings under System -> Administration tab on the start-menu. Here you can check the current installed version and change the screen resolution. Other settings are available, just make sure to let the gpu-core run on performance-mode!

2.3 Installing SSH-server as backdoor for updating NVIDIA driver after kernel update
Note: After a while new kernels will be available, when installed they corrupt the NVIDIA driver. Because NVIDIA-driver builds binarys on each kernel, you probably have to do chapter 2.2 again with crappy resolution.
If the driver corrupt you could manage it from another computer, in the same network, using SSH. It is simple and often quicker, here is what you do:
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Install SSH by entering: sudo apt-get install openssh-server openssh-client

The default setup & config is OK from the start. Use Putty as your SSH-client on another computer (ssh on another linux box).
1. Connect to the dns-name/ip of the HTPC
2. Login with your username & password
3. Goto the desktop directory by entering: cd ~/Desktop
3. Visit the NVIDIA driver page and copy the directlink. Download the file like this: wget ftp://download.nvidia.com/XFree86/Linux-x86/190.18/NVIDIA-Linux-x86-190.18-pkg0.run (do the same for alle the files)
4. Follow the chapter 2.2 point 5 and down for finishing installation

2.4 Making your user sudo-master-password-free
Your HTPC does not need security, so to get Ubuntu stop nagging about its precious root-password you should do this. (Warning: This removes the security totally, beware!) Collected from this guide.
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Enter: sudo visudo
3. At the end of file (in the nano-window) enter this:

username ALL=NOPASSWD: ALL
%username ALL=NOPASSWD: ALL

Change “username” to what your username is. The installer creates a user and group with your selected username.
4. Press Ctrl-X, save changes
5. Reboot (to activate the setting)

The “sudo” command in terminal will now stop nagging you.

3. Setting up audio over hdmi
The ALSA (Advanced Linux Sound Architecture) is default installed to the system. It does not manage to setup sound-over-hdmi for some reason. Please check out Alsa Wiki for more information. This is how I managed to fix the problem. This could be different on your system, so please be flexible πŸ˜‰
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Enter: alsamixer
3. Select IEC958 (or simular) using navigation keys and press M to mute/unmute
4. Press Ctrl-C when finished
5. Download wav-examples from here
6. Unzip it by entering: unzip filname.zip
7. Enter: cat /proc/asound/devices it will give you a list simular to this:

lars@htpc:~$ cat /proc/asound/devices
18: [0- 2]: digital audio playback
17: [0- 1]: digital audio playback
16: [0- 0]: digital audio playback
24: [0- 0]: digital audio capture
33: : timer

The brackets shows card and device number. [card- device]
8. Play the file by entering: aplay -D hw:card,device file.wav (replace card with your card number and device with your device number and file.wav with the soundfile. Example: aplay -D hw:0,2 file.wav, used the first device in the list).
You might have to try through different card and devices, you should get sound on one of them. When you do remember the card & device.
10. Create a file by entering: sudo nano /etc/asound.conf
Change x to your cardnumber and y to your device.

ctl.!default {
type hw
card x
device y
}

pcm.!default {
type plug
slave {
pcm {
type hw
card x
device y
}
}
}

11. Reboot is required and you should get sound in all applications afterwards πŸ™‚

4. Installing Xbox Media center (XBMC)
First of all, visit Xbmc.org download page for the latest info. This guide handles the Jaunty installation only.

This is collected from the XBMC Wiki:
Adding the XBMC Repo tells your system where to look for xbmc for installation and future updates
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Enter: echo “deb http://ppa.launchpad.net/team-xbmc/ppa/ubuntu/ jaunty main” | sudo tee -a /etc/apt/sources.list.d/xbmc.list
3. Enter: sudo apt-get update
4. Enter: sudo apt-get install xbmc
5. Enter Y for any questions
(Ignore the key nagging. If you care, import the PGP key by reading the Wiki above)

After installation is finished you’ll find XBMC in Applications -> Sound & Video

4.1 Using VDPAU as your player in XBMC
In XBMC go to: Settings -> Videos -> Players -> Rendering
Change rendering to VDPAU

4.2 Testing the player
Download some 720/1080p *.mov files from Apple
Try different formats from here: http://www.bigbuckbunny.org/index.php/download/

5. Installing LIRC (Linux InfraRed Control)
This guide is based on a simple MCE remote bought from eBay. It should have a on/off button + a Windows logo button in center. If you have different receivers you could find others that works with another default setup.
1. Open a terminal (Applications -> Accessories -> Terminal)
2. Enter: sudo apt-get install lirc
3. In the “Configure lirc” window select: “Windows Media Center Remotes (old version Microsoft USB ID)” using navigationkeys.
4. Select “None” on transmitters
5. Test LIRC by running command: irw (send IR-signals with your remote, they should be printed to the screen)

If you encountered problems you can start all over by running command: sudo dpkg-reconfigure lirc
Restart LIRC by running command: sudo /etc/init.d/lirc restart

If irw works then, IR should work in XBMC also πŸ™‚ Notice the name of the remote it should be mceusb. (If not check the Lircmap.xml if it is default supported).
If you want to reconfigure the buttons in XBMC enter: sudo nano /usr/share/xbmc/system/Lircmap.xml

Last tip:
If you have an iPhone and don’t like the idea of spending time setting up LIRC, download the XBMC Remote

    What is next…
    A new guide! It will explain suspend-to-ram and how to manage LIRC after a suspend (IR-gone missing).
    Irxevent scripts and common start/stop/reboot scripts for XBMC will also be included + desktop navigation with the IR-remote.
    Read all about it here

Please write comments regarding errors and other ways todo stuff quicker πŸ˜‰