You are not logged in.
I am attempting to map the brightness keys ( F4 and F5 ) to a bash script I wrote to change the brightness on a Dell XPS 13. The issue is that I don't want the key map to display the bash command to the console when I press it. The method outlined in the wiki outputs the command to the console line and then executes it: https://wiki.archlinux.org/index.php/Ex … in_Console . Ideally I would like the key press to directly initiate the bash command, rather than initiating it by printing to the console with a newline as recommended in the article. I have it working via the wiki way, but it's annoying for random brightness calls to crop up in the console window.
After a deep Google search, this Stack Overflow thread is the best thing I could find: http://stackoverflow.com/questions/4200 … -a-command . Sadly my little laptop provides "^[[[E" ("\e[[E") for a brightness up key, and "^[[[D" ("\e[[D") for the brightness down key, which violates the two character limit on bind -x method that is mentioned in the Stack Overflow post.
So my question: Is there any way to get around the two character limit on the bind -x mapping as alluded to in the post, allowing me to map my brightness script via a bind -x command? And if not, is there any other way to implement a console based solution? I don't have any window manager or DE installed, and I'd like to keep it that way.
Last edited by tyler.heck (2012-06-08 05:26:36)
Offline
If you just want to get rid of the standard messages, you could simply send output to /dev/null:
myscript >/dev/null
or, if you want to dump error messages into the ether as well, do:
myscript >/dev/null 2>&1
Offline
One ugly workaround would be to have a second tty loged in, then using just the first method, map your key to a series of keypresses like: Alt-f2 scriptname \n Alt-f1
This way, when the key is pressed, it will switch to tty2, run the script command, then switch back to tty1 without getting in the way of what was already being typed in tty1. Of course this would require an opent tty just for running such commands, and it would always return you to tty1 wherever you ran it from.
A far better option would be to do the binding through screen or tmux. If you are not running X, I suspect you must be using screen, tmux, or perhaps dvtm.
Last edited by Trilby (2012-06-07 07:59:53)
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Thanks for the tips.
Redirecting to /dev/null is good for getting rid of unwanted messages, but I'm really after getting rid of the command itself appearing on the console when I press the key. Sadly a redirect isn't enough to fix that issue.
I actually haven't installed much over the base system (so no tmux, screen, or dvtm yet). I've being trying to see how much functionality I could add to the base arch install myself, I've already done some simple stuff like basic network management and system back ups. I have looked into tmux and was probably going to install it later this week (writing something like that myself isn't gonna happen), so I'll bump that up and do an install tonight. I'll post any thing I needed to do to enable silent key mapping that isn't standard with tmux on the chance that someone else may one day stumble upon this thread.
I also had a thought last night to write a daemon that would capture key events directly from the system, and use them to call relevant executables. I haven't looked into that either so I don't know if its possible, but I'll research that and see if I can one day go back to my relatively "pure" base build. I'd miss the terminal multiplexing though... Gah so may choices!
Offline
That is certainly possible - and it could actually be pretty simple, possibly just a dozen lines of C code. But if you'll end up using tmux anyways, why bother? In tmux it would be one line in the .tmux.conf file.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
tmux worked excellently, thanks for the tip. I'm also going to stick with to the idea of writing my own key mapping daemon, just because I figure it would be a nice way to learn more about some of the internals. Thanks again for your help
Offline