X11 - Xmessage : display a message in a window
You've seen how to run commands, set of commands and scripts in the terminal.
In X graphical environment Xmessage can send the output of a command or script in a window.
Xmessage display a message or query in a window (X-based /bin/echo)
Here are some basic examples.
Xmessage display the date and time:
This can be done with a simple script: in a while loop create an output and pass it to Xmessage
sh -c 'while date | xmessage -nearmouse -buttons OK:1 -file - ; do :; done'
Xmessage display the Jomo Kenyatta International Airport, Nairobi weather report:
sh -c 'while metar -d HKJK | xmessage -nearmouse -title JOMO\ KENYATTA\ NAIROBI -buttons OK:1,Another\ Button:\ AGAIN:0 -default OK -file - ; do :; done'
Xmessage can be used to display a test file like this:
This is the script:
sh -c 'while xmessage -nearmouse -title LOREM\ IPSUM -buttons Close:1 -file ~/Lorem.txt ; do :; done' &
But it can also be in this form:
sh -c 'while less ~/Lorem.txt | col -x | xmessage -nearmouse -title LOREM\ IPSUM -buttons Close:1 -file - ; do :; done'
Because -file - reads from standard input.
Xmessage can be used to display the output of a script that collect the exchange rate of Euro, Dollar and Pound to KES:
The Athena Text widget that is used for this application allow some shortcuts in the Xmessage window:
Ctrl + R or Ctrl + S to search
Ctrl + Z to scroll down
Alt + S to scroll up
Alt + V to go to Home
Ctrl + V to go to End
Note that you can move the scrollbar with the mouse buttons:
Mouse Left button on the scrollbar: scroll DOWN
Mouse Center button on the scrollbar: HOLD scroll to move UP or DOWN
Mouse Right button on the scrollbar: scroll UP
You can customize an X11 application, mostly graphics, in ~ / .Xdefaults file that is read when an X11 program starts.
Here is what to write in your ~ / .Xdefaults file to have the same graphic effects.
!Lines beginning with ! or includes in /*string here*/ are comments and are ignored:
!This is a Comment
/*This is a Comment*/
/*-No-white-space-start-or-end-of-any-line-*/
!{{{ XMESSAGE
Xmessage*font: -xos4-terminus-medium-*-*-*-12-*-*-*-*-*-iso8859-2
Xmessage*geometry: +200+200
Xmessage*background: gray85
Xmessage*foreground: gray15
Xmessage*Scrollbar.thumb: vlines2
Xmessage*Scrollbar.width: 12
Xmessage*Scrollbar.foreground: rgb:a/5/5
Xmessage*Scrollbar.borderWidth: 0
Xmessage*Scrollbar.displayList:\
foreground gray90;\
lines 1,-1,-1,-1,-1,1;\
foreground gray60;\
lines -1,0,0,0,0,-1
Xmessage*Text.?.cursorColor: rgb:d/5/5
Xmessage*Text.borderColor: gray80
Xmessage*Text*background: gray96
Xmessage*Text*Scrollbar.background: gray80
Xmessage*Text.displayList:\
foreground gray90;\
lines 1,-1,-1,-1,-1,1;\
foreground gray60;\
lines -1,0,0,0,0,-1
Xmessage*Command.highlightThickness: 2
Xmessage*Command.internalWidth: 5
Xmessage*Command.internalHeight: 3
Xmessage*Command.borderColor: gray40
Xmessage*Command.shapeStyle: Rectangle
Xmessage*Command.background: gray80
Xmessage*Command.displayList:\
foreground gray60;\
lines 1,-1,-1,-1,-1,1;\
foreground gray90;\
lines -1,0,0,0,0,-1
Xmessage*Form.displayList:\
foreground gray60;\
lines 1,-1,-1,-1,-1,1;\
foreground gray90;\
lines -1,0,0,0,0,-1
!}}}
Save .Xdefaults in your home directory.
REVA DIGITAL TECH TEAM
Revadig RSS Feeds Revadig Atom Feeds
In X graphical environment Xmessage can send the output of a command or script in a window.
Xmessage display a message or query in a window (X-based /bin/echo)
Here are some basic examples.
Xmessage display the date and time:
This can be done with a simple script: in a while loop create an output and pass it to Xmessage
sh -c 'while date | xmessage -nearmouse -buttons OK:1 -file - ; do :; done'
Xmessage display the Jomo Kenyatta International Airport, Nairobi weather report:
sh -c 'while metar -d HKJK | xmessage -nearmouse -title JOMO\ KENYATTA\ NAIROBI -buttons OK:1,Another\ Button:\ AGAIN:0 -default OK -file - ; do :; done'
Xmessage can be used to display a test file like this:
sh -c 'while xmessage -nearmouse -title LOREM\ IPSUM -buttons Close:1 -file ~/Lorem.txt ; do :; done' &
But it can also be in this form:
sh -c 'while less ~/Lorem.txt | col -x | xmessage -nearmouse -title LOREM\ IPSUM -buttons Close:1 -file - ; do :; done'
Because -file - reads from standard input.
Xmessage can be used to display the output of a script that collect the exchange rate of Euro, Dollar and Pound to KES:
Note the Another button can repeat the query. You can add more buttons as needed.
Xmessage can be useful for a help file from the menu.
or to display the calendar with some notes:
Xmessage shortcuts
The Athena Text widget that is used for this application allow some shortcuts in the Xmessage window:
Ctrl + R or Ctrl + S to search
Ctrl + Z to scroll down
Alt + S to scroll up
Alt + V to go to Home
Ctrl + V to go to End
Note that you can move the scrollbar with the mouse buttons:
Mouse Left button on the scrollbar: scroll DOWN
Mouse Center button on the scrollbar: HOLD scroll to move UP or DOWN
Mouse Right button on the scrollbar: scroll UP
You can customize an X11 application, mostly graphics, in ~ / .Xdefaults file that is read when an X11 program starts.
Here is what to write in your ~ / .Xdefaults file to have the same graphic effects.
!This is a Comment
/*This is a Comment*/
/*-No-white-space-start-or-end-of-any-line-*/
!{{{ XMESSAGE
Xmessage*font: -xos4-terminus-medium-*-*-*-12-*-*-*-*-*-iso8859-2
Xmessage*geometry: +200+200
Xmessage*background: gray85
Xmessage*foreground: gray15
Xmessage*Scrollbar.thumb: vlines2
Xmessage*Scrollbar.width: 12
Xmessage*Scrollbar.foreground: rgb:a/5/5
Xmessage*Scrollbar.borderWidth: 0
Xmessage*Scrollbar.displayList:\
foreground gray90;\
lines 1,-1,-1,-1,-1,1;\
foreground gray60;\
lines -1,0,0,0,0,-1
Xmessage*Text.?.cursorColor: rgb:d/5/5
Xmessage*Text.borderColor: gray80
Xmessage*Text*background: gray96
Xmessage*Text*Scrollbar.background: gray80
Xmessage*Text.displayList:\
foreground gray90;\
lines 1,-1,-1,-1,-1,1;\
foreground gray60;\
lines -1,0,0,0,0,-1
Xmessage*Command.highlightThickness: 2
Xmessage*Command.internalWidth: 5
Xmessage*Command.internalHeight: 3
Xmessage*Command.borderColor: gray40
Xmessage*Command.shapeStyle: Rectangle
Xmessage*Command.background: gray80
Xmessage*Command.displayList:\
foreground gray60;\
lines 1,-1,-1,-1,-1,1;\
foreground gray90;\
lines -1,0,0,0,0,-1
Xmessage*Form.displayList:\
foreground gray60;\
lines 1,-1,-1,-1,-1,1;\
foreground gray90;\
lines -1,0,0,0,0,-1
!}}}
Save .Xdefaults in your home directory.
REVA DIGITAL TECH TEAM
Revadig RSS Feeds Revadig Atom Feeds
Copyright © 2017 by REVA DIGITAL SOLUTIONS Limited. All Rights Reserved.
Comments
Post a Comment