You are not logged in.
I'm trying to get a keybinding to work in Openbox's rc.xml, so that when I press W-XF86Mail it opens a Google documents spreadsheet.
rc.xml:
<keybind key="W-XF86Mail">
<action name="Execute">
<execute>firefox https://spreadsheets.google.com/ccc?key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE&hl=en#gid=3</execute>
</action>
</keybind>
Other keybindings in the same file work fine. But when I reconfigure Openbox I get an error message "One or more XML syntax errors were found while parsing the Openbox configutation files...". After reconfiguration, I press W-XF86Mail and it starts Firefox but opens the wrong URL - the first bit is correct but the last bit reads ...key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE=en instead. As you can see the last bit &hl=en#gid=3 is missing. If I delete the & ampersand then the hash # character seems to cause the same problem. Is there a problem with using the ampersand or hash characters in keybindings?
Last edited by dameunmate (2010-09-04 14:24:50)
Offline
Have you tried escaping the ampersand?
Offline
You can put 'firefox URL' into a script.
Offline
thank for the replies!
how do I escape the ampersand?
and how do I create a script? hmmm.. I should check the WIKI...
Offline
You don't even need a script, just a function in your bashrc would do. It's cleaner than a script as well.
First hit on google for linux escape character.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
You don't even need a script, just a function in your bashrc would do. It's cleaner than a script as well.
Can you integrate it in the current scheme: openbox keybinding?
Offline
As far as i know yes, it just acts like any command (be it script or binary) that's in your $PATH, except that it doesn't need to be in there. It's a bit like a bash builtin.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
thanks. I'm new to Linux, not familiar so looking up .bashrc now...
Last edited by dameunmate (2010-09-02 20:48:30)
Offline
~/.bashrc
This is how your function could look:
gdocspread() {
firefox https://spreadsheets.google.com/ccc?key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE&hl=en#gid=3
}
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
And if I understand correctly, you put it's name (gdocspread) between the <execute> tags:
<keybind key="W-XF86Mail">
<action name="Execute">
<execute>gdocspread</execute>
</action>
</keybind>
Offline
thank you that's very kind of you to write the code for me.
I've tried the above but I press the keys and now nothing happens, firefox does't even start. Here's my entire /home/username/.bashrc:
# Check for an interactive session
[ -z "$PS1" ] && return
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
gdocspread() {
firefox https://spreadsheets.google.com/ccc?key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE&hl=en#gid=3
}
I noticed there's another .bashrc at ./etc/skel/.bashrc - should I be putting the code here instead?
And here's the keybinding in openbox/rc.xml:
<keybind key="W-XF86Mail">
<action name="Execute">
<execute>gdocspread</execute>
</action>
</keybind>
Offline
/etc/skel/.bashrc is a "skeleton file" (something like a template) - you don't touch it. If you want to start anew, _copy_ that file an modify _the copy_
Run
. /home/username/.bashrc
and try again.
Offline
thanks, yes I'm editing /home/username/.bashrc but still no luck (see above)
Offline
An what happens if you run
gdocspread
from the terminal?
Offline
you would most likely need the command to be (if you use urxvt i.e.)
<keybind key="W-XF86Mail">
<action name="Execute">
<execute>urxvt -e gdocspread</execute>
</action>
</keybind>
but that would mean that it would also spawn a terminal instance. You can avoid that by using the urxvt daemon though. OR go back to escaping the & and # in the command.
There's no such thing as a stupid question, but there sure are a lot of inquisitive idiots !
Offline
Calling it with a terminal emulator shouldn't be necessary.
You need to source the .bashrc file before you can use the new function.
Edit: I obviously missed that.
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
Yes I do use urxvt so I've just tried that, and no error messages but after reconfiguring, when I hit the keys I get nothing. But the screen flickers almost as though urxvt opens but the command does nothing and it closes again?
Offline
You need to source the .bashrc file before you can use the new function.
https://bbs.archlinux.org/viewtopic.php … 24#p820224
If OP can't run the command from a terminal, something is definitely wrong.
Offline
Yes I do use urxvt so I've just tried that, and no error messages but after reconfiguring, when I hit the keys I get nothing. But the screen flickers almost as though urxvt opens but the command does nothing and it closes again?
And what happens, if you open urxvt and run gdocspread? Type "gdocspread" (but without the quotes).
Offline
Have you tried escaping the ampersand?
Sorry to repeat myself, but it seems that this would be the simplest approach - either in terms of getting it to work, or ruling out the obvious...
Offline
@B: openbox will just exec() a command, just like urxvt -e. If you need a shell command, you'd have to use
<execute>sh -c 'command'</execute> or
<execute>bash -c 'command'</execute>
But that won't source your .bashrc since it's not an interactive session. (and forget about -i, that'll just freeze openbox ).
@dameunmate: Just use "&" instead of a plain "&". It's the way you write and ampersand in html or xml. Google 'html entities' if openbox complains about other characters in a similar manner.
Last edited by hbekel (2010-09-03 05:11:43)
Offline
thanks for the tips, I've now got the right page to load when I type the command into the urxvt terminal. But it still doesn't work with Openbox keybindings, I edit and reconfigure but press the keys and get no response at all. I've checked and the same keybinding will successfully open other programs and webpages. Here's the keybinding in /home/username/.config/openbox/rc.xml:
<keybind key="W-XF86Mail">
<action name="Execute">
<execute>urxvt -e gdocspread</execute>
</action>
</keybind>
I've also tried <execute>urxvt -c gdocspread</execute> and simply <execute>gdocspread</execute> to no avail. However changing the same keybinding command to <execute>urxvt</execute> does open urxvt successfuly.
So the keybinding will open urxvt, and if I manually open a urxvt terminal and type gdocspread firefox starts on my desired web page. So what's the missing link?
NB: About the ampersand:
For some reason even from the terminal it won't work with the ampersand, but I discovered that I can leave that out as it just defines the language. However for future reference it would be useful to know how to put an ampersand in a URL. This is the code that does load the correct page:
home/username/.bashrc
# Check for an interactive session
[ -z "$PS1" ] && return
alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '
gdocspread() {
firefox https://spreadsheets.google.com/ccc?key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE&hl=en#gid=3
}
Interestingly the URL etc...key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE&hl=en#gid=3 and the URL etc...key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE&hl=en#gid=3 won't load, the URL gets cut off at the ampersand.
Furthermore it's interesting to note that in the above configuration file /home/username/.bashrc only the ampersand causes problems, but in /home/username/openbox/rc.xml both the ampersand and the hash characters cause the URL to be cut off.
Offline
1) I don't think openbox sources your bashrc, that's why you can't call the function from a keybind.
2) As said before you'll have to use html entities in the url for xml files _or_ quote the string containing special characters (&, #, ?, ...) in bash.
So either you use this directly in rc.xml
https://spreadsheets.google.com/ccc?key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE&hl=en#gid=3
or you use this in bash and put the whole thing in a file on your PATH instead of a function in bashrc
"https://spreadsheets.google.com/ccc?key=0AjuCrdYnTCyacGNfX0FuRzBFUnBOalNxS0VXYjJhVUE&hl=en#gid=3"
The way you've put the thing in bashrc, the # is interpreted as the beginning of a comment, which should have been obvious by the syntax highlighting.
Offline
@B: openbox will just exec() a command, just like urxvt -e. If you need a shell command, you'd have to use
<execute>sh -c 'command'</execute> or <execute>bash -c 'command'</execute>
But that won't source your .bashrc since it's not an interactive session. (and forget about -i, that'll just freeze openbox ).
And it looked so promising...
I guess that shows the limits of my knowledge .
Got Leenucks? :: Arch: Power in simplicity :: Get Counted! Registered Linux User #392717 :: Blog thingy
Offline
@B: openbox will just exec() a command, just like urxvt -e. If you need a shell command, you'd have to use
<execute>sh -c 'command'</execute> or <execute>bash -c 'command'</execute>
But that won't source your .bashrc since it's not an interactive session. (and forget about -i, that'll just freeze openbox ).
IIRC, bash -l will initiate a login shell which includes all of the bashrc goodness.
//github/
Offline