Skip to content

Category: Unix Hint

adding titles to postsript file displays on screen

The following was significantly updated on 30 May 2012 and again on Aug 2014:

idl and pgplot and many other postscript plotting routines have this annoying “feature” wherein, the output postscript file, when displayed with evince (“evince <filename> &”), goes into a window whose banner does NOT give its filename.  This is confusing if one is looking at multiple files.  We would prefer that the banner gives the name of the displayed file.

E.g., if the postscript file was produced with pgplot,  the window banner says “PGPLOT postscript plot”, rather than giving the file name.

E.g., if the postscript file was produced with IDL,  the window banner says “Graphics produced by IDL”, rather than giving the file name. (NOTE ADDED AUG 2014: YUPING HAS CREATED A SCRIPT INSIDE IDL TO GENERATE A FILENAME TAG ON PS FILES. SEE HIS POST!)

The reason is, that it writes into the file itself that the title is “PGPLOT postscript plot”; i.e., it literally writes “%%Title: PGPLOT postscript plot”
(or something similar for the IDL) into the postscript file.

After much effort, I have realized that evince will automatically display the desired filename rather than the above useless info, if only
one eliminates the whole “”%%Title” line.  (My first solutions, rather than eliminating that line, wrote the filename in the “%%Title” line.)

Inside IDL itself, I  think it is not possible either to alter or to eliminate the %%Title line as the postscript file is written because the drivers are proprietary.  Therefore one must fix the postscript file afterwards.  (The web shows how to run a unix script inside IDL that does so.)

Inside pgplot itself, one CAN fix the drivers so as to eliminate the offending %%Title line: Go to  drivers/psdriv.f

———–

To fix up a postscript file after the fact:

Joel has written a script (whose original was made and embellished by Joe Swiggum), joelpslabel, which

1. writes a new file whose name is the same as the original postscript file except
–Its name has an added “label” before the dot in the original file name
–Its modification date is listed as being identical (at least to the minute) with the original file name  (as in “ls -al”) so that you know when the original was created. (This was hard!!!!!!!!!!!!)

2. The script then runs evince on the new file, thereby putting on the screen something identical to the old file but with a banner that gives the old file name

———————

The new file with the new name having “label” in it stays on disk, and the original file is untouched, and they both have the same (claimed) date on them.  I do this because an older version of this script, which actually overwrote the original, sometimes got confused and the original was destroyed, requiring an archival search of old backups.  The downside is of course twice as much disk space but hey disk space is cheap and easy these days.

One can run joelpslabel on the original file as many times as one likes – each time overwriting the “new” file but assigning it the date of the orig file.

One can also run evince on the new file infinite times. The only downside there is that the banner will give the newfilename the 2nd-infinite time, rather than the old file name.  (The newfilename = oldfilename + “label”)

Known problem: The script searches for the first “.” in the filename and places “label” before it, so if your filename has more than one dot before “ps”, the name will be very screwy.  joel.weisberg.ps -> joellabel.weisberg.ps

Printer diagnostics – cups and printer API

To go to the CUPS printer GUI, in firefox go to http://localhost:631

To go to the printer API itself, go to http://137.22.12.71 for olin 304 6350 printer.  The startup page for each printer will give its IP address.

 

Thanks Bruce!

Handy Keyboard Chords

Due to the current instability with the GNOME environment, here are a few handy key chords to help reset the X windows server.

Press: 
Control-Alt-Backspace To: Kill all running processes attached to the X-Server on the computer and restart the X-Server, Note: As this ends all tasks associated with the X-Server, only use this one if you just turned the computer on or know nobody is using it, though it is the fastest way to restart X and is the only key chord that has any chance of returning GNOME to a functioning state.
                                      
Control-Alt-F1 To: Take you to init-1 (command line), pausing the X server, but not disrupting any open processes. From this command line many smaller tasks can be accomplished, provided that they do not need a separate window to operate.

Control-Alt-F7 To: Bring you back to init-7, (resuming X), use after Control-Alt-F1 to resume the windowing server. You should wait roughly 10 seconds in between using the two commands or the X server will get a little confused. Note: This pair of commands will never bring GNOME back to life, but if you want to work on the computer you can use the init-1 environment to do many simpler tasks.

For more information, as well as a whole host more key combinations please see this website.

Additionally, if one of the computers refuses to cooperate, it is possible to ssh in to any of Linux computers from any *nix system on campus (either a lab Mac, another Linux box, or your own laptop for that matter). To do so type:

ssh -Y username@hostname.physics.carleton.edu

And then enter your password when prompted.

So, for example,

ssh -Y cerjanb@deneb.physics.carleton.edu

Would log me in (provided I entered the correct password) as cerjanb on Deneb.

nautilus file manager startup in chosen directory from command line

To start up nautilus in a given directory from command line, simply type

nautilus <dirname> &

remember that . is a name for the current directory.  So nautilus . & will open a nautilus file manager in whatever directory the terminal is in.  This is the inverse of hitting the f4 key in nautilus which opens an xterm in the same directory that konqueror is in.

–Joel

How fix “Firefox already in use” problem

Our shared home directories sometimes confuse Firefox, causing it to fail to launch while posting a dialog window saying that “Firefox is already in use”.

The only solution I’ve found that really works is somewhat drastic. It requires you to delete your ~/.mozilla/firefox directory, which has the effect of deleting your bookmarks.

To preserve your bookmarks, we must first export them to a temporary location, exit Firefox, delete your ~/.mozilla/firefox directory, relaunch Firefox, and then import your bookmarks from the temporary location.

Here’s the step by step solution:

1. To get Firefox to launch (in a somewhat hosed state) so that you can save your bookmarks, open a terminal window and issue these commands:

rm -f ~/.mozilla/firefox/*.default/lock
rm -f ~/.mozilla/firefox/*.default/.parentlock

2. Launch Firefox. It will be somewhat hosed, but you should be able to export your bookmarks by opening the Bookmarks window by selecting “Bookmarks->Organize Bookmarks” from the Browsers menu. Once the Bookmarks window appears, click on the “Import and Backup” menu and select “Backup”. A “Bookmarks backup” window will pop up prompting you for a location to save your bookmarks to. Just go with the default values, which should save a “Bookmarks <date>.json” file to your Desktop.

3. Exit Firefox

4. From a terminal window, issue this command:

rm -f ~/.mozilla/firefox/

5. Launch Firefox. At this point Firefox should behave normally and you can restore your bookmarks by opening the Bookmarks window and selecting “Bookmarks->Organize Bookmarks” from the Browsers menu. Once the Bookmarks window appears launched, click on the “Import and Backup” menu and select “Restore”. A dropdown list of of bookmark backup files should pop up, and you can select the most recent one to restore your bookmarks.

To find a file down a tree

find . -ls | grep -i <filename>

that means find all files from current dir and below, and get file date etc with ls and then find those matching <filename>. The ‘-i’ argument tells grep to ignore the case (uppercase/lowercase) of characters in the filename.

Change users quota (MUST BE *THUBAN* ROOT)

type edquota <username> as root on thuban.

this drops you into a vi editing session.

change the quota as desired and then exit the session.

If you are not familiar with vi, you may find more details on how to edit this file under the “new user” post, where the setting up of a quota for a new user is discussed.

–Joel

konqueror (nautilus?) file browser and kwrite (kate?)text editor setup hints

Added by jmw 2020 may 28: Maybe these konqueror and kwrite config hints are still somewhat useful for nautilus and kate???

I find konqueror the best file browser for linux. To customize it a little, for example to get .idl files to open with my favorite text editor, kwrite:

with konqueror running:
settings>>configure konqueror gives some options like what your home dir should be (eg /home/youusername

to make conqueror behave a certain way with a certain kind of file, i made in my home dir (/home/jweisber) a file called dummy.idl

if you select it inside konqueror (one click to highlight it)

go to edit>properties
it should pop open a window labelled “Properties for dummy.idl – Konqueror”
‘way to the right of “type” is an icon of a bunch of tools. push on it.
it should pop open a window labelled “Edit file type application/idl KDEditFileType- Konqueror”
if its not already there, add a filename pattern of *.idl
that means any file ending with that will be treated in the way you are getting ready to set up

under application preference order, enter
kwrite

if you wish, you can also associate a pretty icon with *.idl by clicking on the “?” icon to left of “filename patterns”

click ok and from now on , when you dble-click on any file ending in .idl, it should open it with kwrite (see addition below)

(you may have to entirely quit and restart konqueror for the new properties to take)

–jmw january 2008

——addition feb 2008 – to get kwrite to use “syntax highlighting” (ie to color idl files with a certain color set; fortran etc etc):

open an idl file in kwrite.

in the kwrite toolbar up top, hit settings>configure editor>highlighting

now here is what took me more time than i am willing to admit:

the panel should now be labelled highlighting rules.

the first thing to do is to select a type from the pulldown menu near the top; eg “sources idl ”

then inside properties:file extensions, type *.pro;*.idl;*.batch

inside properties: MIME types, type application/idl

then hit the icon on the far right of this line and get a panel saying “Select the mimetypes you want highlighted using sources/idl syntax highlight rules”

and check the relevant mime types.

(note if the right mime types arent there, see joel)

note that some of these properties do not “take” until you jump out of konqueror and restart it!