Friday, January 10, 2020

Create Desktop Shortcut Ubuntu 19.10

I'm running Ubuntu 19.10 in a Virtualbox and wanted to create desktop shortcuts to programs so that I can quickly launching them (my machine is still running 16.04 since I skipped 18.04 because of Gnome Desktop).

It shouldn't be this much of a pain to create a desktop shortcut but the Gnome Desktop people think the desktop should be nothing more than a Theme Machine.  The Gnome Desktop looks and acts so much like an Apple Ipad I see Steve Jobs ghost every time I look at it.   Alright enough whining from me it's what we got so let's try to make it work for us our way.

First we need to install Gnome Tweaks.  In Terminal (Command Line) type the following:

sudo apt-get install gnome-tweaks

Once it installs, run it. Now navigate to the EXTENSIONS section and turn on the DESKTOP ICONS option.


That's all you need for Desktop Shortcuts but there are other niceties that Gnome Tweaks offers and it's worth looking over later.

To make our desktop shortcut we need to locate the "launcher" file for our chosen program. These "launcher" files are stored in a couple of locations on Ubuntu systems and they have the extension ".desktop" The ".desktop" files are located in the following two directories:

/usr/share/applications/
/home/YOURUSERNAME/.local/share/applications/

*** replace YOURUSERNAME with your logon name (user name)
*** most ".desktop" files are stored in the first location

To get to the ".desktop" files just launch the FILES program and navigate to one of the two folders where the .desktop files are stored.  (NOTE:  to get to the "/usr/share/applications" you will have to first click on the OTHER LOCATIONS option in the left hand column in FILES)


After Clicking on the OTHER LOCATIONS options you click on the COMPUTER option in the left top section of the FILES program.  After that just navigate to the "/usr/share/applications" folder and find the ".desktop" file for the program you want to create a desktop shortcut for.



Below is where ".desktop' files are stored in your home directory.
They are in a hidden folder so you have to check 
the "Show Hidden" option in FILES

Once you've found the ".desktop" file for your desired program you simple Right Click on it and select COPY.  Then navigate to the DESKTOP directory (left side panel in your FILES program) and PASTE your ".desktop" file into the DESKTOP folder.

That will make the ".desktop" file appear on your desktop but the icon will be wrong and it will not function yet. Below you can see that I copied and pasted the ".desktop" file for the program Darktable.  Notice that the "shortcut" looks like a text file and you can see ".desktop" extension still.


To finish make this a usable desktop shortcut you will need to Right Click on the ".desktop" file on your desktop and select properties. Now click on the PERMISSIONS tab and check the "Allow executing file as program" option.  Just closing Properties saves your change (click on the X in the upper right corner).



Okay now the last step.  Once again Right Click on your ".desktop" file on your desktop and you should have an option that says "Allow Launching"  just Left Click on it and it will then be ready and the icon should change to what your use to seeing associated with your program.


You can now double click on your new desktop shortcut and it should start your program.


Wouldn't it be a lot easier to just allow a right click on your desktop and browse to your desired application?  Or even have an GUI app installed by default that did most of the heavy lifting for you?  Well there's not that I know of and it gets harder from here.


METHOD 2


MAKE YOUR OWN ".DESKTOP" FILE

What if you've installed AppImages and need make a desktop shortcut for them or  if there is no "launcher" file on your system for your progam?  or maybe you've written your own Bash Script  or Python program and want a quick desktop shortcut to it.  Well you will have to make your own ".desktop" file.

I'm going to go through this quickly so that you can just get it done.  I encourage you to read more about ".desktop" files and all their options here.

First open a text editor, create a new blank document, and copy & paste the below information into it:


[Desktop Entry]
Version=2.6
Name[en_US]=Darktable
GenericName[en_US]=Graphic Editor
Comment[en_US]=This is an AppImage file link of Darktable
Exec=/home/YOURUSERNAME/AppImages/Darktable2.8.AppImage
Path=/home/YOURUSERNAME/AppImages/
Icon=/home/YOURUSERNAME/Pictures/Icons/darktable.png
Terminal=false
Type=Application
Categories=Application



Now you need to change what you copied & pasted to fit your needs.  Here is what each line means and what you should change:

[Desktop Entry]
All .desktop files start with this

Version=2.6
This is the version of your program and you really don't have to have this line or it doesn't have to be correct but you should try to get it right

Name[en_US]=Darktable
This is the name that will appear under your new desktop shortcut

GenericName[en_US]=Graphic Editor
This is a general type of application i.e. webbrowser, text editor, graphic editor etc.

Comment[en_US]=This is an AppImage file link of Darktable
Whatever you want to help you know about this shortcut

Exec=/home/YOURUSERNAME/AppImages/Darktable2.8.AppImage
This is the path to and your programs startup command.  My program's startup command is "Darktable2.8.AppImage" and that program is located in "/home/YOURUSERNAME/AppImages/" directory.  This program happends to be in my home directory in the folder AppImages.  If your's is similar you would change YOURUSERNAME to your logon or user name.

Path=/home/YOURUSERNAME/AppImages/
This is path to your program and where your program will startup

Icon=/home/YOURUSERNAME/Pictures/Icons/darktable.png
This is the path to and file name of the graphic you want to use as an icon for your program.  I have a folder in my "Pictures" folder called "Icons" where I keep all my icon graphics. Change this to fit your needs.

Terminal=false
Is this a Terminal program or command.  i.e. if this was a bash script you would set this to "true".

Type=Application
This specification defines 3 types of desktop entries: Application, Link or Directory.

Categories=Application
Categories in which the entry should be shown in a menu.

There are more options you can add and for a better explanation you really should follow this link and read more about it.

Okay, once you've changed the ".desktop" file to fit your needs save it to the DESKTOP directory with the extension ".desktop".  Make sure you have you icon graphic saved in the proper place that was referenced in the ".desktop" file you just saved.

The ".desktop" file should have appeared on your desktop after you saved the ".desktop" file to the DESKTOP directory but it will look like a text file and will not function yet.


You will now need to Right Click on the ".desktop" file on your desktop and select properties. Now click on the PERMISSIONS tab and check the "Allow executing file as program" option.  Just closing Properties saves your change (click on the X in the upper right corner).



Okay last step.  Once again Right Click on your ".desktop" file on your desktop and you should have an option that says "Allow Launching"  just Left Click on it and it will then be ready and the icon should change to what your use to seeing associated with your program.



You can now double click on your new desktop shortcut and it should start your program.


***NOTES:  When editing make sure you mind your Capital Letters in file and path names.  I tried the "~" shortcut for my home directory but it did not work for me.  Watch the "/" and make sure you have them in the right places.  When you copy .desktop file from one of the two directories they tend to have a lot more options set in their .desktop files.  You can make .desktop files that reference Bash scripts just make sure to change the Terminal=false to Terminal=true and in the Exec= part this works for me "Exec=/PathToBashScript/bash BashScriptName.sh" .  The same will work for Python too.

***ICON'S Locations.  The images used as the icons are either referenced directly with their entire path listed in the .desktop file (ICON=/path/image) or are stored in a couple of system directories. One is  "/usr/share/pixmaps" and the second is "/usr/share/icons" (most live here).  If you just see a name without a path listed in the .desktop file (i.e. Icon=imagefile) then it will be stored based off the variable $prefix which can be /usr, /usr/local or ~/.local or in one of the two directories listed above.

Sunday, January 05, 2020

USB Logitech Unified Mouse/Keyboard Quit Working

I had a Logitech Unified USB wireless mouse/keyboard combo that worked plug & play on Ubuntu 16.04.  While cleaning the PC I broke the Unified USB dongle (don't ask).  A new Unified dongle was $15 alone or you could get a new M510 Mouse and dongle for $20.  I figured, why not get the mouse too.  Once I plugged in the Logitech Unified Dongle, the mouse worked great, but there are no hardware buttons for pairing my old keyboard (k360 model).  A quick search online and I found the pairing software for Mac, Windows, and Chrome but not Linux. 

I had a plan I thought might work, I have a virtual windows 10 running on the Ubuntu 16.04 box so I downloaded the pairing software for windows and installed it on my virtual box win 10.  I then associated a USB port with the virtual win 10 and ran the pairing software on the virtual.  I plugged in the Unified Dongle when instructed and amazingly it worked and the k360 keyboard paired with the new Unified Dongle.  I then accidentally hit the RESET switch on the computer and it shut down while the virtual was still running.  Upon reboot I was getting no response from the mouse or keyboard.  In addition no USB keyboard or mouse would work (no input devices at all).  I could get into bios and the keyboards and mice worked fine, but once Ubuntu booted I could not type my password or move the mouse cursor.

How I fixed it;  

1.  After several resets I found the f12 key would bring up the GRUB menu in which I selected the ADVANCED option.


2.  This will bring up a 2nd menu.  I picked the 2nd option down the (upstart) one.


3.  This will drop you to a command line (Terminal) screen.  It will ask for your User Name and Pass Word.  Once you supply those you will be able to type commands.

4.  I reinstalled the xserver-xorg-input software from this command line with the following three commands;

sudo apt-get update
sudo apt-get install --reinstall xserver-xorg-input-all
sudo reboot

That was it.  After doing this everything worked just fine and the keyboard was still paired with the new Unified Dongle.


NOTE:  After doing this the hard way I've read that there is Linux software that does the pairing and more.  I did not use this software so you may want to research it before trying it but to install it you simple open a Terminal Window (command prompt) and type the following three commands;

sudo apt-get update   
sudo apt-get install solaar 
sudo reboot

After the reboot you will see a new icon on the top right of your screen near the date and time.


It's the bluish * looking one.

Here is an article about Solaar.  Good luck.