I've been trying to make LIB PROPSHEET more controllable
(see TEACH PROPSHEET, in poplog V14.2) and came up with a
scheme to use sysobey to run xrdb in order to change defaults.
I wonder if anyone can see anything wrong with this. Here's the
code for a procedure xsetresource, with a help section giving
examples of its use. Suggestions for improvement welcome.
Aaron
-----------------------------------------------------------------------
;;; lib xsetresource.p ( $poplocal/local/auto/xsetresource.p )
;;; A.Sloman 24 June 1993
/*
HELP XSETRESOURCE A.Sloman June 1993
(UNIX Only)
xsetresource(string)
xsetresource(strings)
This procedure can be used to set resource defaults for X clients.
It is given a string or list of strings, such as can occur as separate
lines in a .Xdefaults line. If it's a list, one string is created by
concatenating the strings, separated by newline characters.
The resulting single string is piped through "xrdb -merge"
Example of use
xsetresource(
['Poplog*Background: black'
'Poplog*FontColor: white'
'Poplog*font: -*-times-bold-r-normal--*-140-*-*-p-*-iso8859-1'
'Poplog*geometry: -0-0'
]);
;;; create a mew propbox
vars ps_box=propsheet_new_box('TEST BOX', false, false, false);
;;; display it
propsheet_show(ps_box);
;;; Now try with different settings
xsetresource(
['Poplog*Background: MediumSeaGreen'
'Poplog*FontColor: yellow'
'Poplog*font: 8x13bold'
'Poplog*geometry: -50+0']);
vars ps_box2=propsheet_new_box('TEST BOX2', false, false, false);
propsheet_show(ps_box2);
*/
define xsetresource(strings);
lvars s, strings, string ;
unless systranslate('DISPLAY') then
mishap(0, 'DISPLAY NOT SET')
endunless;
if isstring(strings) then strings
elseif islist(strings) then
;;; concatenate the strings, separating them with newlines
consstring
(#| for s in strings do explode(s), `\n` endfor |#)
else
mishap('STRING or LIST OF STRINGS NEEDED')
endif -> string;
sysobey('echo "' sys_>< string sys_>< '" | xrdb -merge')
enddefine;
|