Posts Tagged 'Command line'

Controlling your media player

In my previous post, I promised I’d show how to control your media player to skip to the next song when you press a combination of keys. Admittedly, I should’ve posted this earlier (especially since it’s not that big a post), but better late than never, isn’t it?

The basic idea is that you can run a command with so-called arguments. Most (if not all) media players on Linux also take arguments to skip to the previous or next song in your playlist, or to play/pause the current track. This is extremely useful if you just want to listen to music without the program you use to play it bothering you.

You know how to find the command of your media player (I explained it in Your wish is Xubuntu’s command). My media player is Exaile, the command of which is “exaile”. This is what I’ll be using in this post, but you can replace it by the command of your preferred media player.

To find out which arguments a program takes, you have to resort to a terminal window (Applications->Accessories->Terminal). From there, you can read a program’s manual by typing man <command>, so I’d use man exaile:
Exaile's man page
You can read through it by using the arrow keys and exit the manual by pressing “q” (so “Esc” won’t work!).

Some programs don’t have a manual, but if they don’t, they mostly take the --help argument, which gives you an overview of all other arguments available. I’d use exaile --help:
exaile --help

As you see, Exaile supports both of these commands. It doesn’t really matter which I use, both tell me I can skip to the next song with the --next argument (or -n), to the previous one with --prev (or -p), and play/pause (depending on its current state) with --play-pause (or -t, from toggle).

Knowing that, I opened up the Keyboard Settings (Applications->Settings->Keyboard Settings) and in the Shortcuts-tab I set the commands exaile --prev, exaile --play-pause and exaile --next to some keyboard shortcuts. I could then control Exaile using my keyboard! Now, every time I start Exaile I minimize it to the system tray so that it would just be an icon in my panel. Using the “LibNotify Plugin” I get a notification which song I skip to, making my media player as unobtrusive as possible:

Xubuntu Feisty just installed - Cool, integration!

Customisations like this are the reason I love using Xubuntu – it adapts to you instead of the other way around. It are these little things that makes using a computer just that extra bit more pleasant.

Your wish is Xubuntu’s command

I remember well how a friend of mine proudly showed me that he could easily launch Internet Explorer using a special key at the top of his keyboard. Today, I know that with Xubuntu, I can use my regular keys (and cheap keyboard 😉 ) to launch any program. Inspired by this article I decided to share this trick with you.

How it works? Simple. As you might know, a program on Linux is started when a command is executed. A command is executed e.g. when you type it in the terminal, but also when you click a menu entry in your applications menu. In Xubuntu, you can assign these commands to certain keyboard shortcuts, so that when you press the set key combination, the specified command will be executed.

Of course, in order to assign a command to a keyboard shortcut, you need to know which command you need. In order to find this, you can use Xfce’s Appfinder, which you can find in the Applications menu under Accessories.

Xfce4 Appfinder's default screen

Using the “Search:” box on top, you can find the program you need the command of. I wanted to find “Warzone 2100”, so I entered that and pressed “Enter”. It then showed up in the list. To find the command, I right-clicked Warzone 2100’s entry and selected “More Information…”:

View a program's information

As you can see, Warzone 2100’s command is, surprisingly, warzone2100.

I then fired up my keyboard settings from Applications->Settings->Keyboard Settings. On top, I selected the “Shortcuts” tab. The first time you want to add keyboard shortcuts, you need to create a new “Theme” using the left Add button. As you can see, I created the theme “Examples”, and had created the theme “Vincent” before.

Keyboard settings

Then using the right “Add” button you can assign a new command so a certain keyboard shortcut. I could’ve used Warzone 2100 here, but I used xflock4 because this command is not one you’d find with the Appfinder and I personally use it a lot. As you might guess, this command locks the screen (i.e. starts your screensaver).

Adding a command

After I clicked OK I was prompted for the command I wanted to use.

Setting a shortcut

As I like to use my left “Ctrl” key in combination with the “0” in the numpad on the right, I entered that. And that was it! I could now use that key combination to lock my screen!

The shortcut is added!

Admittedly, the “Keyboard Settings” window is not very user-friendly, and yes, the creation of themes sounds a bit useless to me to, but at least it works. You can use the same procedure to add a keyboard shortcut for all your favourite programs. For example, I used this to assign Ctrl+F12 to the command “firefox” which will, not surprisingly, open Firefox. So by combining with the Ctrl key, I already have 12 possible special keys on top of my keyboard!

In my next post I’ll show how to control your media player to skip to the next song when you press a combination of keys. Stay tuned!


a