Archive

Archive for the ‘linux’ Category

Using Spotify Links in Linux

I’ve yet to officially start my tutorials on Linux, but I’ve been playing around with Spotify recently and I’ve been annoyed by the problem of getting Spotify playlists to load from my web browser directly into Spotify. For those who don’t know about Spotify, I suggest you read my previous post, and if you still want invites, I am getting them on a daily basis, so please apply. Spotify playlists can be shared easily in the form of a link, and there have been several websites set up to publish these links. The problem of using these links in Linux consists of two issues:

  1. Getting the browser to recognize a Spotify link (in the form: spotify:user:jacken:playlist:5CUB76CWjf2vFxZymgO3cW).
  2. Getting the browser to execute the link as an argument on a program running through wine, the Linux windows compatibility layer.

The first problem can be solved quite easily in Firefox, but it does involve messing around with the configuration a bit. Open a new tab, type “about:config” (without the quotes) and press enter. If you are running a recent version of Firefox, you should click the button accepting the “this might void your warranty” message. Right click anywhere on the page (which should have filled with a table of options) and create a new boolean. In the preference name box, type “network.protocol-handler.external.spotify” (again without quotes), and then choose the value true for the option. This has now enabled the spotify protocol in Firefox, meaning that whenever the browser is sent a request to open something with the prefix spotify: it will ask the user what to do with the request. Of course, the 2nd problem is getting Firefox to communicate to a program that does not run natively within Linux. To bypass this, we can create a simple script that Firefox can execute. The script will then do all the complicated bits that Firefox can’t do. Open up a terminal, and execute this command:

cd ~/.wine/drive_c/Program\ Files/Spotify/

If you have installed wine with default settings, this is where all the Spotify files are located. Otherwise, you will have to modify the command to cd you into the correct Program Files directory. Once in the directory, you should find two files, spotify.exe and Uninstall.exe (use the ls command to check). Create a file called “spotify.sh” in this directory, and edit it with your favourite text editor. Copy and paste the following into the file:

1
2
#!/bin/bash
wine "$HOME/.wine/drive_c/Program Files/Spotify/spotify.exe" /uri "$1"

Save the file and exit the text editor. What does this code mean? Well, the first line (known as a sha-bang!) tells the system what type of file our script is, and which interpreter to use when executing it. In this case, we want to run the script through the bash shell, so we give it the location of bash on the system (which is 99.9999% always /bin/bash, but you can find out by typing which bash into a terminal and alter accordingly). The next line is the command we want the script to execute, which calls on wine to run spotify.exe file with the argument /uri and the link url given by Firefox when executing ($1). $HOME is simply a shell variable that stores your home directory location (usually in the form: /home/username). Now all you have to do is make the file executable:

chmod +x spotify.sh

Now try it out on a spotify link! If spotify is already open, the playlist should appear on the left, otherwise spotify will open up and display the playlist for you. When you click on the link, Firefox should ask you what you want to do with it, and all you have to do is select the spotify.sh file we just wrote. If it doesn’t ask when you click on a link, you will need to go into Edit -> Preferences -> Applications and find “spotify” in the list, then select the file using the “use other” action.

Categories: linux, personal Tags: , , , ,

Linux Tutorials?

Regular blog readers will know that I use Gentoo Linux as my main operating system, and people who stalk me on facebook will know that I am an Open Source advocate. So I’ve been throwing this idea around in my head for a while, because I know that some of my fellow bloggers use Linux or at least have tried it out. The idea is for me to write a series of blog posts about Linux, how you can get it, set it up, make it suited to your tastes, etc.

In addition to the tutorials, I would offer support to people who are following along and run into problems (it’s bound to happen with any OS change). The main gist of the posts would be to inform, perhaps dispel a few myths, and generally help people out on certain issues. The reason I want to do this now is because obviously I am very passionate about Linux and the free software community, but also because I am approaching the end of term, and I’ll have free time on my hands.

I’m not promising the learning curve won’t still be steep, but my hopes are that people will respond a bit better if they have posts aimed at the average user, without all the techobabble. There are also no promises that everything I say will be entirely accurate, or the “best way” to go about things. The beauty of Linux is that nobody can ever learn everything there is to know about it; it’s a group effort. Naturally when I am corrected on something I will hasten to edit the post. The same goes for when people ask questions about the tutorials; I want to make the posts as accurate and understandable as possible.

Ubuntu logo
Image via Wikipedia

The tutorials will cover the Ubuntu operating system (which is what I started out with) due to its ease and stability in comparison with others. However for the most part, people should be able to follow along using any of the major distros, such as Fedora or OpenSuse. For the first few tutorials I will be covering installation and how to set up your system to work for you. I will then move onto the more complex areas, including how (and when) to effectively use the command line.

So all I really need now is feedback on the idea. How many of my readership would be interested in learning about Linux? I’m not going to stop posting about atheism / religion, but it wouldn’t be a personal blog if I didn’t share my hobbies with everyone :D.

The Atheist Blogger