Archive | Computing RSS for this section

MATE menu shenanigans

So I’ve got lots of stupid entries in my main menu in MATE — lots of things that seem to have been added by wine or something. And I’ve tried mozo/alacarte to get rid of them and they did not work.

The wine-related .desktop files live in the directories within…

.local/share/applications/wine/Programs

Now, the menu system looks for .desktop files and creates a menu entry for each one. So… so if I go in there and change the ‘.desktop‘ files to ‘.nodesktop‘, what happens?

Used a clunky script (I know, I know, going via a temporary file to construct the script is amateurish at best; well, it works). It just renames within the current directory — it does not work recursively; I don’t want to be that destructive!

echo "#Rename .desktop files to .nodesktop" > tempfile
for f in *.desktop
do
g=$(basename "$f" .desktop).nodesktop
echo mv \"$f\" \"$g\" >> tempfile
done
bash tempfile
rm tempfile

I don’t know enough to know why I had to write the mv command out to make it work, but when I just tried to run 'mv \"$f\" \"$g\"' from inside the script it did not work. This works and does remove the entries from my menu. I can then selectively put them back if I so desire.

Anyway, this does work for the MATE menu.

I’m sure there’s a better way. I don’t know why the menu editors don’t work.

But they don’t.

Advertisements

Clink; making the Windows command line more functional

Clink makes the Windows command line 10× more useful. Command completion, retain history between sessions, and a lot more. Installation is trivial. I just have to mention it because of how handy it is. Some tools don’t work brilliantly though Cygwin, so I need to use CMD.EXE. And it’s GPL.

With Clink, I can type a letter at the CMD prompt and then hit Tab twice and I’ll get a list of possible commands to run.

I installed Clink using the default installer then opened a command window. In the image below, note the info at the top showing that Clink has started up. I then typed ‘gv Tab Tab’ (ie hit Tab twice) and got a list of the executables that begin with ‘gv’ — gvim, the graphical version of the vim editor, and gvwgs64.exe, part of the Ghostscript/GSview universe of PostScript tools.

Screengrab of Clink at work.

Anyway, it has lots of capability and is seamless. I’m very impressed.

Genuine productivity.

Updating my Debian box — a non-expert’s experience

My Debian desktop box was running the LTS (long term support) version (in other words, older than oldstable, getting minimal updates and getting outmoded and old and crufty), which is the 7.x series. Support for that even as LTS is scheduled to end May 2018, not far away.

So I bit the bullet and decided to update to current, which is 9.3 (‘stable’). I like Debian, rather than one of the many distributions derived from it. I’ve found for me it words pretty well. Most problems I have are with applications not the OS, and when I’ve fiddled around with other Linux distributions, I have generally found that they are different but not better, and often have fewer packages. So Debian it is.

I don’t have a great network connection where I live (in the bush in Australia, which has poor broadband even in towns), so rather than do a net install I downloaded the iso for the installation disk and burned it. This file: https://cdimage.debian.org/debian-cd/9.3.0/amd64/iso-dvd/debian-9.3.0-amd64-DVD-1.iso. I did not bother grabbing 2 and 3; I have enough internet to grab anything not on the DVD from the server, and eventually the DVDs get out of date.

I also made what I think is a good decision about backups. I began with a 1TB drive. Not big now, but  the computer is about 7 years old, I’d guess. Maybe more. It has an i7-2600K, which was a pretty good chip at the time. When I got it I was using it for numerical modelling, like here, but I don’t do much of that these days, and with 8 GB RAM it is still perfectly capable of running a responsive desktop, so I do not feel a need to upgrade the processing power or the RAM. Since then, I bought a 2 TB drive for storing media, and bunged it in the case and mounted it as /home/username/Music. Worked fine. So with that in mind…

    1. Went into VirtualBox and exported all the virtual machines I wanted to keep to an appliance, ‘Appliance.ova’ — this was a 34 GB file.
    2. Went into firefox and exported my bookmarks to a json file.
    3. Used rsync to copy /home/username (including the Music folder, since it was mounted at the time) to an external USB backup drive called SAMSUNG. Here is the rsync command, for reference:
      rsync -a -v -v -v --stats  --log-file=logrsync.log /home/username /media/SAMSUNG/home/
      

      and note that I have excluded nothing, since I want to keep my web history as well as the actual data. This command will grab stuff like .mozilla/firefox profiles and the like, though more on that later. The Appliance.ova file was also in a place where it would get backed up externally.

    4. Left the 1 TB drive in the case but disconnected power and SATA cables from it. Since I’d been getting some errors from the drives, I decided to use the second row of SATA sockets for the new install where previously I’d been using the first. So I plugged in the CD/DVD and the 2 TB hard drive into the second row of slots, the DVD into the white socket and the HD into the first blue socket. I made sure to use SATA cables with clips.

      Picture of the mother board and which SATA sockets I used.

      Using the right-hand set of sockets for the SATA drives instead of the left.

    5. Double-checked that the USB backup drive had all my data — /home from the 1 TB drive and Music from the 2 TB drive. Yes, it did. Also had the Appliances.ova and the .mozilla hidden directory with all my web history and stored passwords (more on that later). Disconnected it from the machine. So now only the 2 TB HD and the DVD drive were connected.
    6. Put Debian 9.3 DVD 1 into the drive and rebooted the computer.
    7. Pressed ‘Del during boot to bring up BIOS menu and selected CDROM as first boot device. BIOS menu showed that we’re using IDE channel 1, not channel 0 as previously. That’s OK.
    8. Let the machine boot off the DVD and selected Install, not graphical from the menu. Graphical is probably fine but I’ve been doing this for a while and I have no problem with ncurses. Wired internet connection was in and on.

      Picture of the menu.

      Menu to select the Debian install method.

    9. Clicked through the install (Language, Location, Keyboard map, Hostname, Domain, Root password, User account, Clock

      Picture of the menu.

      Menu to select language.

    10. Partitioned the HD. SCSI 2(010)(sda). Whole device. 16 GB swap (2 × the RAM), then rest of disk at ext4 Linux, mount point ‘/’, and set this partition bootable. Done.
      Picture of the partitioner screen.

      Partitioning — setting up swap space.

      Picture of the partitioning.

      Setting up the root partition.

    11. Write the partition information to disk.
    12. Start installing.
    13. Threw a corrupt file error while installing the base system and dumped me into a text menu. Selected ‘Install base system’ or whatever it was (ie, have another go, please) and it went through. I only installed the base system (ie, command line tools).

      Picture of the error screen.

      Red screen means error.

    14. Linux image was amd64, and the kernel image (it told me) was 4.9.0-4.
    15. Told it I was not scanning anymore DVDs.

      Picture of the apt configuration screen.

      Setting up apt (the package management).

    16. Yes, please set up a mirror.
    17. Chose a mirror and let it configure apt. It said something about ‘upgrading’ but I don’t want to toast my bandwidth so I turned off my router. For now I just want to use the DVD, so once apt was configures with the correct mirror, I figured it would be OK to turn off the internet.
    18. Chose some software, set it to install but it halted at one pointed — needed to get something from the net, should not have turned it off yet. Reran with net on and ok.
    19. Yes, GRUB to MBR, please.
    20. Rebooted with web off. Changed BIOS to boot from HD and left DVD in as a file repository.
    21. As root, edited /etc/apt/sources.list and commented out the web repositories for now.
    22. apt-get update
    23. apt-get –install-suggests install mate-desktop-environment.
    24. Chose gdm3 as my display/login manager, since MATE and Gnome should work well together.
    25. Added some other stuff using apt-get; xsane, libreoffice, that sort of thing.
    26. Plugged in backup USB HD and, with a command line open in /home/username/, coipied all the backed-up material into my new home directory:
      cp -irv /media/username/SAMSUNG/home/username/* .
      cp -rv .[^.]* .
      
    27. Edited /etc/apt/sources.list to remove comments from web repositories, now that the bulk of the software was installed.
    28. Downloaded VirtualBox installer from https://www.virtualbox.org/wiki/Linux_Downloads.
    29. As root, installed a few packages it needs:
      apt-get install dkms
      apt-get --install-suggests install linux-headers-amd64 linux-headers-4.9.0-4-amd64
      apt-get install  libqt5opengl5
      dpkg -i virtualbox-5.2_5.2.6-120293~Debian~stretch_amd64.deb
    30. Then ran VirtualBox and imported the Appliance.ova file, and there everything was. Once I installed the guest additions, it all worked smoothly.
    31. Ran Firefox. Despite the exact copy of the old profile directory, it remembered nothing. I tried running firefox -P and selecting the profile that matched the old one rather than the new one it had cfreated, but that did not seem to help either.
    32. Mounted the old 1 TB HD using a SATA to USB adapter and recopied old profile directory from the 1 TB HD to the new directory (profiles live in /home/username/.mozilla/firefox with filenames like brqhj45.default-1234456787655).
    33. That fixed my passwords but not the bookmarks.
    34. Within the bookmark manager of Firefox, imported the json file I created in step 2, and that fixed that. Done.

So at the end I had my old root drive (minus the Music folder) on the old 1 TB drive as emergency snapshot and backup, I had a current backup on the external USB HD (including the Music folder) and on the 2 TB drive, which used to be just the Music folder, I had everything, including Music.

Still got some issues with Windows progs installed under the old wine not working with the new one — but install media not working with new one either so cannot reinstall…

Relatively painless.

 

 

 

VirtualBox full screen goes grey

32-bit Win 7 VirtualBox virtual machine (VM) running atop Linux (Debian Old Stable, 7.11). VirtualBox version 5.1.30.

Boots fine, behaves well… here is the resulting desktop, captured using Host-E:

Desktop of Win 7 32-bit VM in VirtualBox.

Win 7 32-bit VM in VirtualBox.

Now, to get full screen, I hit ‘Host-F’ where the Host key is usually right Control. Here’s what happens when I do that (grabbed this screen using Gimp, since Host-E gave an image identical to the above, which was not what I actually saw):

A plain grey screen with no desktop.

The Win 7 machine on going to full screen using Host-F.

Now, if we look more closely at the second image, we can see a cursor (near the top):

Close up view of the four-pointed cursor

Close up of the cursor.

What seems to have happened is that the narrow border around the screen, drawn I think by VirtualBox itself, is covering the VM screen. Since VB is drawing the border itself, and knows it is a border and not the VM screen, presumably it doesn’t capture it when Host-E is used to grab the screenshot, which is why the Host-E screenshot actually looks OK — even though the user (me in this case) can’t see anything! But Gimp captured what was really there.

Now, the fix is easy — use the four-pointed cursor (yours may look different) to resize the bottom border by clicking and dragging it all the way to the bottom of the screen:

We see the four-pointed cursor being used to change the dimension of the bottom fram to something more sensible.

Dragging the top edge of the bottom border back down to the bottom.

So I guess this counts as a minor bug in VirtualBox, but not much of an issue. So now that’s sorted out I can get on with some editing.

 

Et seq.

Light weight Linux is largely in the applications

Here, I speak out of personal experience not expertise about the underlying architecture of Linux distributions. So I may be quite wrong.

One of the best things about Linux is the wide range of options available. One category is ‘light weight’ distributions, ones that do not need the latest hardware to function well. My main experience with these comes through my netbook, which is pretty old and eqipped with 1 GB RAM, 250 GB HD and a 1.5 GHz atom n550 chip. While 1.5 GHz is reasonably fast compared to many ‘old’ processors, the low-energy design of the atom means it is limited in performance compared to a desktop chip of similar clock speed.

I currently run Debian current with MATE desktop.

Actually, MATE is a great example of the strength of open source software. When GNOME moved to version 3, some fundamental UI design changes occurred. Many did not like it, and some of those many had the skills and will to do a lot more than complain. They took GNOME 2 and continued to develop it, and such is their success that MATE is now an option in very many distributions. MATE sticks with the older idea that things be arranged in menus and the user can drill down through menus to find what they want, rather than using tiles, panels of icons and so on. MATE is especially suitable for anyone who has experience with Windows versions 95 to 7 (the versions before Windows 8 and its tiles). Just because an idea is older does not make it wrong. And it’s great that options are available, such that you have a better chance of finding an interface that matches your own mental map of the computer.

Debian is not a ‘light’ distribution. But what I have noticed is that the speed of the machine really depends on the applications I use. And so I have developed a very simple way of setting up my Linux on a slower machine; I have two of everything.

(Plus I learned how to control what processes start on boot…)

For example, for web browsing I have Dillo and Firefox. Dillo opens instantly (I use xbindkeys and fire it up with Alt-Shift-d) and its speed is limited by my internet connection (and when browsing the web, some websites are just slow and full of cruft, and a fast computer/browser/OS does not help). But Dillo is limited if you like bells and whistles — Flash, JavaScript, and so on. Lots of your standard web services are a bit … clunky in Dillo, if they work at all. So for them I have Firefox, which runs a little slow but can handle all the scripts and whatnot. I tried Midori but it’s not stable enough.

The old machine runs LibreOffice quite well. LibreOffice 5 runs faster than 3 or 4 — I think there must have been some substantial improvements under the bonnet — and while I used to have a lighter word processor (like Ted or Abiword), now I find that LibreOffice is quick enough to save me the duplication. If it’s plain text I use vim or tde, if formatted I use LaTeX or LibreOffice, which also gives me a spreadsheet.

I played around with using a simpler desktop environment — or just a window manager like FLWM, which I use on my desktop machine — but I found that on a laptop where I need to manage various wireless connections, install printers for use at offices I visit, and so on, the GUI tools provided by the DE are invaluable. I am not a guru, I am interested in usability. On the desktop, I can invest the time to get things working and then leave them alone.

By using Debian I have the luxury of knowing that:

  • forward support will be excellent (I played around with the excellent CrunchBang for a while, but then that vapourised, an experience which pushed me towards using one of the big distros)
  • the pool of available applications is vast
  • the amount of documentation and community expertise is vast
  • the ease of use is excellent (apt-get)
  • I don’t have to deal with Ubuntu and it’s weird desktop UI choices.

Maybe there is a speed penalty compared to, I don’t know, compiling from source. But overall usability is my goal, not bootup time or time for an application to open. I spend most of my time in applications, so as long as they run smoothly once open, I don’t mind if opening takes a moment. I’ll happily trade that off for stability, LTS, choice and familiarity.

 

Just my little rant.

Step-by-step install for Slitaz Linux rolling release on VirtualBox — pretty straightforward

Slitaz is a compact Linux distribution that hits a pretty solid sweet spot between efficiency and functionality. That makes it an excellent candidate for a small-footprint install inside a virtualisation environment for when you need a little bit of Linux to get a few jobs done.

For us English speakers, it lives at http://www.slitaz.org/en/

It comes in two styles — conventional stable releases, and a rolling release that is a little more up to date but might also be a little less stable. I decided to look at the rolling release. Downloaded from here — install image only about 45 MB! http://mirror.slitaz.org/iso/rolling/slitaz-rolling.iso

So began by starting VirtualBox and creating a new machine. (New; Name: Slitaz rolling Type: Linux 32-bit; other.

RAM: 256 MB

Create HD

Type: VDI, Dynamically allocated

Size: 8 GB

OK, went into:
System → Processor → enable PAE/NX

Inserted the iso using the Storage menu

Double clicked to boot

Booted Slitaz Live (first entry on list of boot options)

Waited and eventually (host is not a fast machine) got desktop

Applications → System Tools → GParted

root password is ‘root’

Device → Create partition table → MSDOS

Right clicked on unallocated space and created 1024 MB swap

Then made the rest ext4 Linux (I called it Slitaz)

‘Applied operations’

Waited till competed and exited GParted

System tools → Slitaz installer

Clicked ‘Install Slitaz’

Already done partitioning, so ‘Continue installation’

Selected ‘Install Slitaz to partition’ /dev/sda2

Set root password

Set up a user

Checked ‘Install bootloader’ then click ‘Proceed to Slitaz installation’

Nothing happened…? Waited quite a while. Clicked ‘Back to installer page’

Clicked ‘Install’ again

This time executed GParted from the menu, in case the installer ‘needed to know’ it had been executed

So opened then exited GParted, then continued with installation

Told it to format /dev/sda2 as ext4 (just to give it something to do)

Clicked ‘Proceed’ again; waited a really long time

Install proceeded — possibly I should just have waited longer the first time…

Chuntered away and then exited abruptly, leaving me with the desktop

Applications → Logout → Shut down

Interesting; VirtualBox manager noted machine as ‘Aborted’…?

Removed iso from virtual drive in the Storage menu of VB manager, then booted the VM

No luck; maybe install was incomplete?

Put iso file back in and repeat steps above (no need to repartition) but waited longer for each step to complete

Did not run GParted again, just clicked through, did not format partition

This time, the installer did not quit early, but finished and gave me an ‘Installation complete, you can now restart’ option

Clicked that option but then powered down after it started to reboot off the livedisc. Removed the iso and booted

logged in a normal user. No worries

Got TazPkg windows about recharging package lists; said OK

Typed root password; let it run then clicked ‘Check for upgrades’ — should not be many, it’s a rolling release. Came up with about 9 packages.

Clicked ‘Toggle all’ and ‘Install’ and watched it run.

Except for installer dropping out the once as noted above (and it might have been me do something odd…) install was very easy; only complexity was the need to run GParted yourself (no ‘auto partition’ option), but GParted is pretty easy to use.

———————————————–
Next, dkms, linux headers, guest additions…

Searched for dkms in TazPanel and it was there. Excellent. Checked the box for install. Searched for ‘headers’ and found ‘linux-module-headers’, so checked that for install. Then installed. Watched it do dependency tracking and then start installing. Very nifty.

Went to ‘Devices’ menu at top of VM and put in the Guest Additions image. In xterm on the guest, typed ‘su’ and logged in as root, then

cd /media/cdrom

And ran the VBoxLinuxAdditions.run script; it would not go! Permission issues, even though I was root.

Dunno why… as root, copied the file off to /home/username/ (username is the name of the user I created in the install — replace with your username) then

$chmod +xw VBoxLinusAdditions.run

and then ran it from there. It ran, but gave an error: ‘failed to set up vboxadd…’ but then I relaised I had not rebooted (installing dkms needs it, I think) and tried again.

This time, I logged in as root when I got the GUI login prompt, rather than using su.

Opened xterm, cd to cdrom, tried to run ./VBoxLinuxAdditions.run but again failed. Still would not run from /media/cdrom, but the file I copied over to the hard drive worked fine, and guest additions were installed.

Success!

OK, shared folders.

Rebooted guest, logged in as user (not root), opened a term, created a folder called sharetaz inside my /home/username directory. chmod 777 on the directory

chmod 777 sharetaz

(This is not good for security on a shared machine. There are better ways; though this is quick and easy, and reasonable in the context of a VM that one user is running when logged into their own desktop.)

On host, I decided to share my /home/username/Work folder, so just left that alone.

At top of running guest, clicked: Devices → Shared Folders → Shared Folders Settings → Add Folder Icon’ (i.e., clicked the folder plus a plus sign icon on the right).

Selected the folder on the host (easiest to use the pull down menu to select ‘Other’ and then browse). Selected ‘Make permanent’ and ‘Automount’; why not.

Gave it the name ‘Work’ as an identifier for the next step. Then saved and ok and exited from the setting dialogues.

In xterm on the guest:

su
typed root password
Then:

mount -t vboxsf -o uid=$UID,gid=$(id -g) Work /home/username/sharetaz

Failed; I checked outputs of ‘echo $UID’ and ‘echo id -g’, and both seem kind of empty. So got those values manually.

id -u username gives 1000
id -g username gives 1000

(remember, username is your username — darren, smith, whatever) so ran (still as root)

mount -t vboxsf -o uid=1000,gid=1000 Work /home/username/sharetaz

then exited su

then cd into sharetaz, and yep, there were the files in Work on the host.

Made a small file

vi textfile.txt

added some content, saved, could I see it on the host?

Yep, plus could edit file on host or guest. Looks like done!

I put the mount command in a small script which I can run as a superuser or via sudo (when I install sudo) when I need it. There are ways to mount the automatically on boot, but I can’t be bothered.

When I reboot, the share folder is empty. If I open a term window I can type

su
root password
/path/to/mount_share
exit

and there it is.

Done.

EndNote shenanigans; solution as bad as the problem

Had to update a reference list in Word using EndNote. Was much more work than it should have been.

First, turned off Track Changes (you never know what it’s going to mess with).

In Endnote Tab in Word, to update bibliography, first needed to convert all citations to unformatted, by Ctrl-A then select EndNote Tab, Convert Citations and Bibliography and then Convert to Unformatted.

Then tried to Update Citations and Bibliography – errors. ‘Update failed’.

Then accepted all changes that included citations (you never know).

Tried to recreate bibliography.

Update failed.

Then made sure all citations were not already superscript (who knows with EndNote?).

Still fell over when ‘updating in-text citations’.

OK, redid Convert to Unformatted: ‘Command failed’.

But they all seemed to be converted.

OK, pasted in original reference list from source document and tried to rerun Update.

‘Command failed’.

Apparently, there can be funny fields hidden in a Word document that can cause this error. So… went to http://endnote.com/kb/81143 which basically says
(1) Back-up your file (2) Convert to unformatted citations (3) Ctrl-A Ctrl-6 (Ctrl-6 unlinks fields, so this so-called solution can damage your document!!!)

Make sure all citations were converted to unformatted before running this! Otherwise, the field-stripping (Ctrl-6) will turn the formatted EndNote cross references into plain text!

Now, did work in that it fixed the EndNote problem – so problem fixed but … since it unlinks fields, it turned the ToC into a box of plain text and turned a whole lot of URLs distributed throughout the document into plain text. So it is a broken solution that only works at the expense of more manual work to then fix the collateral damage.

But it will have to do.

So, steps to update the references when using EndNote:

  1. Unformat citations
  2. Strip out the codes that case errors
  3. Format the references
  4. Fix all the damage done by step 2.
  5. Wish you were still working in a field that used BibTeX.

 

BibTeX.

 

Firefox opens the wrong file browser (file associations in Linux)

So I wanted to look at where Firefox stores my passwords and stuff. Following the instructions at https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data#w_how-do-i-find-my-profile. Going direct to the files did work, but… if I followed the instructions:

mozthen Firefox opened Audacious, a program for playing audio. There’s no mention of Audacious in the list of applications under Preferences. So this is looks like a silly bug that should have been fixed ages ago (I am running Firefox Quantum 57.0.4, 64-bit). I fixed it by uninstalling Audacious — Firefox then defaulted to Dolphin — but that’s not a good solution. If I reinstall Audacious… the problem comes back. It’s not Firefox’s fault, it’s a more Linux-y thing.

One suggested fix is to find and edit mimeapps.lst (at least for gnome and gnome-related). It might be, in order of precedence (ie highest up list will be the one that has the effect):

~/.config/mimeapps.list 	
/etc/xdg/mimeapps.list 	
~/.local/share/applications/mimeapps.list 	
/usr/local/share/applications/mimeapps.list
/usr/share/applications/mimeapps.list

So I found

~/.local/share/applications/mimeapps.list

and removed all entries with ‘audacity’ in them. In fact, that file was the only one populated. Then I logged out of my account, logged back in and tried it out…did not help.

Then I typed:

$ cat /usr/share/applications/mimeinfo.cache | grep  inode/directory

inode/directory=audacious.desktop;kde4-dolphin.desktop;kde4-gwenview.desktop;nautilus.desktop;

OK, so audacious is there and dolphin, which is what Firefox used when when Audacious was uninstalled, is next. So I sudo edit the file and comment out the line and replace it with a new one without audacious. In fact, I actually want nautilus so I reorder the line completely.

inode/directory=nautilus.desktop;kde4-dolphin.desktop;

But I think the MOST IMPORTANT thing was this:

sudo vim /usr/share/applications/audacious.desktop

And the last line of the file is:

MimeType=application/ogg;application/x-cue;application/x-ogg;application/xspf+xml;audio/midi;audio/mp3;audio/mpeg;audio/mpegurl;audio/ogg;audio/prs.sid;audio/x-flac;audio/x-it;audio/x-mod;audio/x-mp3;audio/x-mpeg;audio/x-mpegurl;audio/x-ms-wma;audio/x-musepack;audio/x-s3m;audio/x-scpls;audio/x-stm;audio/x-vorbis+ogg;audio/x-wav;audio/x-xm;inode/directory;x-content/audio-cdda;

So this is saying what MIME types Audacious is allowed to be thought of as opening — and one is inode/directory. So I remove it.

Now, test Firefox: BINGO!

So there you go, I’m sure no surprise to many, but this seems to work. Key files are the .desktop files, and the trick is that for some types of content Firefox uses them, not some inbuilt database of application associations, despite having such a list in its help. I edited system-wide desktop files, but you might have local versions, so check locally as well.

Sorted…

StrucFact or whatever it is called

Wrote a crude program to calculate X-ray, neutron and neutron magnetic diffraction scattering factors.

Introduction

StrucFact or StrucFact.exe is a crude program to calculate expected intensities for neutron diffraction (magnetic and nuclear) and X-ray diffraction (in the version from 2013). It is distributed as source code because any serious user will likely need to modify the source to make sensible use of it. It’s mathematics is essentially taken from Neutron Diffraction by George Bacon and H. M. Rietveld J. Appl. Cryst. (1969) 2 65-71 (see also here), and its mandate is limited; its job is to calculate F2 for neutron scattering for arbitrary cells, magnetic or nuclear, and more recently for X-ray diffraction.

It is `developed’ solely on an `as needed’ basis, which means I add `features’ when I need them to solve some problem I am working on. The inverted commas may seem gratuitous, but they are not!

I am sure there are better tools out there for everything that this program does, and I advise against using it. There should be a README.TXT and the code itself distributed with this file.

Please Note

1. It does not work for incommensurates (unless you want to define an enormous cell).

2. It treats every cell as P1 (i.e. you have to give it all atoms explicitly).

3. The nuclear and magnetic cells must be the same size, which means that if one is bigger than the other (usually magnetic bigger than nuclear) you have to put the atoms from the smaller cell into the bigger, including inserting all redundant copies of atoms.

4. No corrections for intensities (e.g. not even Lorentz), no B-factors beyond the isotropic.

In other words, it is remarkably limited. Why anyone would want to use it I do not know when FullProf and GSAS and the like are around. Having said that, it is quite simple (in the sense that everything has to be done explicitly, so it is laborious but not as conceptually demanding) compared to such programs, and the (minimally tested) code is here available.

2 Compiling

This is Fortran90 code that does not need any extra libraries. gfortran is to be preferred.

Non-static binary:

gfortran -o StrucFact.exe strucfact.f90

Please report errors in the code to /dev/null, although if desperate you can email me.

Download from http://djg.altervista.org/downloads/StrucFact_Files.tar.gz or http://djg.altervista.org/downloads/StrucFact_Files.zip. There’s a PDF inside the archive that gives more info.

Meh.

Windows programs from the command line…

This is simple but I like it. A bit old school, which suits me.

First, I created a ‘bin’ directory. Well, first first I opened a command line prompt;

C:\ cd Users\username

C:\Users\username> md bin

cd bin

C:\Users\username\bin>

Then I opened Windows menu and selected my login icon and selected ‘Change account settings’:

In the ‘Find a setting’ search box, searched for ‘env’ — this gives environment variables, including the path. Selected ‘Edit environment variables for your account’ — this does not need admin account.

Selected ‘Path’ and clicked ‘Edit’, then ‘New’ then added ‘c:\users\username\bin” to the list of directories in the path. Then clicked ‘OK’ and exited from all dialogs. (Where ‘username’ is your … username.)

Opened a command window and typed ‘path’ and verified that the new directory was at the end of the path.

Now, found the location of the three executables I wanted to access from the command line — winword.exe, excel.exe and acrord32.exe. Your paths may not be the same as those shown below. Then I put them in little batch files that were stored in the new bin directory. Batch files are word.bat, exel.bat and acrobat.bat. They look like this:

excel.bat:

REM Batch file to open excel; note that space between /t and %1 is essential!
REM also, will not work if whole path including excel.exe is quoted as a single string.
start /b c:\"Program Files (x86)"\"Microsoft Office"\root\Office16\excel.EXE /t %1

word.bat

REM Batch file to open word; note that space between /t and %1 is optional!
start /b c:\"Program Files (x86)"\"Microsoft Office"\root\Office16\WINWORD.EXE /t %1

acrobat.bat

REM Batch file to open acrobat reader
start /b "c:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe" %1

Now, these are very simple; they only take one command line argument — the file to be opened. This is 80:20 rule stuff! The Windows ‘start’ command lets me start the application using the /b flag which is like an & on a Unix command — it gives me back the command line prompt once the program starts running. Note how paths are quoted — start messes with the /t switch on Excel and Word if the whole path including the exe file name is quoted, so it has to be quoted in bits.

To use them, I just type a command (batch file name) plus the file I want to open. For example

C:\>acrobat h:\MyDocs\9780170409063_Sample_Chapter.pdf

And I get:

cli2.png

where you can see that I have got the command line back and my file has been opened in an existing session of Acrord32. Note that I have not put ‘echo off’ or anything in these batch files, so they echo the command to the screen. I quite like seeing what’s going on ‘under the bonnet’, but a prefatory ‘@echo off’ at the start of each batch file will make them run silently.

Windows CLI