CSS

Tuesday, October 31, 2017

Move dropbox directory on Linux using the command line

Short Answer

You can't.  All the stuff on the internet is real old.   I worked on this for 10 hours and here is my answer.

How to get the directory where you want

This is only really useful if you want to move the dropbox directory to a filesystem other then the one your users are on.

Create a user whose home directory is where you want the Dropbox directory to be.  The Dropbox directory is going to end up under this user's home directory.  

Why is this better then a symbolic link?

It is better than a symbolic link since because Dropbox uses OS level file notifications calls to decide what to sync.  These do not work through a symbolic link.  If you just make a link called Dropbox and point it to another filesystem your files will not be synced.  You can change and create files through a symbolic link.  Dropbox needs to have a real link to work.

Tuesday, June 27, 2017

Fix Greeter Login panel on Ubuntu 17.04

This works with all flavors of Linux that use LightDM as their greeter.

When my laptop was in its docking station, the login prompt would not display.  I guess it was displaying on the closed laptop display.

Create a file /opt/sbin/set-prime-mon

Contents:
#!/bin/sh
# Set prime monitor to left most
LOG=/var/log/set-prime-mon.log
# Remove any previous logs
rm -f $LOG
output=$(xrandr | grep -E " connected (primary )?[1-9]+" | grep "+0+0" | sed -e "s/\([A-Z0-9]\+\) connected.*/\1/")
echo $output >> $LOG 2>&1
if [ -n $output ]; then
 echo "setting prime to $output" >> $LOG 2>&1
 xrandr --output $output --primary
fi

Create a file /etc/lightdm/lightdm.conf.d/99-setprime.sh

Contents:
display-setup-script=/opt/sbin/set-prime-mon

Wednesday, April 19, 2017

Stopping new Icon when I launch a java appication from Gnome or Unity

So I had successfully created a .desktop file to launch Eclipse from Gnome.  I also found it no problem  making it a favorite.  The problem I was having was every time I launched Eclipse I ended up with 2 icons.  The Favorite and one for the running process.  The trick to making not getting this is to make sure the .desktop name matches the xwindows WM_CLASS property. You can get this value by running:

 xprop WM_CLASS 

Next click on the window of the Java application you are interested in.  In the case of Eclipse the value is "Eclipse" so the file needs to be named Eclipse.desktop.

Thursday, March 30, 2017

Java Base64 OutputStream cutting off characters

This took me a while to figure out. I am using a Outputstream to write create a piece of XML.  One of the elements needed to be Base64 encoded.  I wrapped my outputstring using java.util.Base64.wrap.  I did not close the Base64 OutputStream.  It is not really clear but the close of this stream is when it takes care of padding,

Bad Code

// out is a FileOutputStream 
final Base64.Encoder encoder = Base64.getMimeEncoder(); 
final OutputStream clob = encoder.wrap(out); 
IOUtils.copy(in, clob, Charset.forName("UTF-8")); 
// No close of clob Just went and kept writing to out 

Good Code

// out is a FileOutputStream 
final Base64.Encoder encoder = Base64.getMimeEncoder(); 
final OutputStream clob = encoder.wrap(
      new CloseShieldOutputStream(out)); // Use nice Apache IO Wrapper that does                        // not chain close 
IOUtils.copy(in, clob, Charset.forName("UTF-8")); 
clob.close(); // this forces out the padding