LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (https://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   Problem with Auto-Shrinking xterm (https://www.linuxquestions.org/questions/linux-desktop-74/problem-with-auto-shrinking-xterm-689331/)

lmaza 12-09-2008 09:27 AM

Problem with Auto-Shrinking xterm
 
I put the following to give the context of my question.
(It is taken from a book).
"Project Auto-shrinking xterm

Most people just use X resources to make simple modifications to colors or fonts. Even then, they generally just copy the X resources from another user without ever really understanding what the resouces are doing. In this short project we will investigate an interesting set of resources in xterm: Translations.

Translations in xterm enable you to execute certain actions in response to events. Often this events are key presses or mouse clicks (a good way to get macros), but there are other events such as when the mouse enters or leave the window.

Say you want the xterm to shrink whenever the mouse leaves it and then grow when the mouse enters. This way, you could have may xterms on the screen and could somewhat watch what they were doing without having them take over your entire desktop. This can be very handy when you have a lot of compilations goin on. You might want to watch them all to see when one completes, but you don't really care what the output looks like most of the time.

To get this effect you can instruct xterm to change its font in response to mouse actions. The following X resource would do this:

shrinkterm*VT100.Translations: <EnterWindow>: set-vt-font(d) \n \
<LEaveWindow>: set-vt-font(1) \n"

Now I take the freedom to make a question: (At last). I am using Debian GNU/Linux. But I do not use KDE and I do not use Gnome. Instead I only use X and a window manager. Specifically my ~/.xinitrc file gives with $cat .xinitrc the following

xterm -geometry +50+35 -fa courier -fs 14 -fg green -bg black
fvwm

$
So I tried to get the shrinking xterms mentioned above. Therefore I edit a file called my_shrinkterm where I included the lines

shrinkterm*VT100.Translations: <EnterWindow>: set-vt-font(d) \n \
<LEaveWindow>: set-vt-font(1) \n

After that I introduce the comand
$xrdb -merge my_shrinkterm
Then type
$xterm -name shrinkterm&
After that I get a xterm that effectively grows when the mouse enters the window an shrinks when the mouse leaves it. The problem is that I cannot write in that xterm. When I put the mouse on the shrinked xterm, it grows but it seems not attend the keyboard. As an aproach to diagnose (make a diagnostic of) the problem I used the command write (from my first xterm on pts/0) to send a message to the pseudo terminal. I mean I introduced the command
$write user pts/1
SOME WORDS
^D

And the message (SOME WORDS) in effect appears on the xterm (the one that shwinks and grows depending on the mouse position).

If somebody can and take the time to send help. Thanks in advance.

lmaza 12-11-2008 07:20 AM

solution from the command line
 
The following works at the command line (I mean, I finally get the auto-shrinking xterm):

$ xterm -cr green -fa courier -fs 12 -fg green -bg black -xrm 'XTerm*VT100.translations: #override <EnterWindow>: set-vt-font(d)\n \ <LeaveWindow>: set-vt-font(1)\n'&

And after that you get a nice auto-shrinking xterm with black background and green text (foreground).

I found the right syntax to use xterm translations at the command line at a page called: xterm.faq.html



Quote:

Originally Posted by lmaza (Post 3369198)
I put the following to give the context of my question.
(It is taken from a book).
"Project Auto-shrinking xterm

Most people just use X resources to make simple modifications to colors or fonts. Even then, they generally just copy the X resources from another user without ever really understanding what the resouces are doing. In this short project we will investigate an interesting set of resources in xterm: Translations.

Translations in xterm enable you to execute certain actions in response to events. Often this events are key presses or mouse clicks (a good way to get macros), but there are other events such as when the mouse enters or leave the window.

Say you want the xterm to shrink whenever the mouse leaves it and then grow when the mouse enters. This way, you could have may xterms on the screen and could somewhat watch what they were doing without having them take over your entire desktop. This can be very handy when you have a lot of compilations goin on. You might want to watch them all to see when one completes, but you don't really care what the output looks like most of the time.

To get this effect you can instruct xterm to change its font in response to mouse actions. The following X resource would do this:

shrinkterm*VT100.Translations: <EnterWindow>: set-vt-font(d) \n \
<LEaveWindow>: set-vt-font(1) \n"

Now I take the freedom to make a question: (At last). I am using Debian GNU/Linux. But I do not use KDE and I do not use Gnome. Instead I only use X and a window manager. Specifically my ~/.xinitrc file gives with $cat .xinitrc the following

xterm -geometry +50+35 -fa courier -fs 14 -fg green -bg black
fvwm

$
So I tried to get the shrinking xterms mentioned above. Therefore I edit a file called my_shrinkterm where I included the lines

shrinkterm*VT100.Translations: <EnterWindow>: set-vt-font(d) \n \
<LEaveWindow>: set-vt-font(1) \n

After that I introduce the comand
$xrdb -merge my_shrinkterm
Then type
$xterm -name shrinkterm&
After that I get a xterm that effectively grows when the mouse enters the window an shrinks when the mouse leaves it. The problem is that I cannot write in that xterm. When I put the mouse on the shrinked xterm, it grows but it seems not attend the keyboard. As an aproach to diagnose (make a diagnostic of) the problem I used the command write (from my first xterm on pts/0) to send a message to the pseudo terminal. I mean I introduced the command
$write user pts/1
SOME WORDS
^D

And the message (SOME WORDS) in effect appears on the xterm (the one that shwinks and grows depending on the mouse position).

If somebody can and take the time to send help. Thanks in advance.


tredegar 12-13-2008 05:54 AM

Quote:

The problem is that I cannot write in that xterm. When I put the mouse on the shrinked xterm, it grows but it seems not attend the keyboard.
this is correct, because the "focus" is still set to the terminal that you used to launch the shrinking xterm.
If you want to type in the shrinking xterm, click on it to bring it into focus.

That's quite a neat trick, I didn't realise you could do that with xterm.

I learn something new every day.

Here's the code in code-tags in case anyone else would like to try it:
Code:

xterm -cr green -fa courier -fs 12 -fg green -bg black -xrm 'XTerm*VT100.translations: #override <EnterWindow>: set-vt-font(d)\n \ <LeaveWindow>: set-vt-font(1)\n'&

lmaza 01-08-2009 07:44 AM

That is the idea. To put information that could be useful for other linux users.
Thanks for your answer.


All times are GMT -5. The time now is 12:47 PM.