Alright then, let's do it!
This guide is broken up into three parts:
Part 1 - Intro to XFCE keyboard shortcuts
Part 2 - How to hotkey a firmware application
Part 3 - How to hotkey a PND file (dynamically)
Part 1____Intro to XFCE Keyboard Shortcuts_______________________
Open up XFCE settings (settings->XFCE 4 Settings Manager)
Click on 'Keyboard'
Select the 'Application Shortcuts' tab
The window is too large for the Pandora resolution. Hold down shift (shift key or left shoulder button) and drag the window upwards. You can drag by clicking anywhere on the window.
Our First Keyboard Shortcut
For the first example, let's shortcut the keyboard config panel (the one you are using) to a key combination. This will make adding more shortcuts later far easier!
Click on 'add'
The popup now prompts for a command.
In Linux, commands and programs are the same thing - all commands are actually small programs. This idea comes from Unix (of which Linux is a clone of) with the idea that the operating system can be organically grown and programs can use it each other to accomplish bigger tasks.
In the box enter 'xfce4-keyboard-settings' (without the quotes) and select 'OK'.
Now we need to map a key combination! It's a good idea to use obscure combinations that won't already be used by your applications.
My suggestion is 'ctrl-alt-k'.
Just press the key combination you wish. The entry is added into the list.
Test the hotkey by closing the keyboard settings window and pressing your key combination. Did it work?
Add some more. Try these suggestions:
'Thunar' - ctrl-alt-f (this will open up a file manager window)
'Terminal' - ctrl-alt-t (this will open up a terminal window)
Part 2____How to hotkey a firmware application_______________________
We'll be using the same process as above, but we need the (sometimes complex) command strings associated to the menu or desktop entries.
These command strings can be found within .desktop files on the system.
What's a .desktop file? Very similar to a shortcut icon on a Windows system. They can be placed on the menu or desktop, and contain additional information for menu category (in Windows you do this with subdirectories in the start menu folder, but Linux uses metadata to achieve the same thing).
Our firmware apps have entries on the menu. The .desktop files for menu apps can be found in:
Where is this?! /usr/share is a folder for shared data between users (Linux is multi user orientated). For example /usr/share/icons and /usr/share/themes which are accessed by anyone on the system.
Navigate to /usr/share/applications in Thunar (try out your Thunar hotkey if you made one!) You will need to start from 'file system' to get there.
You can see all the menu entries here. Find the one you want and double click it. Is it the one you were after? If so then close the application. If not, keep searching till you find it.
Examples: Wifi and CPU overclock
For this example we're gonna map the wifi toggle and cpu overclocking utility. High five? Not yet? okay.
Scroll down till you find 'Wifi Toggle'
Now right-click (hold down with stylus, or push right with nub) and from the menu choose 'properties'.
Click on the 'Launcher' tab.
See the box where it says 'command'? Select all of the text in that box and select 'copy' (double click on the text to highlight it all. Easiest way to copy when using the stylus is to press ctrl-c).
Now bring the keyboard settings again (did you map it like I said? Ha! This is where the lazy people lose out. I bet you map it now, if you didn't before!).
Add a new keyboard shortcut like before.
In the command box, paste the long string we took.
Enter a obscurish keyboard shortcut. I recommend ctrl-alt-w.
All done! High five? You betcha!
Part 2____How to hotkey a PND file (dynamically)_______________________
This is the same proccess as before, but with some complications. You ready to do some shell scripting? Hey! Don't gimme that face! It's not so scary really.
What makes it complicated?
PND files can be launched by using the command 'pnd_run NAMEOFPNDHERE'. The problem is that PND files are likely to move around in the filesystem.
Move around? Huh? Well... Linux (like Unix before it) stores all external drives within the file system heirachy. Whereas Windows will have a C drive (with your OS and all files) and a D, E, F and so on... Linux will just add it as a virtual folder in /media. Imagine if instead of having an E: drive, Windows just mapped it to a folder called 'drive_e' on your C: drive? That's kind of how Linux does it!
We can't rely on fixed paths for our PND files, that would be keeping them hostage! You'd never be able to swap the cards over or move the PND to another location without the shortcut breaking.
For this we need some shell scripting magic!
Shell Scripting Magic
Open up Mousepad.
Type in the following:
#!/bin/bash #Finds a PND based on given argument and launches it! pnd_run `find /media -name $1 -print`
Be aware that those little marks are not apostrophes. To type them press function-h. The difference is very important, and the script will fail without them.
What does this actually do? You run this script like any command. You supply it with the name of a PND somewhere on your system (including SD card slots and usb drives) and it will find it, then launch it.
Let's break down what the script does.
'#!/bin/bash' - This just tells Linux that this is a script. '#' means the rest of that line is never executed and is used for comments. You see how I added a desciption on the next line'?
'pnd_run' - This is the Pandora command for running a PND file. The second part after this command needs to be the name of a PND file (either in the current directory or you supply a fixed path).
` ` <- anything between this is processed first, then given to the command before it. The script inside these gives the location of the PND file we are looking for - it is then give to pnd_run. It's a lot like in algebra where you have to work out the sums within brackets first.
find - A Linux command to scan for files. We are suppling it with the following:
/media - The location to start the scan. /media is where all the external media are mapped in Linux. Our PND files will be on SD card etc.
'-name' - Tell 'find' to match all or part of a filename
$1 - This is the first peice of information (or 'argument' in programmer jargon) given to our script (so for example, our script will be called 'pnd_find'. If you execute the command 'pnd_find Exaile.pnd' the value of $1 will be 'Exaile.pnd')
'-print' - Output the results in text format!
NOTE: This will search all inserted media. It works pretty fast, but may take a while if you have a huge disk attached to the USB (eg. 500gb). If you only want to search the two memory card slots, use the following script instead:
#!/bin/bash #Finds a PND based on given argument and launches it! pnd_run `find /media/mmcbl* -name $1 -print`
The SD cards are location in /media/mmcblBLAHBLAH. The asterix is known as a 'wild card' and just means 'anything and everything'. It's like the blank letter in a Scrabble set. We're asking it to use any directory starting with '/media/mmcbl'.
Saving and Installing our Script
Save the file as pnd_find.sh in your home folder (or SD card, whatever you wish!).
We are giving it an .sh extension for our own benefit, so we know this is a shell script.
Now open a terminal (Did you make the keyboard shortcut?). You can navigate to the folder in Thunar and right-click 'Open Terminal Here'.
If you saved it to your home folder, the terminal starts there by default. If not, go to your home folder by typing in 'cd' and hitting enter.
We need to add permissions for this script to become executable. At the moment it isn't, which is a security feature in Linux/Unix.
Type the following in and hit enter (change the name to your shell script name if you chose another)
sudo chmod ugo+rwx pnd_find.sh
What does this do? Well firstly sudo enables you to peform admin tasks while not logged in as an admin (or root). Sudo stands for 'superuser do' and means that any admin action requires a password. If any random script wants to do bad things, like delete files on your base OS, it will need to very politely ask for a password first!
Chmod stands for 'Change Mode' and changes the permissions of the file. This includes who can use it and how.
'UGO' means we want to change the file to be accessible for this user (U), any member of this users group (G) and anyone outside the users group (0 - other).
'+' means we want to add this permission, as opposed to take it away. We want to switch it on or make it positive. Think of it like a tick in a tickbox.
'RWX' - We are adding permissions for reading ( r ) writing (w) and executing as program (x).
If you want to test your script now, type in the following (add the exact, case sensitive name for the PND):
'./' just means your present directory
Did it launch the program? Try double checking the exact name of your PND file (Linux is case sensitive). It might not work if you have more than one with an identical name. Check that you didn't use aposotrophies by accident in the script.
If it till doesn't work, post a comment in this thread.
Now you want to install this script as a system program/command.
Type in the following and hit enter:
sudo cp pnd_find.sh /usr/bin/pnd_find
/usr/bin is where commands live. Once you put it here, the script can be run as a command anywhere on the system!
Test it out by typing the same as above but without the './'
If that works, then we're seriously cooking!
Go back to the keyboard settings and add it. In the command box type 'pnd_find PNDNAMEHERE.pnd'.
Try swappng the memory cards around. It should still work (does for me).
Thanks for reading this far. High five to the max?
If you're reading this sentence you owe me a beer.
Edited by SomeGuy99, 15 June 2010 - 08:22 PM.