Guide: Hotkeys Ftw


Joined
May 17, 2010
Messages
2,198
Location
:|
You enjoying XFCE? It's pretty posh huh? As nice as it is, XFCE was always designed with a mouse in mind. Working the menu or Desktop on the Pandora can be a pain. Well... what if you could launch applications from a keyboard shortcut? Would that help cut down all the unnecessary muscle movement huh?

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:

/usr/share/applications

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.

Hit okay.

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:

Code:
#!/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:

Code:
#!/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)

Code:
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):

Code:
./pnd_find PNDNAMEHERE.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:

Code:
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 './'

Code:
pnd_find PNDNAMEHERE.pnd

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. B)
 
Gruso said:
Great work on these guides! I hope you're cool with being blogged some time. :)

Yay!

I'd quite like to do these with screenshots, maybe you could host them on Pandorapress?

IIRC the board doesn't support making posts with lots of pictures. Also, I need to install/compile one of the screenshot utils and get it running. That, or I bug Stuckie to add the screenshot support in The Gimp.
 
Last edited by a moderator:
SomeGuy99 said:
Code:
#!/bin/bash
#Finds a PND based on given argument and launches it!

pnd_run `find /media -name $1 -print`
Just so you know, find will need to search through all of external storage before it exits. It might take a while and be very power-inefficient if you have something like a 500GiB external HDD attached :p. Somebody could write a little C app to give out the path to a pnd using libpnd etc (using the right search path specified in the config).
 
Last edited by a moderator:
urjaman said:
SomeGuy99 said:
Code:
#!/bin/bash
#Finds a PND based on given argument and launches it!

pnd_run `find /media -name $1 -print`
Just so you know, find will need to search through all of external storage before it exits. It might take a while and be very power-inefficient if you have something like a 500GiB external HDD attached :p . Somebody could write a little C app to give out the path to a pnd using libpnd etc (using the right search path specified in the config).

Good point about the external hard drive. I only use USB thumbdrives in my slot personally.

You could modify the find path to /media/mmcbl* and it would only search the SD card slots?

Okay, I updated to add your suggestion. Thanks. :)
 
Last edited by a moderator:
Hi, I just did a NAND flash for the latest OS image that Ed posted a little while ago.
Now when I setup my shortcuts none seems to work, although the key combinations seem to be correct according the the keyboard settings table.

Any way to fix this?

Sorry...but i am a linux newbie, but I can totally rock the terminal if you tell me exactly what I should type! :)
 
SomeGuy99 said:
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.

Hmm, I can't seem to be able o right-click a menu item, it always select the item instead of opening a menu, I tried even with VNC and a mouse, but had the same problem.
 
Last edited by a moderator:
SomeGuy99 said:
Are you right clicking the icon?

Doh, I was trying to click directly on the menu, I skipped the part that said "navigate to /usr/share/applications"!
 
Last edited by a moderator:
Changing it to scan /media/*/pandora/* instead might be a good idea, it will still work properly and there will be less to scan.
EDIT: Of course assuming the default .pnd scan folders are not changed, but I imagine most people are fine with the defaults.
 
I followed this guide to add a wifi toggle hotkey now that I have my Pandora, I followed the guide correctly, and I double checked the entry in the keyboard manager but nothing happens when I press the hotkey. :S
Same thing also happened with the screenshot guide, the screenshot command works fine but the hotkey does nothing.
 
Jdbye said:
I followed this guide to add a wifi toggle hotkey now that I have my Pandora, I followed the guide correctly, and I double checked the entry in the keyboard manager but nothing happens when I press the hotkey. :S
Same thing also happened with the screenshot guide, the screenshot command works fine but the hotkey does nothing.

Hmmm. Are you in full XFCE? It doesn't work under minimenu.

Double check the listed keyboard shortcuts in the keyboard settings. What does it say? There should already be some entries for the default ones.
 
Last edited by a moderator:
SomeGuy99 said:
Jdbye said:
I followed this guide to add a wifi toggle hotkey now that I have my Pandora, I followed the guide correctly, and I double checked the entry in the keyboard manager but nothing happens when I press the hotkey. :S
Same thing also happened with the screenshot guide, the screenshot command works fine but the hotkey does nothing.

Hmmm. Are you in full XFCE? It doesn't work under minimenu.

Double check the listed keyboard shortcuts in the keyboard settings. What does it say? There should already be some entries for the default ones.
There's 2 i added:
/usr/pandora/scripts/pnd_run.sh -p "/usr/pandora/apps//pandorascripts.pnd" -e "op_wifi.sh" -b "op_wifi", which I assigned to Shift+Control+W
screenshot, which I assigned to Shift+Control+S (I called the script screenshot instead of snapsnap)
Both from your guides :p

The other entries are:
xflock4 assigned to Ctrl+Alt+Del (doesn't work, but I have to press Shift+Backspace to get Del and the keyboard manager recognizes that as Shift+Backspace, not Del)
xfrun4 assigned to Alt+F2 (doesn't work either)
xrandr --auto, assigned to XF86Display (I have no idea how to trigger that :p )

None of them work, I wonder if it broke in a hotfix.
EDIT: And yes, I'm using XFCE, and followed the "Making XFCE Sexy" guide earlier today, it looks awesome now :)
 
Last edited by a moderator:
I have absolutely no idea. I guess something somewhere is broken?

This sounds above my abilities to be honest. We'll need to rope in an expert of higher order :D

Okay, I have one idea:

Try making a new Linux account, and try making some keyboard shortcuts there. If they work in that account, then we have a configuration conflict somewhere in your current profile.

I can't test anything myself unfortunately, as I don't have a working Pandora to hand.
 
SomeGuy99 said:
I have absolutely no idea. I guess something somewhere is broken?

This sounds above my abilities to be honest. We'll need to rope in an expert of higher order :D

Okay, I have one idea:

Try making a new Linux account, and try making some keyboard shortcuts there. If they work in that account, then we have a configuration conflict somewhere in your current profile.

I can't test anything myself unfortunately, as I don't have a working Pandora to hand.
Nope, it's a no go :(
Weird that it seems I'm the only one with this issue, I haven't done anything drastic that would break the hotkeys.
 
Last edited by a moderator:
Jdbye said:
SomeGuy99 said:
I have absolutely no idea. I guess something somewhere is broken?

This sounds above my abilities to be honest. We'll need to rope in an expert of higher order :D

Okay, I have one idea:

Try making a new Linux account, and try making some keyboard shortcuts there. If they work in that account, then we have a configuration conflict somewhere in your current profile.

I can't test anything myself unfortunately, as I don't have a working Pandora to hand.
Nope, it's a no go :(
Weird that it seems I'm the only one with this issue, I haven't done anything drastic that would break the hotkeys.

We need someone with more expertise then. Any ideas?

Post this in the help forum and see who answers maybe?
 
Last edited by a moderator:
SomeGuy99 said:
Jdbye said:
SomeGuy99 said:
I have absolutely no idea. I guess something somewhere is broken?

This sounds above my abilities to be honest. We'll need to rope in an expert of higher order :D

Okay, I have one idea:

Try making a new Linux account, and try making some keyboard shortcuts there. If they work in that account, then we have a configuration conflict somewhere in your current profile.

I can't test anything myself unfortunately, as I don't have a working Pandora to hand.
Nope, it's a no go :(
Weird that it seems I'm the only one with this issue, I haven't done anything drastic that would break the hotkeys.

We need someone with more expertise then. Any ideas?

Post this in the help forum and see who answers maybe?
I copied the latest rootfs to a SD card and booted from it, and... hotkeys work! So it seems there actually was something broken in the OS rev I was using, which was the one in the flashkit in the Support section on openpandora.org.

EDIT: s/flashed/copied
 
Last edited by a moderator:
Jdbye said:
SomeGuy99 said:
Jdbye said:
SomeGuy99 said:
I have absolutely no idea. I guess something somewhere is broken?

This sounds above my abilities to be honest. We'll need to rope in an expert of higher order :D

Okay, I have one idea:

Try making a new Linux account, and try making some keyboard shortcuts there. If they work in that account, then we have a configuration conflict somewhere in your current profile.

I can't test anything myself unfortunately, as I don't have a working Pandora to hand.
Nope, it's a no go :(
Weird that it seems I'm the only one with this issue, I haven't done anything drastic that would break the hotkeys.

We need someone with more expertise then. Any ideas?

Post this in the help forum and see who answers maybe?
I flashed the latest rootfs to a SD card and booted from it, and... hotkeys work! So it seems there actually was something broken in the OS rev I was using, which was the one in the flashkit in the Support section on openpandora.org.

Ah. Strange!

That's Linux for you - stuff breaks for no obvious reason :)
 
Last edited by a moderator:
SomeGuy99 said:
Jdbye said:
SomeGuy99 said:
Jdbye said:
SomeGuy99 said:
I have absolutely no idea. I guess something somewhere is broken?

This sounds above my abilities to be honest. We'll need to rope in an expert of higher order :D

Okay, I have one idea:

Try making a new Linux account, and try making some keyboard shortcuts there. If they work in that account, then we have a configuration conflict somewhere in your current profile.

I can't test anything myself unfortunately, as I don't have a working Pandora to hand.
Nope, it's a no go :(
Weird that it seems I'm the only one with this issue, I haven't done anything drastic that would break the hotkeys.

We need someone with more expertise then. Any ideas?

Post this in the help forum and see who answers maybe?
I flashed the latest rootfs to a SD card and booted from it, and... hotkeys work! So it seems there actually was something broken in the OS rev I was using, which was the one in the flashkit in the Support section on openpandora.org.

Ah. Strange!

That's Linux for you - stuff breaks for no obvious reason :)
Indeed... because they stopped working after I rebooted. If i add new ones they'll work until I reboot again. I'm pretty sure they never worked previously, so at least it's one step forward.
EDIT: Aaaand they're working again :blink:
 
Last edited by a moderator:
Jdbye said:
Indeed... because they stopped working after I rebooted. If i add new ones they'll work until I reboot again. I'm pretty sure they never worked previously, so at least it's one step forward.
EDIT: Aaaand they're working again :blink:

I think this is something to talk to Ed, Skeezix etc. about. It must be something new in the firmware (which I haven't been able to test).
 
Last edited by a moderator:
Back
Top