Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
I've been using Linux for almost an year and I can't believe how I survived so long without knowing it (so far only used wind..ughh can't finish saying it).
Anyhow, I'm using Ubuntu 10.04LTS on Openbox. Everything is working fine, but when I add keybindings at some point I need globbing so I do <execute>bash -c "application /path/to/args/*"</execute> to enable globbing. This however has a problem, I can't add newlines between the arguments, and sometimes it leads to really long lines that have to be wrapped.
So, finally, my question: Is there anyway to execute an application through openbox's keybindings with globbing enabled which allows me to add newlines between the programs arguments?
[EDIT]I'd prefer not to make my own program to apply globbing to the application nor create scripts, so if that's the only way you can find to solve this problem then I do not need you answear (not trying to act up, it's just that I can solve it that way too, but prefer a more elegant aproach)[/EDIT]
Interesting question. I don't use Ubunut but I do use openbox and I have tweaked the keybindings a bit. Can you give me an example of the sort of command that would need to be split over more than one line?
I don't actually have the really long lines right now because... well.. I'd have a really long config file (and it would be pointless to post dozens of lines when they're just paths to personal filenames) but it would be something like this.
But it doesn't work. It starts audacious without any song and I get an output like:
bash: line 1: ~/music/mars\ volta\,\ the/2003\ -\ de-loused\ in\ the\ comatorium/inertiatic\ esp.mp3: permission denied
I'm checking on openbox's source code to see if I can add something to the parser to understand my folders and automatically add keybinds to them. Fun project for holidays, uh? :P
Well if it was me I would just make an m3u playlist and set audacious as the default app to run the playlist, then when I click on the m3u playlist it would just work. However, as you want keybindings, not clicky clicky mouse clicking (I do understand), this works for me
Yes, that works for me too, but if you look closely you're not doing any globbing, ie you don't have something like:
Code:
audacious /play/everything/on/this/folder/*
But I see this is dragging along for too long, so I'll just call a C proggy to do the globbing instead of bash. And since bash calls ~/.bashrc on startup, it's probably most efficient this way. I'll post the C code of the program in case anyone stumbles upon this and needs my solution (still don't know what's wrong with bash and newlines which was the whole point of this question for me)
Code:
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<glob.h> //Nice header :) allows for filename expansion just like shell. Oh, how I love Linux! x)
//#define DEBUG
int main(int argc, char *argv[])
{
int i = 0;
glob_t globber;
if(argc > 1)
{
glob(argv[1], GLOB_NOCHECK | GLOB_TILDE | GLOB_BRACE, NULL, &globber);
for(i = 2; i < argc; i++)
glob(argv[i], GLOB_NOCHECK | GLOB_TILDE | GLOB_BRACE | GLOB_APPEND, NULL, &globber);
}
#if DEBUG
for(i = 0; i < globber.gl_pathc; i++)
printf("Arg %d: %s\n", i, globber.gl_pathv[i]);
#endif
execvp(globber.gl_pathv[0], globber.gl_pathv);
fprintf(stderr, "Globber: failed to execute application: %s\n", globber.gl_pathv[0]);
return 1;
}
The first argument is "audacious" in this case. So to keybind that folder I'd have something like:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.