Author Topic: Creating keybindings in Openbox  (Read 3732 times)

0 Members and 1 Guest are viewing this topic.

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Creating keybindings in Openbox
« on: September 08, 2012, 04:57:09 am »
Hello Evilzoners. I'm going to write a real brief tutorial on editing keybindings in Linux.


                                                Let's Get Started



Many of you probably know how to do this. Some of you may be wondering why I would waste mine and your time on such a simple thing. Well, depending on your WM or DE it may not be so obvious. This tutorial is for those new to Linux.


Gnome- In Gnome this is very easy. This can be done through the Gnome Control Center.


KDE - Editing keybindings can be done in the System Settings


XFCE4 - Like most other flashy distros, this can be done in Keyboard settings.


Openbox - The real reason I wrote this is to show you how to edit keybindings in Openbox. In order to edit keybindings in Openbox you need to edit the ~/.config/openbox/rc.xml config file.


                                               Creating a Keybinding



In order to add a keybinding to ~/.config/openbox/rc.xml you must scroll down to where it says <keyoard> Creating a keybinding via config files is really quite simple. The basic format goes like this:


Code: [Select]
<keybind key="">
  <action name="">
     <command> </command>
  </action>
</keybind>

For example, if you wanted to make a new keybind to open up the terminal using the Super key(Windows key, Meta key)and the the T key your format would look like this:

Code: [Select]
<keybind key="W-t">
  <action name="Execute">
    <command>terminal</command>
  </action>
</keybind>

The W key stands for the Super-or Window-key. Let's try another example:

Code: [Select]
<keybind key="C-S-z">
  <action name="Execute">
    <command>urxvt</command>
  </action>
</keybind>

The C key stands for Ctrl and the S stands for Shift. Likewise, you can use A for Alt. So for this you would hold Ctrl-Shift and then press z. Other keys such as F1, Escape, Tab and any numbers you would just enter in as they are. The <command> is the command that you would otherwise enter in to the terminal to execute. If you want to find some commands you can go to your file system and look in /usr/share/applications then right click on an application and go to the launcher tab. The command will be there. For you lazy people:

Code: [Select]
<keybind key="S-5">
  <action name="Execute">
    <command>firefox</command>
  </action>
</keybind>

That makes it so all you have to do is hold shift and press 5 and it opens firefox. You could even create a keybinding that opens firefox to a specific website!

Code: [Select]
<keybind key="C-A-f"
  <action name="Execute"
    <command>firefox evilzone.org</command>
  </action>
</keybind>

Also be sure to reconfigure openbox otherwise the keybinding won't work. Other actions you could do include things like showing a menu.

Code: [Select]
<keybind key="A-r">
  <action name="ShowMenu">
    <command>root-menu</command>
  </action>
</keybind>

This keybind will open up you Openbox menu so you don't have to have your cursor over the desktop and right click to see it.

                                                      Conclusion



Many new linux users find editing config files daunting. I assure you that it is very simple. Always be sure to double check your changes before saving and Don't Change Anything If You Don't Know What It Does!! Always ask google.

Well, I never know how to conclude these things. So, thanks for reading. I understand this may be very mundane information to many users, but I figured this was one of those things a lot of new guys are afraid to ask. Keybindings definitely make your linux experience a faster smoother experience.

  "We will encourage you to develop the three great virtues of a programmer: laziness, impatience, and hubris." Larry Wall, Programming Perl
« Last Edit: September 08, 2012, 06:21:30 am by lucid »
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline namespace7

  • Sir
  • ***
  • Posts: 561
  • Cookies: 115
  • My Brother's Keeper
    • View Profile
Re: Creating keybindings in Openbox
« Reply #1 on: September 08, 2012, 12:20:32 pm »
Well written tutorial that explains the subject quickly and efficiently.
Keep it up mate.

+1
"A programmer’s greatest enemy isn’t the tools or the boss or the artists or the design or the legacy code or the third party code or the API or the OS. A programmer’s greatest enemy is getting stuck.
Therefore a crucial step to becoming a better programmer is learning how to avoid getting stuck, to recognize when you’re stuck, and to get unstuck." -Jeff Wofford

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Creating keybindings in Openbox
« Reply #2 on: September 10, 2012, 01:19:44 am »
Thanks for the feedback. A true evilzoner has a keybinding that opens up their browser to evilzone.org.  ;) More tutorials to come.
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline iTpHo3NiX

  • EZ's Pirate Captain
  • Administrator
  • Titan
  • *
  • Posts: 2920
  • Cookies: 328
    • View Profile
    • EvilZone
Re: Creating keybindings in Openbox
« Reply #3 on: September 10, 2012, 11:01:57 am »
Thanks for the feedback. A true evilzoner has a keybinding that opens up their browser to evilzone.org.  ;) More tutorials to come.

I have this feature in my browser called a homepage, works pretty well and is real straight forward to set up lol
[09:27] (+lenoch) iTpHo3NiX can even manipulate me to suck dick
[09:27] (+lenoch) oh no that's voluntary
[09:27] (+lenoch) sorry

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Creating keybindings in Openbox
« Reply #4 on: September 10, 2012, 07:08:51 pm »
Well whatever I thought it might be interesting to someone.
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline kateus

  • Peasant
  • *
  • Posts: 89
  • Cookies: 11
  • scientia potentia est
    • View Profile
Re: Creating keybindings in Openbox
« Reply #5 on: September 10, 2012, 08:38:02 pm »
Thanks. I just installed a new OS yesterday that uses openbox, this has helped me quite a bit :).

+1

th3g00n

  • Guest
Re: Creating keybindings in Openbox
« Reply #6 on: September 10, 2012, 09:30:27 pm »
In windows do I have to mod the registry?

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Creating keybindings in Openbox
« Reply #7 on: September 10, 2012, 09:35:29 pm »
I believe that you could use something like SharpKeys or a similar program. Otherwise I think the registry is your only option. I don't really know I don't use windwoes
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline namespace7

  • Sir
  • ***
  • Posts: 561
  • Cookies: 115
  • My Brother's Keeper
    • View Profile
Re: Creating keybindings in Openbox
« Reply #8 on: September 10, 2012, 09:44:52 pm »
In windows do I have to mod the registry?
This is slightly off topic but here we go:

You don't need to do anything to the registry.
I have not used Windows in some time, but if my memory serves me right this is how you can assign a shortcut key on windows:
- Create a shortcut (right click on a file, and choose "Make Shortcut") of whatever executable you want to make a shortcut key for (for example a web browser .exe file or a .bat script or anything other that can be executed by the OS).
- Rename and paste the generated shortcut to any location.
- Right-click on the shortcut file and choose "Properties".
- Under the "Shortcut" tab, click on the "Shortcut key" field and press a button that you want to assign.
- Now you can launch the shortcut by pressing Ctrl+Alt+yourLetter.

Should work.
"A programmer’s greatest enemy isn’t the tools or the boss or the artists or the design or the legacy code or the third party code or the API or the OS. A programmer’s greatest enemy is getting stuck.
Therefore a crucial step to becoming a better programmer is learning how to avoid getting stuck, to recognize when you’re stuck, and to get unstuck." -Jeff Wofford

th3g00n

  • Guest
Re: Creating keybindings in Openbox
« Reply #9 on: September 10, 2012, 10:19:19 pm »
^^^This is a crazy option. I mentioned the registry because i was reading a book about it.

Offline namespace7

  • Sir
  • ***
  • Posts: 561
  • Cookies: 115
  • My Brother's Keeper
    • View Profile
Re: Creating keybindings in Openbox
« Reply #10 on: September 10, 2012, 10:43:56 pm »
^^^This is a crazy option. I mentioned the registry because i was reading a book about it.

You can modify the registry to tune up and change the default behavior of your system, but modding the registry to make a shortcut key is an overkill.
By the way, don't forget to remove the key shortcut from the file before deleting it :)

NOTE TO GMOD/ADMIN: This got off topic, could you please cut this thread in half, and move everything from th3g00n's question post to this post into a new thread titled "How to assign a shortcut key to a program on Windows" under the appropriate section (would this fall under Operating Systems)?
« Last Edit: September 10, 2012, 10:45:16 pm by namespace7 »
"A programmer’s greatest enemy isn’t the tools or the boss or the artists or the design or the legacy code or the third party code or the API or the OS. A programmer’s greatest enemy is getting stuck.
Therefore a crucial step to becoming a better programmer is learning how to avoid getting stuck, to recognize when you’re stuck, and to get unstuck." -Jeff Wofford

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Creating keybindings in Openbox
« Reply #11 on: September 12, 2012, 09:37:22 pm »
I'm going to add a slight bit of info on customizing the Openbox menu, just to make this silly tutorial a bit more useful. I would go through all of customizing it but honestly, that's what obmenu is for. I noticed that one thing obmenu cannot do is add menu headers, or titles, to the menu.

However, it's very simple. You have to edit ~/.config/openbox/menu.xml instead of ~/.config/openbox/rc.xml.

It's very easy to see where the menu starts in the config file. So locate the top of the menu(or really anywhere you feel like adding a title) and add this:

Code: [Select]
<separator label="Hardcorebadassramrodwowmenu"/>

 ;D

"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python