Open any kind of file from the terminal with an “open” command (Linux)

Mac OS X has a handy script called “open” that lets you open basically any kind of file from command line inside it’s default application. For example, if you are navigantig through the terminal and there is a file called “document.pdf” and you need to open it, you can simply do: “open document.pdf” and it will open the document inside the Preview app. Another example is: “open picture.png” and the open command will do the same thing. As simple as that.

But as a Linux user, I was wondering if there is such a command to use from the terminal emulator under my Linux box. If you try the “open” command, it will probably not work, unless the word “open” is an alias pointing to whathever program/script you have. But it happens that we do have the command “xdg-open” built-in the Linux shell that will get the job done. You can invoke, from the command line, the very same commands (but using the “xdg-open” command instead). For example: “xdg-open document.pdf” and it will open the document inside eg., Evince (it will depend on your desktop environment). You can do “xdg-open picture.png” and it will open the picture inside the Eye of Gnome or whaterever picture viewer you have as a default.

If you want to keep things common between the two systems, specially if you are a command line user in both, just make an alias called “open” pointing to “xdg-open”:

$ alias open="/usr/bin/xdg-open"

In fact, almost every desktop environment has its built-in “open” command, but “xdg-open” is more generic.

That’s it!

Reference:

http://https://budts.be/weblog/2011/07/xdf-open-vs-exo-open

Quick fix for dropbox icons appearance (Linux)

If you tried to use the hardcode-tray script to fix the appearance of the tray icons under Linux desktops, you may have noticed that dropbox icons still look the same. This might happen if you install dropbox from here, instead from your linux official repository. If this is your case, you can use this easy fix to get the correct icons:

  1. First you need to locate the correct dropbox icons within your icon theme installation. In my case, I am using the Papirus icon theme. On my Linux, they are located at “/usr/share/icons/Papirus/”;
  2. Under the Papirus directory, you will find a folder named “22×22/panel”, where are the target dropbox icons. Note that I’m using the “22×22” size. Copy the following icons to “~$USER/.dropbox-dist/dropbox-lnx.x86_64-20.3.15/images/hicolor/16×16/status”. Note that your dropbox version might be different!
  3. Convert the SVG icons to PNG (it got to be PNG, otherwise dropbox will show no icons in the system tray). Use the following command to convert the icons properly:
inkscape -z -e output.png -w 22 -h 22 input.svg

This command will get the job done. But as dropbox use several icons to indicate each state, then you have to use the same command to convert each icon. To get all icons converted at once, use a modified version of this command:

for i in $(ls *svg); do j=$(echo $i | sed "s,.svg,,g"); inkscape -z -e $j.png -w 22 -h 22 $i; done

This command list all SVG files, strip the “.svg” extension; run the inkscape command and done! Note that the icons will be converted to 22px x 22px. If this is not your case, just change the output size accordingly.

Images:

Before

img-alternative-text

After

img-alternative-text

Thats all!