CHAOSACES n00b


Joined: 12 Jan 2004 Posts: 66
|
Posted: Sun May 16, 2004 4:13 am Post subject: HowTo: Get imwheel to work with fullscreen terminal apps |
|
|
I found it quite annoying that whenever I went to scroll with the mouse wheel in certian "fullscreen" terminal apps (less, man, info, nano, links, etc),
the terminal would scroll up above the program I was working with. Well, I fixed that.
First, we need to change the title of the terminal emulator to the name of whatever program we're working with. This is done via a script I call "settitle":
Code: |
#! /bin/bash
# settitle
# distribute and alter freely
if [ $4 ]; then
echo "Error -- Too many arguments."
echo "Usage is:"
echo "\`settitle program [arguments] [file]\'"
echo "Or:"
echo "\`settitle -c title\'"
exit 1;
fi
if [ ! $1 ]; then
echo "Error -- Too few arguments."
echo "Usage is:"
echo "\`settitle program [arguments] [file]\'"
echo "Or:"
echo "\`settitle -c title\'"
exit 1;
fi
if [ $TERM == "linux" ]; then
echo "You can't change the title if there is no window."
exit 1;
fi
if [ $1 == "-c" ]; then
shift;
echo -e '\033]0;'$@'\007\c';
exit 0;
fi
echo -e '\033]0;'$@' '$TERM'\007\c';
$@ &&\
echo -e '\033]0;'$TERM'\007\c';
exit 0;
|
This script will accept any program and it's arguments as it's own arguments, change the window title, run the program with the arguments specified, and change the window title back when finished. Using the "-c" switch, you can change the title to whatever you want. If you need more than the number of arguments allowed, you can use a backslash "\" before spaces (ex. `settitle -c This\ title\ contains\ far\ too\ many\ arguments.` || `settitle nano -w\ -i\ -I\ -dos\ /usr/local/bin/settitle`) Just save it to /usr/local/bin (or wherever you add scripts to your path), chmod 755 it, and you're good to go.
Next, we need to set up some aliases in .bash_profile:
Code: |
# .bash_profile
if [ $TERM != "linux" ]; then
alias nano='settitle nano -wi'
alias less='settitle less'
alias links='settitle links'
alias man='settitle man'
fi
[/quote]
Finally, we need to add these programs to .imwheelrc:
[quote]
"^nano.*"
None, Up, Page_Up,
None, Down, Page_Down,
"^man.*"
None, Up, Page_Up,1
None, Down, Page_Down,1
"^info.*"
None, Up, Page_Up,1
None, Down, Page_Down,1
"^less.*"
None, Up, Page_Up,1
None, Down, Page_Down,1
"^Eterm.*"
None, Up, Shift_L|Page_Up,1
None, Down, Shift_L|Page_Down,1
#Control_L, Up, Page_Up
#Control_L, Down, Page_Down
Button1, Up, Page_Up
Button1, Down, Page_Down
".*"
None, Left, Super_L|F12,1
|
NOTE: It is very important that the programs you set this up for come before the terminal you use. Otherwise, the terminal's settings will be given prescedence. Also, the catchall ".*" should come last.
Well, I hope this helps someone out. Let me know if you have any problems with this, or I left anything out, or I'm just an idiot. |
|