Ubuntu – Unity, XFCE, etc: making/changing applications shortcuts

For Unity, XFCE, and many more desktop environments, the files that cause programs to show up in your menus and Unity menus are in two places:

/usr/share/applications
~/.local/share/applications
<–especially for WINE

Sometimes an application might not show up in your menus nicely because it doesn’t have a .desktop file in either of these locations. Try opening one of the .desktop files for a program that works, and saving as a new file for a program you’d like to work the same way.

SeeĀ https://help.ubuntu.com/community/UnityLaunchersAndDesktopFiles for more details.

Draftsight CAD software on Ubuntu 14.04 or 12.04 64-bit

You can easily install this and other .deb programs that have complicated prerequisites by using GDebi:
sudo apt-get install gdebi
sudo gdebi ~/Downloads/draftsight.deb

 

That should be it. Draftsight 2015 is for 64-bit Linux. The information below is not needed and out of date.
—————————————————————-

Manual, complicated way follows:

You can also consider trying more libre options

Note: These directions applied to Draftsight version V1R3.1 .. V1R5.1

Note: alternatively, Draftsight Windows version will run mostly fine under Wine 1.6.

Here’s how to install the Draftsight V1R5 prerequisites on Ubuntu 12.04 14.04
sudo apt-get install libxcb-render-util0:i386 libpixman-1-0:i386 libgtk2.0-0:i386 libaudio2:i386 libdirectfb-1.2-9:i386 libdirectfb-extra:i386
libpango1.0-0:i386 libpangox-1.0-0:i386 libpangoxft-1.0-0:i386
libts-0.0-0:i386 libxft2:i386

Now, we’ll install Draftsight
sudo dpkg -i ~/Downloads/draftSight.deb

and fix the missing requirements if any with a second command:
sudo apt-get -f install

now try typing draftsight at terminal and see if the splash screen AND the second window requesting your registration pops up (careful, this second registration window is sometimes hidden under other app windows you have open!)
=======================
If draftsight isn’t “found”, probably the link wasn’t put automatically into /usr/bin/draftsight. In that case, try:

cd /opt/dassault-systemes/DraftSight/Linux/
(Note: before V1R5, path was: cd /opt/dassault-systemes/draftsight/bin )
and type
./draftsight
If that works, then you need to create a softlink to the binary by typing in Terminal:
sudo ln -s /opt/dassault-systemes/DraftSight/Linux/DraftSight /usr/bin/draftsight
====================
if you don’t have an icon in the “start menu” of Ubuntu, try doing in Terminal:
sudo nano /usr/share/applications/draftsight.desktop
and paste this content into this file then save and try your start menu again:

[Desktop Entry]
Name=DraftSight (Linux)
Comment=Edit DWG/DXF files
GenericName=DraftSight
Exec="/opt/dassault-systemes/DraftSight/Linux/DraftSight"
Type=Application
Terminal=false
Icon=dassault-systemes.draftsight

Categories=Application;Graphics;
========================

Note, you may not be able to X-Forward your desktop running Draftsight. I haven’t tried VNC.

Ubuntu: Fixing Desktop icons and Menu items for MATLAB

MATLAB doesn’t automatically setup itself in the menus of Ubuntu, but you can easily fix this with these two steps:

type in Terminal:
sudo wget http://upload.wikimedia.org/wikipedia/commons/2/21/Matlab_Logo.png -O /usr/share/icons/matlab.png

sudo nano /usr/share/applications/matlab.desktop

cut and paste these lines:
#!/usr/bin/env xdg-open
[Desktop Entry]
Type=Application
Icon=/usr/share/icons/matlab.png
Name=MATLAB R2014a
Comment=Start MATLAB - The Language of Technical Computing
Exec=matlab -desktop
Categories=Development;

Of course, changing MATLAB R2014a to the version you have (not critical)

(based off of: https://help.ubuntu.com/community/MATLAB/)

Ubuntu 12.10: renaming ethernet interfaces from “p1p1″ to “eth0″

Sometimes, an ethernet interface will install itself as “p1p1″ or the like instead of the traditional “eth0″.

Some software (e.g. MATLAB) will only accept “eth0″ for licensing.

Here’s how to rename your network card in Ubuntu 12.10:

  1. Get your ethernet card MAC address: ifconfig | grep HWaddr
    keep it handy (open a new Terminal window for following steps)
  2. cd /etc/udev/rules.d
  3. backup your file: cp 70-persistent-net.rules 70-persistent-net.rules.bak
  4. edit your file: sudo nano 70-persistent-net.rules
  5. very carefully type: SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="xx:xx:xx:xx:xx:xx", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
    where the xx:xx:xx are your MAC HWAddr from Step 1
    Type this all as one big long line, then save and exit.
  6. edit /etc/network/interfaces to refer to eth0 instead of p1p1 or whatever [thanks Konstantin]
  7. reboot
  8. login and type ifconfig to confirm your network adapter is at eth0

Repairing broken symbolic link (linux)

First of all, be sure you know what you’re doing.

A symbolic link may become broken due to updating/compiling/installing software, showing up as red text in ‘ls’ in Terminal. Let’s suppose our broken link is named “foo.so”

Steps

  1. find where link pointed to: readlink -v foo.so
  2. Determine where link should point do (e.g. a new version of the old file), lets say foo2.so
  3. Update link: ln -sfn foo2.so foo.so

Now you have your foo.so showing up as a light blue file in terminal, pointing to foo2.so

REGEXP to get formatted date out of arbitrary length string

This regexp was tested in Octave 3.6 and Matlab, and will hopefully work in plurality of regexp parsers in C etc.
Based off of regexp string from:
http://www.regular-expressions.info/dates.html

REGEXP string to get YYYY-MM-DD string from arbitrary length string:
(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])

Matlab/Octave REGEXP date string example code:

input = '09av8joj23oit2pojiijo/20398/vj89/2012-10-15/0298f9082j23'; %random stuff with date in it
regStr = '(19|20)\d\d([- /.])(0[1-9]|1[012])\2(0[1-9]|[12][0-9]|3[01])';
[startIndex,endIndex] = regexp(input,regStr,'start','end')

This returns:
startIndex =
34

endIndex =
43

which means that you can grab the date out of this input mess by typing in Matlab/Octave:
myDate = input(34:43);

MATLAB/Octave: check free disk space

This method is for Matlab or Octave running on Linux (or Cygwin) systems only.

The example below assumes you want to check the free space on your C:\ drive using Cygwin,
or your HOME directory using Linux. Choose one or the other.


myDrive = '/cygdrive/c'; %for cygwin
myDrive = '~'; % for Linux

[err,freeSpaceBytes] = unix(['df --block-size=1 ',myDrive,' | tail -1 | awk ''{print $4}'' '])