Finding and Recovering lost files in Git

One problem in git is that when a user deletes a file accidentally, git acts as though the user intended to do that. The next time the user runs “git commit -a” then the list of transactions will include the formal deletion of the file. People who don’t inspect the file list, or who carelessly run “git commit -a -m ‘your message'” will delete files.

Today I had that situation arise and I have a brief report on how I fixed it. If you don’t know for sure what the file path was, first scan all deleted files to see if you spot the ones you want:

$ git log --diff-filter=D --summary | grep delete

If the list is huge, grep for an element in the file name or path you are looking for. In my case, the missing file was an ogv file:

$ git log --diff-filter=D --summary | grep delete | grep ogv

delete mode 100644 36.LaTeX_Overview/LaTeX-Overview.ogv
delete mode 100644 37.LyX-for_LaTeX_homework/LyX-LaTeX_homework.ogv
delete mode 100644 46.windows_R_setup/46.windows_R_setup-slides.ogv

I had 3 files to restore. Now I know their full paths.

Find out which commit removed the files (I’ve sanitized the name of the author of the commit):

$ git log --all -- 37.LyX-for_LaTeX_homework/LyX-LaTeX_homework.ogv
commit b67eaa335379d5bb5e1187482d3647000426644d
Author: Anonymous
Date: Thu Sep 27 15:43:43 2018 -0500

Finished the installing dependencies and R sections.

There are 2 ways to recover files. These files happened to be in an LFS-enabled git repo, so the first method I tried retrieved the “reference” version of the file. I was not sure I could trust that. This method retrieved the actual ogv file:

$ git checkout b67eaa33^ -- 37.LyX-for_LaTeX_homework/LyX-LaTeX_homework.ogv

The ^ means “the one before this” because the one before this commit was the last one that had the file.

The other method of retrieving uses git show. In my git instruction manual (, we have illustration of the show method.

Posted in Uncategorized | Leave a comment

Oliver Wyman ripoff Alert

I received an email today:

Dear Paul,

Oliver Wyman is currently conducting a study to learn more about the international travel and study-abroad programs in Higher Education in order to help shape the next generation of products.

I would like to invite you to participate in our study, which should take approximately 15 minutes to complete.

As a thank you for completing the questionnaire, we will offer you the option of a $75 Gift Card or a $75 donation to the American Red Cross. At the end of the questionnaire, you will also be given the option to participate in a short follow-up phone interview for an additional $75.

Follow this link to the Survey:
Take the Survey

Or copy and paste the URL below into your internet browser:

Thank you,

Marvin So
Oliver Wyman

1166 Avenue of the Americas | New York, 10036
Direct: +1 212 345 0471

So I followed their link, wasted my time answer 14 questions, and guess what happened? Total ripoff. Website says:


So, the conclusion seems to be that Marvin So of the Oliver Wyman company is a scam artists who will waste your time.

Posted in Uncategorized | Leave a comment

Building a new xfwm4 Debian package: Try it, you’ll like it!

In the askubuntu web forum (, I asked if it is possible to change the behavior of the mouse in response to  Alt-Middle click. Currently, that causes a window to be moved to the bottom of the stack of windows. On a new Dell precision 5510, the trackpad makes it difficult to know where the left button is separated from the middle button and I often accidentally get the middle when I want left.

There were no answers for a while, so I asked same question in the XFCE4 support forum.

The answer is that the Alt-Middle click behavior (pushes window to bottom of stack) is hard coded in the xfwm4 source code. Only way to change it is to recompile xfwm4. Helpful person pointed at src file events.c line 928 for revision. I found easy to build new package and now have xfwm4 behaving the way I want!

In case you have not tried this for yourself, the process is much more straightforward than one might expect. It seems quite a bit better than it was just 18 months ago. In brief, get the source for the package, fiddle the source code, try to rebuild, let it make a patch, then build again.

$ sudo apt-get build-dep xfwm4
$ mkdir -p tmp/xfmw4
$ cd tmp/xfwm4
$ apt-get source xfwm4 
$ cd xfwm4-4.12.3/src
$ vi events.c

In that file I made a correction that amounted to this patchfile. It looks like the spaces were destroyed in cutting an pasting, but if you open events.c and go to line 928, you see there is one line I’ve commented out and one I’ve added.

+++ xfwm4-4.12.3/src/events.c
@@ -925,7 +925,8 @@ handleButtonPress (DisplayInfo *display_
else if ((ev->button == Button2) && (state) && (state == screen_info->params->easy_click))
- clientLower (c, None);
+ /* clientLower (c, None); */
+ button1Action (c, ev);
else if ((ev->button == Button3) && (state) && (state == screen_info->params->easy_click))

This causes the Alt-Middle and Alt-Left behaviors to be the same. I fiddle those lines in the source, then run

$ dpkg-buildpackage -rfakeroot

In new version of this program, there is a very handy feature. The builder notices you edited the file and it makes a patch for you and puts the patch in the debian directory, under patches. Read the output, it will be obvious what to do.

$ dpkg-source commit

Before running the builder again, edit the changelog to update the version. The easiest way is to use the helper named “dch”

$ dch

Opens a dialogue where you need to make sure you are incrementing the package name, so that when you install the new xfwm4 you will build, it gets a new number.

Then run the builder again

$ dpkg-buildpackage -rfakeroot

If all goes well, then the new packages will be in the directory above.

$ cd ..
$ sudo dpkg -i xfwm4_4.12.3-1ubuntu4_amd64.deb
$ xfwm4 --replace &

You’ll see the effect of the change right away.

If you’ve never rebuild a Debian/Ubuntu package, you might as well download the source and give it a try. This is one of the most satisfying parts of being a Linux user.

This change in xfwm4 helps me quite a lot because this touchpad is, well, very difficult to use. Without looking down at the touchpad, I find it impossible to know for sure where the left button area ends and the middle button begins. My right thumb does not always reach far enough to find the left button. By making the left and middle button alt-click behaviors the same, I reduce the error rate quite a bit.

In caveman talk, I’d say to Dell: “trackpad bad! buttons good!”. I know I’m out of style here.

Posted in Uncategorized | Leave a comment

Building R-devel on RedHat Linux 6


Warning: I’m 85% done with this, formatting is not right. I DO NOT want to type in the prompt in front of every command because then one cannot copy/paste directly.  However, copying some output chunks picks up the dollar signs and I’m inconsistent.

Brief Summary: R-devel will not build without access to newer zlib, bzip2.  This is a problem because CRAN requires users to test packages against R-devel, not against existing R or R-patched. This note has step-by-step information about what was necessary to compile & install R-devel in my user account on a cluster compute environment running RedHat 6 Linux.To upload an R package, one must agree to compile the package against R-devel, the cutting edge version of R.

The 2016 current version of R-devel has removed the versions of several compression libraries that used to be included. Instead of providing those libraries, R-devel supposes they are installed in the operating system. On my up-to-date Ubuntu laptop, this was not a concern because I have up-to-date versions of zlib, xz, pcre, and curl.On the compute cluster, which is still running RedHat 6, it is a more serious problem because the libraries zlib, bzip, pcre, curl, and xz are out of date. We find that out because when we try to build R-devel, it fails and tells us what is out of date.

As a result, one cannot configure and compile R-devel. One must get updated libraries. If the system administrators would replace all of those libraries, we could go ahead.However, in a Unix system, it is possible to compile and install support libraries in a user’s account, without system-wide intervention. With the exception of bzip2, where theinstallation is a non-standard setup, the installs of zlib, xz, curl, and pcre are standard and easy. Building R-devel on a Linux system with slightly older packges.

Here is the process I went through on RHEL6 to make this go. Special thanks to Wes Mason at KU ITTC who provided the critical ingredient.

1. Our cluster defaults to an ancient version of gcc.   I can tell my environment to use the newer gcc compiler

$ module avail
$ module load gcc/4.9.22

2. Try to build R-devel without making any special preparations.

mkdir src
 cd src
 wget --no-check-certificate
 tar xzvf R-devel_2016-02-11.tar.gz
 cd R-devel
 ./configure --help
mkdir builddir
 cd builddir
 ../configure --prefix=$HOME/packages/R-devel '--with-cairo' \
 '--with-jpeglib' '--with-readline' '--with-tcltk' \
 '--with-blas' '--with-lapack' '--enable-R-profiling' \
 '--enable-R-shlib' \
## fails ignominously:
 checking if zlib version >= 1.2.5... no
 checking whether zlib support suffices... configure: error: zlib
 library and headers are required

3. Install zlibDownload, un-tar, configure, compile

cd ~/src
 tar xzvf zlib-1.2.8.tar.gz
 cd zlib-1.2.8
 ./configure --prefix=$HOME/packages

I won’t show all the output for all of these things, but this is brief and representative

 Checking for gcc...
 Checking for shared library support...
 Building shared library with gcc.
 Checking for off64_t... Yes.
 Checking for fseeko... Yes.
 Checking for strerror... Yes.
 Checking for unistd.h... Yes.
 Checking for stdarg.h... Yes.
 Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
 Checking for vsnprintf() in stdio.h... Yes.
 Checking for return value of vsnprintf()... Yes.
 Checking for attribute(visibility) support... Yes.

This is the common GNU-style software. configure. make. make install. Run those:

make install
$ make install
 cp libz.a /home/pauljohn/packages/lib
 chmod 644 /home/pauljohn/packages/lib/libz.a
 cp /home/pauljohn/packages/lib
 chmod 755 /home/pauljohn/packages/lib/
 cp zlib.3 /home/pauljohn/packages/share/man/man3
 chmod 644 /home/pauljohn/packages/share/man/man3/zlib.3
 cp zlib.pc /home/pauljohn/packages/lib/pkgconfig
 chmod 644 /home/pauljohn/packages/lib/pkgconfig/zlib.pc
 cp zlib.h zconf.h /home/pauljohn/packages/include
 chmod 644 /home/pauljohn/packages/include/zlib.h /home/pauljohn/packages/include/zconf.h

4. Adjust the environment so R-devel builds will find packages installed there.

 export PATH=$HOME/packages/bin:$PATH
 export LD_LIBRARY_PATH=$HOME/packages/lib:$LD_LIBRARY_PATH 
 export CFLAGS="-I$HOME/packages/include" 
 export LDFLAGS="-L$HOME/packages/lib" 
The first two are vital during the “make” phase in R-devel, the latter 2 are vital in the “configure” phase in R-devel.5. Try to build R-devel again, using new zlibI remove and remake the build directory, so that any accumulated errors are eliminated
cd ~/src
cd R-devel/
rm -rf builddir
mkdir builddir
cd builddir/
../configure --prefix=$HOME/packages/R-devel --with-cairo \
 --with-jpeglib --with-readline --with-tcltk \
 --with-blas --enable-BLAS-shlib --with-lapack --enable-R-profiling \
 '--enable-R-shlib' \

That succeeds, finds zlib, but configure ends with this error:

checking bzlib.h presence... yes
 checking for bzlib.h... yes
 checking if bzip2 version >= 1.0.6... no
 checking whether bzip2 support suffices... configure: 
error: bzip2 library and headers are required

6. Get new bzlib support. This one is not built with GNU auto tools,so it is a little more interesting/idiosyncratic. Would not havesolved it without help from this site:

## So we go get bzlib, which is part of bzip2, just like we did on zlib

cd ~/src
tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6

Inspect the README. Temptation is to be careless and just run make, but that’s not quite enough because we need the shared library. Then make after

make -f Makefile-libbz2_so
 make clean
 make -n install PREFIX=$HOME/packages
 make install PREFIX=$HOME/packages

7. Try to build R-devel again

cd ~/src/R-devel
 rm -rf builddir/
 mkdir builddir
 cd builddir
 ../configure --prefix=$HOME/packages/R-devel '--with-cairo' \
 '--with-jpeglib' '--with-readline' '--with-tcltk' \
 '--with-blas' '--with-lapack' '--enable-R-profiling' \
 '--enable-R-shlib' \

configure fails with

checking whether bzip2 support suffices... no
 checking for lzma_version_number in -llzma... no
 configure: error: "liblzma library and headers are required"

8. Go get liblzma. I tried that, couldn’t compile that, but Wes Mason warned me not to try to install the separate liblzma, but rather get the package known as xz.

cd ~/src
tar xzvf xz-5.2.2.tar.gz
cd xz-5.2.2
./configure --prefix=$HOME/packages
make -j3
make install

8.  Try R-devel again, same steps as before, make builddir, then

../configure --prefix=$HOME/packages/R-devel '--with-cairo' \
 '--with-jpeglib' '--with-readline' '--with-tcltk' \
 '--with-blas' '--with-lapack' '--enable-R-profiling' \
 '--enable-R-shlib' \

That gets quite a bit further and fails:

checking for pcre/pcre.h... no
 checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support... no checking whether PCRE support suffices... configure: error: pcre >= 8.10 library and headers are required

9. Get pcre. This is getting old now

cd ~/src


 tar xzvf pcre-8.38.tar.gz
 ./configure --prefix=$HOME/packages
 make -j3
 make install

9B. Back to R-develR-devel configure fails same way:

checking for pcre/pcre.h... no
checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support...
no checking whether PCRE support suffices... 
configure: error: pcre >= 8.10 library and headers are required

9C So I suspect the UTF-8 support is the issue.Back to PCRE, reconfigure. Usually, best to erase whole sourcedirectory and get a clean run at it. Because I did not do safe thingand use a builddir in there, I have to do that. I run this configure command,

./configure --enable-utf8 --prefix=$HOME/packages
make install

10. Try R-devel again.Fails asking for libcurl

 checking libcurl version ... 7.19.7
 checking curl/curl.h usability... yes
 checking curl/curl.h presence... yes
 checking for curl/curl.h... yes
 checking if libcurl is version 7 and >= 7.28.0... no
 configure: error: libcurl >= 7.28.0 library and headers are 
required with support for https

11. Install libcurl## Note need ignore certificate problem on this one

 cd ~/src
 wget --no-check-certificate
 tar xzvf curl-7.47.1.tar.gz
 cd curl-7.47.1
 ./configure --prefix=$HOME/packages
 make -j3
 make install

12. Try R-devel again

cd ~/src
 cd R-devel
 rm -rf builddir
 mkdir builddir
 cd builddir
 ../configure --prefix=$HOME/packages/R-devel '--with-cairo' \
 '--with-jpeglib' '--with-readline' '--with-tcltk' \
 '--with-blas' '--with-lapack' '--enable-R-profiling' \
 '--enable-R-shlib' \

HOORAY, it finished!

config.status: creating tests/Embedding/Makefile
 config.status: creating tests/Examples/Makefile
 config.status: creating tools/Makefile
 config.status: creating src/include/config.h
 config.status: executing libtool commands
 config.status: executing stamp-h commands
R is now configured for x86_64-pc-linux-gnu
Source directory: ..
 Installation directory: /home/pauljohn/packages/R-devel
C compiler: gcc -std=gnu99 -I/home/pauljohn/packages/include
 Fortran 77 compiler: gfortran -g -O2
C++ compiler: g++ -g -O2
 C++11 compiler: g++ -std=c++11 -g -O2
 Fortran 90/95 compiler: gfortran -g -O2
 Obj-C compiler: gcc -g -O2 -fobjc-exceptions
Interfaces supported: X11, tcltk
 External libraries: readline, BLAS(generic), LAPACK(generic), curl
 Additional capabilities: PNG, JPEG, NLS, cairo, ICU
 Options enabled: shared R library, R profiling, memory profiling
Capabilities skipped: TIFF
 Options not enabled: shared BLAS
Recommended packages: yes
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally

That last warning, well, I’m ignoring it. I don’t need to build their documents, I need to see if my package builds without errors. I don’t care much that shared BLAS is not enabled, but I ususally would want that if I were making a production system.However, running


ends in failure:

gcc -std=gnu99 -shared -fopenmp -L/home/pauljohn/packages/lib -o 
CommandLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o 
arithmetic.o array.o attrib.o bind.o builtin.o character.o coerce.o 
colors.o complex.o connections.o context.o cum.o dcf.o datetime.o 
debug.o deparse.o devices.o dotcode.o dounzip.o dstruct.o 
duplicate.o edit.o engine.o envir.o errors.o eval.o format.o 
gevents.o gram.o gram-ex.o graphics.o grep.o identical.o 
inlined.o inspect.o internet.o iosupport.o lapack.o list.o 
localecharset.o logic.o main.o mapply.o match.o memory.o 
names.o objects.o options.o paste.o platform.o plot.o plot3d.o 
plotmath.o print.o printarray.o printvector.o printutils.o qsort.o 
radixsort.o random.o raw.o registration.o relop.o rlocale.o 
saveload.o scan.o seq.o serialize.o sort.o source.o split.o 
sprintf.o startup.o subassign.o subscript.o subset.o summary.o 
sysutils.o times.o unique.o util.o version.o g_alab_her.o 
g_cntrlify.o g_fontdb.o g_her_glyph.o xxxpr.o `ls ../unix/*.o 
../appl/*.o ../nmath/*.o` ../extra/tre/libtre.a -lblas -lgfortran 
-lm -lquadmath -lreadline -lpcre -llzma -lbz2 -lz -lrt -ldl -lm 
-licuuc -licui18n
 /usr/bin/ld: /home/pauljohn/packages/lib/libbz2.a(bzlib.o): 
relocation R_X86_64_32S against `BZ2_crc32Table' can not be used 
when making a shared object; recompile with -fPIC
 /home/pauljohn/packages/lib/libbz2.a: could not read symbols: Bad value
 collect2: error: ld returned 1 exit status
 make[3]: *** [] Error 1
 make[3]: Leaving directory `/panfs/'
 make[2]: *** [R] Error 2
 make[2]: Leaving directory `/panfs/'
 make[1]: *** [R] Error 1
 make[1]: Leaving directory `/panfs/'
 make: *** [R] Error 1

13. That’s certainly pointing the finger back at bzip2, which is the only non-standard library in the whole batch. It doesn’t use GNU autoconf, has vague instructions. I went into the bzip2 directory and inserted -fPIC as a CFLAG in the Makefile. Then I ran make and make install PREFIX=$HOME/packages again, as above14. R-devel, againrm the builddirmake a new builddir, go in there, run the configure statement, looksOK


succeeds. Be aware, it is VITAL the PATH and LD_LIBRARY_PATH be set in the environment as stated above.Here’s the evidence it did eventually compile

make[2]: Leaving directory `/panfs/'
make[1]: Leaving directory `/panfs/'
make[1]: Entering directory `/panfs/'
building/updating vignettes for package 'grid' ...
building/updating vignettes for package 'parallel' ...
building/updating vignettes for package 'utils' ...
make[1]: Leaving directory `/panfs/'
make[1]: Entering directory `/panfs/'
configuring Java ...
Java interpreter : /usr/bin/java
Java version : 1.7.0_09-icedtea
Java home path : /usr/lib/jvm/java-1.7.0-openjdk-
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program 
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
make[2]: Entering directory `/library/tmp/Rjavareconf.wg86X6'
gcc -std=gnu99 -I/home/pauljohn/src/R-devel/builddir/include -I/usr/lib/jvm/java-1.7.0-openjdk- -I/usr/lib/jvm/java-1.7.0-openjdk- -I/usr/local/include -fpic -I/home/pauljohn/packages/include -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/home/pauljohn/src/R-devel/builddir/lib -L/home/pauljohn/packages/lib -o conftest.o -L/usr/lib/jvm/java-1.7.0-openjdk- -ljvm -L/home/pauljohn/src/R-devel/builddir/lib -lR
make[2]: Leaving directory `/library/tmp/Rjavareconf.wg86X6'
JAVA_HOME : /usr/lib/jvm/java-1.7.0-openjdk-
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /home/pauljohn/src/R-devel/builddir
make[1]: Leaving directory `/panfs/'


Posted in Linux | Tagged , , , | 41 Comments

New lifescape panorama


Today, I was struck by the beauty of the desert on a crystal clear morning. As the panorama below  indicates, there is no apparent sign of life in this seemingly barren, desolate part of the high plains. Only the grizzled veterans like me can see the glimmers of life that lie deep within the sand, waiting for the rainy season to bring precious moisture.

The library on new year's eve

The library on new year’s eve

When the rainy season comes (or the semester starts), the isolated cedar and cactus trees will not look so lonely.

Posted in Uncategorized | Leave a comment

Time Series tips for R users

Two people were in here last week asking me about time series modeling in R. I said I’d look something up.

I thought this was fabulously helpful for translating between R and time series books:

The leading authority on time series, especially ARIMA, in R is probably Rob Hyndman:

A new tutorial that was announced today that reminded me I promised to look up time series materials.

Posted in R | Tagged | Leave a comment

Get out of fail2ban jail

Ever get locked out of your own computer because you tried the password too many times when you were, well, not paying attention? I found it tough to find how to unban myself and was pretty frustrated by the ambiguity of the instructions. Not ambiguous. Comprehensive. I don’t really want to know any more about fail2ban than how to remove one particular IP.

First, get a list of the jails
# fail2ban-client status

|- Number of jail: 1
`- Jail list: sshd

Then review the banned things

# fail2ban-client status sshd

Status for the jail: sshd
|- Filter
| |- Currently failed: 2
| |- Total failed: 634
| `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd
`- Actions
|- Currently banned: 2
|- Total banned: 4
`- Banned IP list:

# fail2ban-client set sshd unbanip

I didn’t find this recipe written down anywhere, probably it is too obvious for an expert to write it own.

However, this guy writes interesting scripts and I was able to deduce the required actions from reading his code

Posted in Linux | Tagged | Leave a comment

OpenBUGS-3.2.3 Linux Packages

I’m very sorry I stopped paying attention to the packaging on openbugs for a while. I stopped reading the gmail account because I hated their labeling system, but that account is where I’m registered in the OpenBUGS list.

Oh, well. We are back up to date now

1. RedHat/Centos 6 and 7

This is a fully fledged EL repository server, users can add the repo to yum and it will be automatic. Otherwise, can download the old fashioned way…

3. Ubuntu

That’s not a fully fledged repository, that’s too baroque for me. But you can download the package file. I left the whole build directory there and everything, so in case you wonder what is in there, be my guest to snoop about

Posted in Linux | Tagged | Leave a comment

Gambit packages updated

Linux packages for Gambit were built yesterday. All of these do install and I’m able to open the Gambit GUI and create a game. I compiled with no special arguments, these may not include all of the features you want. If I got that wrong, email me at I’m willing to do this once again, but only if you ask:).

The RPM for EL7 systems can be found in the repo described here:

but if you just want the RPM, get them here:

If you are in different flavor of Linux, maybe you rebuild the SRPM instead:

I also built packages for Ubuntu/Debian systems. I was uncertain at first if the stable version of Gambit is 13.1.2 or 14.1.0, and so I made both. Get the deb files in these directories

I am struck once again by how incredibly baroque and cumbersome the Debian packaging process has become. Its too bad. I did not build an apt repo, there’s no straightforward way to do that. Again, too bad.

This Gambit compile did not produce any shared libraries, which improves the chances that one can run them on similar, but not identical, Linuxes. I’m almost certain these will install & run on Debian or Ubuntu-based Mint. If not, all of the stuff to rebuild is uploaded in the same directory.

This version of Gambit does require the wxWidgets 2.8 or newer. In the end, I used the newest ones I could get more-or-less easily. I used the wx from the EPEL repo on the EL7 system. That provided:


It appears to me I may have been conservative there, I did not intentionally avoid the packages named wxGTK3 on EPEL, I simply took the first set I understood. If you require RPM based on wxGTK3, I think i can do it. Just let me know.

On the Ubuntu system, the wx 3.x is available in the default repositories. However, there is an allegation of an unpatched bug (which I’ve not experienced). Currently, I’m running with these packages:


Note the last one is the “unofficial” version, that’s an update from the non-base repo. In my heart, I don’t think you really need that, but I was feeling compulsive and downloaded it from the wx home site. If you want your Ubuntu to work exactly like mine, you can install this repo

deb utopic universe

I found that by Mr. Google, same way you would, I expect ( leads you to which leads to

There is an open question on how to package some working examples and make them easy for users of these packages. I’ve asked in the gambit email list. In the olden days, I recall packging up the Gambit test programs with this and telling users how to run from the command line to test the calculations. I can’t find any evidence of that now, however. It would be nice if we could set this up to install some examples that are supposed to run. Maybe call them templates or whatnot. They may be in the source code now, but I’m too careless to find them. What do you think?

I promised one user I’d demonstrate steps to compile Gambit on EL7.

I did a “manual compile” as a non-root user that installed into /tmp, for exploration. The session was in an Emacs shell, here it is, errors and all:

I had to install wxWidgets devel support from the EPEL repository. In case you want to see what the RPM building process does, here is the output

Posted in Linux | Tagged , , , | Leave a comment

Compiz, Multi-Head, Workspace Backgrounds

The approach described in the post earlier this week works well on single-head systems, but not when there are several monitors. Compiz handles these differently than XFCE4 or Gnome, causing some revision in the script.

Since Compiz treats the combined monitors as a single workspace, it is not actually possible to show separate images on the separate monitor backgrounds. There is a workaround, however: Use ImageMagic montage to manufacture a large image and then let compiz display that. I wanted the script to be flexible, so the -w argument now has 4 roles.

If -w -2, then all workspace backgrounds will be reset with randomly drawn images from one directory
If -w -1, then all workspaces are set to the same background
If -w n, for any “n’th” workspace, then that workspace will be replaced
If -w n > existing number of compiz wallpapers, then the new image will be added for the n+1’th workspace.

The -p argument determines whether we are setting for one page (one monitor) or two pages (2 monitors).

WIthout further adieu, here’s the script that works. I never wrote anything in Python before, so take mercy

#!/usr/bin/env python3

## Paul E. Johnson 
## 20150102

## A script to randomly reassign compiz background images for viewports.
## Recall compiz after 0.9.2 uses "viewports" to simulate workspaces.

## Will choose an image file randomly from within dir hierarchy. 

## Can replace one viewport's wallpaper.  The w argument will be
## interpreted in one of 3 ways 

## 1. If w is either 0 or -1, this means remove all
## existing wallpapers and replace with one randomly chosen image.
## 2. If w is -2, then all workspace backgrounds will be replaced
## with different images from same directory
## 3. If 1 < = w <= N (where there are N wallpaper images already
## defined), then the image on viewport w will be replaced. All of the
## other images will remain the same.
## 4. If N < w, we interpret this as a request to expand the
## wallpaper array by one.

## I thought it was a little interesting to make types 1 and 3
## work together with compiz. To change the number of wallpapers,
## it is required to correctly change these variables in the
## wallpaper plugin as well:
## "bg-fill-type"
## "bg-image-pos"
## "bg-color1", 
## "bg-color2", s

## I had previously been doing this by dbus-send, but compiz's
## interaction with dbus has become less and less stable, so this version
## uses "gsettings".

## About the schema argument:
## Because I do not use Unity as my desktop environment, I have to point
## SCHEMA at the location where compiz stores wallpapers. If you get
## compiz working with XFCE4, for example, make sure you use the Gsettings
## backend and DO allow Compiz to interact with the desktop environment in
## advanced settings. 

## If you are using Unity, you probably need to change the path, removing
## "Default" with "unity".  You can do from command line or by editing script.

## If you want to know how to get Compiz going without the Unity Desktop, 
## this is not a bad set of advice 
## If you have Unity installed, it is necessary to remove it, or else
## launching compiz with the Gsettings back end gets Ubuntu all confused and
## Unity keeps starting at same time. If you have trouble with that, I can help

import argparse
import subprocess
import sys
import os
import random

parser = argparse.ArgumentParser()
parser.add_argument("-d", "--dir",  help = "directory path", 
                    default = "/usr/local/share/Backgrounds")
parser.add_argument("-p", "--pages",  help = "pages", 
                    default = "1", type = int)
parser.add_argument("-w", "--workspace", 
                    help = "workspace number, -1,  0, 1-n, or > n", default = "0", 
                    type = int)
parser.add_argument("-schema", help = "gsettings shema", 
                    metavar = "SCHEMA", default = "org.compiz.wallpaper:/org/compiz/profiles/Default/plugins/wallpaper/")
parser.add_argument("-key", help = "gsettings key", metavar = "KEY", default = "bg-image")
args = parser.parse_args()

array = eval(subprocess.check_output(["gsettings", "get", args.schema, args.key]))

## print(array)
arraylen = len(array)

## python arrays index 0, ... , N-1, so downshift workspace number
ws = args.workspace - 1

def getFn( pages, mydir, myws ):
    if pages > 1:
        dirlist = [os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(mydir)) for f in dn]
        if (len(dirlist) > 0):
            filelist = [os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(random.choice(dirlist))) for f in fn]
            filelist = [os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(mydir)) for f in fn]
        filename1 = random.choice(filelist)
        filename2 = random.choice(filelist)
        newfn = '/tmp/dual-%d.jpg' % myws
        if (os.path.isfile(newfn)) == True:
            newfn = '/tmp/dual-%d.%s.jpg' % (myws, "2")["montage", filename1, filename2, "-tile",  "2x1", "-geometry", "1600x1200+0+0", "-background", "black", newfn])
        filename = newfn
        filename = random.choice([os.path.join(dp, f) for dp, dn, fn in os.walk(os.path.expanduser(mydir)) for f in fn])
    print("The newly found filename is:")
    return filename

## print("Array length was")
## print(arraylen)

## If ws 0 or smaller, we are going to reset whole collection back to
## just one image. if ws > N of images, then add a new image.
if ws == -3:
    for num in range(len(array)):
        array[num] =  getFn(args.pages, args.dir, num)["gsettings", "set", args.schema, args.key, str(array)])
elif ws < 0:
    filename = getFn(args.pages, args.dir, 1)
    array=[str(filename)]["gsettings", "set", args.schema, args.key, str(array)])["gsettings", "set", args.schema, "bg-fill-type", str("[0]")])["gsettings", "set", args.schema, "bg-image-pos", str("[0]")])["gsettings", "set", args.schema, "bg-color1", str("['#000000ff']")])["gsettings", "set", args.schema, "bg-color2", str("['#000000ff']")])
elif ws < arraylen:
    filename = getFn(args.pages, args.dir, ws)
    array[ws]=str(filename)["gsettings", "set", args.schema, args.key, str(array)])
    filename = getFn(args.pages, args.dir, len(array))
    array.append(str(filename))["gsettings", "set", args.schema, args.key, str(array)])
    arraylen = len(array)["gsettings", "set", args.schema, "bg-fill-type", str([0]*arraylen)])["gsettings", "set", args.schema, "bg-image-pos", str([0]*arraylen)])["gsettings", "set", args.schema, "bg-color1", str(['#000000ff']*arraylen)])["gsettings", "set", args.schema, "bg-color2", str(['#000000ff']*arraylen)])["gsettings", "set", args.schema, args.key, str(array)])

print("HELLO, corrected image array is:")               
print('\n '.join(array))

Now, if you don't want to use Compiz, but instead any other XFCE4 compatible window manager, such as OpenBox, then you can use XFdesktop to draw separate backgrounds on the monitors. I've done that too.

Posted in Linux | Tagged , , | Leave a comment